wp-e-commerce / WP-e-Commerce

WP eCommerce - The most popular independent eCommerce platform for WordPress
https://wpecommerce.org
GNU General Public License v2.0
215 stars 216 forks source link

Zip code validation is only checking for non blank zip codes, not for valid #1274

Open JeffPyeBrook opened 10 years ago

JeffPyeBrook commented 10 years ago

See function _wpsc_have_valid_shippingzipcode

New shipping component should include a validate postal code method

leewillis77 commented 9 years ago

Strikes me as pretty hard (impractical?) to do in a way that works internationally.

Can we just go with a well placed filter of the return value from wpsc_have_valid_shipping_zipcode and let local devs implement validators for their chosen countries with plugins - would also support people who wanted to restrict shipping to only certain postal code regions / ranges?

JustinSainton commented 9 years ago

@leewillis77 Yep, I'd agree.

JeffPyeBrook commented 9 years ago

My thought was to include a very basic validation callback/filter in the component, that would leverage additional functionality within shipping plugins. That way each shipping plugin could add to the functionality for locations and methods it supports.

And you are correct in that it is complicated. Even in the US it is not as simple as validating against a list of known zip codes. For example, certain USPS shipping methods and options require the zip+4, so the meaning of what a valid zipcode is can change on the fly. And some zip codes are not eligible for some rates. You need to use the correct USPS address cleansing and rating functionality to get to the right answer.