Updating Multiship jQuery Code

sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
in Bugs & Feature Requests edited June 2011

I've run across a couple problems on the jQuery code for Multiship and have corrected these in the sample code in the wiki (and updated code version to 2.2)

Issue 1: Clear out the field that holds the new name so it's fresh the next time you want to add a new recipient.

Issue 2: If you are using hmac verification, jQuery('input[name="shipto"] won't pick up the shipto field. It needs to be: jQuery('input[name^="shipto"] which means "field name starts with shipto". This seems to work better on my multiship integrations.

Issue 3: Really a sub-issue of 2, I was getting a lot of 'undefined' values set in my cookies so I trapped for that as a non-displayer along with 'null' and ''. Also, don't show divider option if there aren't any valid shipto options.

The only thing I wanted to check on with those who know better, is that I took out some jQuery('input[name$="shipto"] (which means "shipto" at end of name) in favor of the more open-ended ~="shipto" because in hmac verification, the field name won't end in "shipto" any more. If you just wanted to get the 2:shipto and 3:shipto, it could be name~=":shipto" but I'm not sure if that's really necessary.

2.2 posted. Thoughts?
  • brettbrett FoxyCart Team
    I reviewed the changes on the wiki, but can you clarify issue 1?

    Issue 2: Nice catch.
    Issue 3: Nice.

    Thanks for improving that. Greatly appreciated, as always ;)
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    Oh sure... issue 1: If I type in "Herbert" as a new recipient and add to cart, all is fine. If I click Continue Shopping and go back to the page and would like to order another widget for my friend Maude, I click on the dropdown, select "Add New Recipient" and "Herbert" is still in the box where I would like to enter Maude. I just thought it should be cleared out.
  • brettbrett FoxyCart Team
    Ah, gotcha. That's probably more a browser specific thing, related to how browser cache form input and keep it there on a "soft" reload. Nice improvement. Makes sense.
  • lukeluke FoxyCart Team
    @Sparkweb thanks for improving this for the rest of the FoxyCart community!
Sign In or Register to comment.