address change not being triggered

njwfxnjwfx Member
I have used the code from:
https://wiki.foxycart.com/v/2.0/snippets/prevent_shipping_to_po_boxes

It works, so if you enter a PO Box as your address you get the popup message.

BUT if you then change the 'address1' line to a non PO box, but don't change the postcode then 'customer-address-change' doesn't seem to be triggered.

So then you're stuck with the message :
'Please enter your location information to display your shipping options.'

in the shipping section as it doesn't think it has a valid address.

Should FC.client.on('customer-address-change' , ) be triggered by a change to the 'fc-form-control--shipping-address1' field?

If not - how would you suggest I resolve the above scenario?

Thanks
Comments
  • fc_adamfc_adam FoxyCart Team
    @njwfx,

    Ah good question - I can see what you're describing there. We'll look into a better solution for that and follow up again soon.
  • fc_adamfc_adam FoxyCart Team
    @njwfx,

    Thanks for your patience. I believe we have a solution for you - and I've updated the wiki page with the new code. Give that a try and you should see both an alert earlier (when the customer enters the address 1 or 2), but also get the shipping rates if they've completed the address before correcting the address line 1/2.
  • njwfxnjwfx Member
    Thanks so much for the updated code. Definitely an improvement and at least now the checkout can proceed, however there are still some inconsistencies.

    On first entry to the checkout page (assuming no postcode has been entered prior), then completing address1 with a po box will pop up the message.

    Changing the po box to a street address does now force recalculation of the shipping so that is OK

    But if you change the address back to a po box, then although the shipping is recalculated, the message re the po box DOESN'T pop up (this is a less likely scenario so not a show-stopper)

    BUT if you enter the checkout page with the postcode pre-filled (as would happen if the postcode was entered on the side cart) then entering a po box in address1 DOESN'T trigger the pop up message.

    Obviously the message will be triggered on the submit button but this is more irritating for the client as they have then filled in the rest of their details, and may not want to proceed if no PO box allowed.

    Thanks for your help





  • fc_adamfc_adam FoxyCart Team
    @njwfx,

    Thanks for detailing the scenarios there. Based on what you're describing - I think I know what the issue was, and just made a quick change to the script on the wiki again. Could you try the latest version and see if it works as expected?
  • njwfxnjwfx Member
    Thanks, it works perfectly now
Sign In or Register to comment.