Blog posts of '2014' 'October'

RSS
If customer enters an invalid zip code, they only see "In-Store Pickup"- Thursday, October 16, 2014

I was asked ...

Today, I had a customer who had a customer call saying that the only shipping option they were seeing was In-Store pickup. After a little debugging, they figured out that she was inputting an invalid Zip code and so it was just showing in-store pickup.

My question is this:
Can an expression be written that will catch the invalid zip code error returned from USPS and print a message to the screen saying "Sorry,  it appears you've input an invalid zip code, so USPS was unable to calculate rates for their services. Please go back and correct the error."

NopCommerce has the option such that it will "return valid options if there are any".  So, first, set that option to False

Admin > Configuration > Settings > All Settings >> column filter the Name column for

shippingsettings.returnvalidoptionsifthereareany

Edit, set to False, and Update

The customer will then get this error message when an invalid zip code is entered.
  • USPS Error returned: Error Desc: Please enter a valid ZIP Code for the recipient. USPS Help Context: .

(Note, that the USPS plugin only sends 5 digit zip to USPS)

However, if you want to do some up front validations (and return friendlier error messages), then you can use ErrorExit in Shipping Director:  Read these other blogs about validations



You can download sample validations that you can then import into Shipping Director (do NOT select Delete option).  They have large order line numbers, so they will append to the end of your config.  You should renumber the ones you like with low order line numbers, so that they appear before any Option lines, and delete the ones you don't need.

The zip validations just check the formats.  They don't ensure that they are actual zip codes.  Only the USPS would do that.
I've been considering writing a plugin for full address validation using smartystreets, but there does not appear to be a demand (at least I don't see any forum posts asking for it).  If interested, let me know :)
Tags :  Validate
Comments (1)