Announcement

Collapse
No announcement yet.

ShipState Conditional Question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    ShipState Conditional Question

    I am trying to make a conditional on the OCST page that will display text if a certain state is selected. I have tried to hack my way through it which has (barely) worked in other areas but I just can't figure this one out. In my mind something like this should work... but I guess I wouldn't be here if it did

    <mvt:if expr="l.ShipState EQ 'Texas' ">
    Hello Texas!
    </mvt:if>

    Any help would really be appreciated.

    #2
    Unless the values have been changed for some reason, you test the ShipState with the ISO value or the State abbreviation. In your case, Texas is TX I believe.

    Unless the customer is logged in already or has previously filled out the form on OCST, ShipState might not be populated yet. That means the condition will fail until that happens. Regardless, you probably need to check that variable like this:

    Code:
    <mvt:if expr="toupper(ShipState) EQ 'TX' ">
    or

    Code:
    <mvt:if expr="toupper(g.ShipState) EQ 'TX' ">
    Because ShipState is a CGI or global variable.

    Hope that helps,

    Scott

    BTW: likely don't need to use toupper() function in this case. It's my preference to make sure the strings I am comparing will be evaluated the same.
    Last edited by ids; 12-03-18, 12:07 PM.
    Need to offer Shipping Insurance?
    Interactive Design Solutions https://www.myids.net
    MivaMerchant Business Partner | Certified MivaMerchant Web Developer
    Competitive Rates, Custom Modules and Integrations, Store Integration
    AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
    My T-shirt Collection is mostly MivaCon T-shirts!!

    Comment


      #3
      Thank you! I could not get your exact code to work but the global variable & abbreviation got me back on the right track. The code below ended up working perfectly!

      <mvt:if expr="g.Basket:ship_state EQ 'TX'">

      Comment


        #4
        NP. Glad you found out the var name.

        (Interesting that the var name didn't work. I verified that ShipState was the NAME of the input.)


        Scott
        Need to offer Shipping Insurance?
        Interactive Design Solutions https://www.myids.net
        MivaMerchant Business Partner | Certified MivaMerchant Web Developer
        Competitive Rates, Custom Modules and Integrations, Store Integration
        AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
        My T-shirt Collection is mostly MivaCon T-shirts!!

        Comment


          #5
          Ok, had a late night last night, but g.Basket:ship_state is only going to be populated if you ALREADY put in an address (it's the saved database value). Scott's value is the correct one, but will only be available AFTER the customer selects something from the dropdown (which Miva does not see because part of the document, not the Miva render engine...unless you want to use the JSON api approach). So, you'll need to use jQuery or javascript to do this. Google something like "Display Text when a drop down item is selected" should get you some sample code.

          Bruce Golub
          Phosphor Media - "Your Success is our Business"

          Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
          phosphormedia.com

          Comment

          Working...
          X