New Day: Fri 19 Aug 2022 05:12:59 PM CDT
The problem is if I want to prevent the user from continuing I have to instantiate the $error object which makes things touch because I have to communicate between JavaScript and php, which is tough. I attempted to use Cookies for the problem but that didn’t work. I am now trying to use a zip code archive on the locally hosted website, as an effort to increase speed, rather than relying on third-party API or even a local (REST) API.
This project is useful but it has the latitudes as well, I don’t want that, I just want the zip as they related to the states.
checkout.js:
https://github.com/woocommerce/woocommerce/blob/master/assets/js/frontend/checkout.js#L35
My current incarnation with the Mike with the thing that I’m using it doesn’t work well unless I use that grep thing. But somehow that works very well but mine doesn’t work well so I have to use that mere solution that I wrote about. But rather would seem to be a more useful tactic is to use checkout.JS. If that doesn’t work then I’ll be at options.
I’ll be referencing this article.
file_put_contents($log, $fields[ 'billing_state' ] ." == " . zipToState($fields[ 'billing_postcode' ]) . PHP_EOL, FILE_APPEND);
Logging Out: Sat 20 Aug 2022 03:22:14 AM CDT
New Day: Sun 21 Aug 2022 07:14:44 PM CDT
I have created the solution isset() method.
function ($zipcode)
{
/* 000 to 999 */
$zip_by_state = [
'--', '--', '--', '--', '--', 'NY', 'PR', 'PR', 'VI', 'PR', 'MA', 'MA', 'MA',
'MA', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA',
'MA', 'MA', 'RI', 'RI', 'NH', 'NH', 'NH', 'NH', 'NH', 'NH', 'NH', 'NH', 'NH',
'ME', 'ME', 'ME', 'ME', 'ME', 'ME', 'ME', 'ME', 'ME', 'ME', 'ME', 'VT', 'VT',
'VT', 'VT', 'VT', 'MA', 'VT', 'VT', 'VT', 'VT', 'CT', 'CT', 'CT', 'CT', 'CT',
'CT', 'CT', 'CT', 'CT', 'CT', 'NJ', 'NJ', 'NJ', 'NJ', 'NJ', 'NJ', 'NJ', 'NJ',
'NJ', 'NJ', 'NJ', 'NJ', 'NJ', 'NJ', 'NJ', 'NJ', 'NJ', 'NJ', 'NJ', 'NJ', 'AE',
'AE', 'AE', 'AE', 'AE', 'AE', 'AE', 'AE', 'AE', '--', 'NY', 'NY', 'NY', 'NY',
'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY',
'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY',
'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY',
'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'NY', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA',
'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA',
'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA',
'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', 'PA', '--', 'PA', 'PA',
'PA', 'PA', 'DE', 'DE', 'DE', 'DC', 'VA', 'DC', 'DC', 'DC', 'DC', 'MD', 'MD',
'MD', 'MD', 'MD', 'MD', 'MD', '--', 'MD', 'MD', 'MD', 'MD', 'MD', 'MD', 'VA',
'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA',
'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA', 'VA',
'WV', 'WV', 'WV', 'WV', 'WV', 'WV', 'WV', 'WV', 'WV', 'WV', 'WV', 'WV', 'WV',
'WV', 'WV', 'WV', 'WV', 'WV', 'WV', 'WV', 'WV', 'WV', '--', 'NC', 'NC', 'NC',
'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC', 'NC',
'NC', 'NC', 'NC', 'NC', 'SC', 'SC', 'SC', 'SC', 'SC', 'SC', 'SC', 'SC', 'SC',
'SC', 'GA', 'GA', 'GA', 'GA', 'GA', 'GA', 'GA', 'GA', 'GA', 'GA', 'GA', 'GA',
'GA', 'GA', 'GA', 'GA', 'GA', 'GA', 'GA', 'GA', 'FL', 'FL', 'FL', 'FL', 'FL',
'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL', 'FL',
'FL', 'FL', 'AA', 'FL', 'FL', '--', 'FL', '--', 'FL', 'FL', '--', 'FL', 'AL',
'AL', 'AL', '--', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'TN', 'TN', 'TN', 'TN', 'TN', 'TN', 'TN',
'TN', 'TN', 'TN', 'TN', 'TN', 'TN', 'TN', 'TN', 'TN', 'MS', 'MS', 'MS', 'MS',
'MS', 'MS', 'MS', 'MS', 'MS', 'MS', 'MS', 'MS', 'GA', '--', 'KY', 'KY', 'KY',
'KY', 'KY', 'KY', 'KY', 'KY', 'KY', 'KY', 'KY', 'KY', 'KY', 'KY', 'KY', 'KY',
'KY', 'KY', 'KY', '--', 'KY', 'KY', 'KY', 'KY', 'KY', 'KY', 'KY', 'KY', '--',
'--', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH',
'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH', 'OH',
'OH', 'OH', 'OH', 'OH', '--', 'IN', 'IN', 'IN', 'IN', 'IN', 'IN', 'IN', 'IN',
'IN', 'IN', 'IN', 'IN', 'IN', 'IN', 'IN', 'IN', 'IN', 'IN', 'IN', 'IN', 'MI',
'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'MI',
'MI', 'MI', 'MI', 'MI', 'MI', 'MI', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA',
'IA', 'IA', '--', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', '--', '--', '--',
'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', 'IA', '--', 'WI', 'WI', 'WI',
'--', 'WI', 'WI', '--', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI', 'WI',
'WI', 'WI', 'WI', 'WI', 'MN', 'MN', '--', 'MN', 'MN', 'MN', 'MN', 'MN', 'MN',
'MN', 'MN', 'MN', 'MN', 'MN', 'MN', 'MN', 'MN', 'MN', '--', 'DC', 'SD', 'SD',
'SD', 'SD', 'SD', 'SD', 'SD', 'SD', '--', '--', 'ND', 'ND', 'ND', 'ND', 'ND',
'ND', 'ND', 'ND', 'ND', '--', 'MT', 'MT', 'MT', 'MT', 'MT', 'MT', 'MT', 'MT',
'MT', 'MT', 'IL', 'IL', 'IL', 'IL', 'IL', 'IL', 'IL', 'IL', 'IL', 'IL', 'IL',
'IL', 'IL', 'IL', 'IL', 'IL', 'IL', 'IL', 'IL', 'IL', 'IL', '--', 'IL', 'IL',
'IL', 'IL', 'IL', 'IL', 'IL', 'IL', 'MO', 'MO', '--', 'MO', 'MO', 'MO', 'MO',
'MO', 'MO', 'MO', 'MO', 'MO', '--', '--', 'MO', 'MO', 'MO', 'MO', 'MO', '--',
'MO', 'MO', 'MO', 'MO', 'MO', 'MO', 'MO', 'MO', 'MO', '--', 'KS', 'KS', 'KS',
'--', 'KS', 'KS', 'KS', 'KS', 'KS', 'KS', 'KS', 'KS', 'KS', 'KS', 'KS', 'KS',
'KS', 'KS', 'KS', 'KS', 'NE', 'NE', '--', 'NE', 'NE', 'NE', 'NE', 'NE', 'NE',
'NE', 'NE', 'NE', 'NE', 'NE', '--', '--', '--', '--', '--', '--', 'LA', 'LA',
'--', 'LA', 'LA', 'LA', 'LA', 'LA', 'LA', '--', 'LA', 'LA', 'LA', 'LA', 'LA',
'--', 'AR', 'AR', 'AR', 'AR', 'AR', 'AR', 'AR', 'AR', 'AR', 'AR', 'AR', 'AR',
'AR', 'AR', 'OK', 'OK', '--', 'TX', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK',
'OK', '--', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'TX', 'TX', 'TX', 'TX',
'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX',
'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX',
'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX',
'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'TX', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO',
'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', 'CO', '--', '--',
'--', 'WY', 'WY', 'WY', 'WY', 'WY', 'WY', 'WY', 'WY', 'WY', 'WY', 'WY', 'WY',
'ID', 'ID', 'ID', 'ID', 'ID', 'ID', 'ID', '--', 'UT', 'UT', '--', 'UT', 'UT',
'UT', 'UT', 'UT', '--', '--', 'AZ', 'AZ', 'AZ', 'AZ', '--', 'AZ', 'AZ', 'AZ',
'--', 'AZ', 'AZ', '--', '--', 'AZ', 'AZ', 'AZ', '--', '--', '--', '--', 'NM',
'NM', '--', 'NM', 'NM', 'NM', '--', 'NM', 'NM', 'NM', 'NM', 'NM', 'NM', 'NM',
'NM', 'NM', '--', '--', '--', '--', 'NV', 'NV', '--', 'NV', 'NV', 'NV', '--',
'NV', 'NV', '--', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', '--',
'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA',
'CA', 'CA', 'CA', 'CA', 'CA', 'CA', '--', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA',
'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA',
'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA', 'CA',
'AP', 'AP', 'AP', 'AP', 'AP', 'HI', 'HI', 'GU', 'OR', 'OR', 'OR', 'OR', 'OR',
'OR', 'OR', 'OR', 'OR', 'OR', 'WA', 'WA', 'WA', 'WA', 'WA', 'WA', 'WA', '--',
'WA', 'WA', 'WA', 'WA', 'WA', 'WA', 'WA', 'AK', 'AK', 'AK', 'AK', 'AK'
];
$prefix = substr($zipcode, 0, 3);
$index = intval($prefix); /* converts prefix to integer */
return $zip_by_state[$index];
}
add_action( 'woocommerce_after_checkout_validation', 'testing_isset_validation' );
function testing_isset_validation() {
if ( $fields[ 'billing_state' ] == zipToState($fields[ 'billing_postcode' ]) ) {
wc_clear_notices();
}
if (isset($_POST['billing_postcode'])) {
if ( $_POST[ 'billing_state' ] != zipToState( $_POST[ 'billing_postcode' ] )) {
wc_add_notice( __( '<strong>Please correct the zip code area for billing.</strong>.', 'voice-verify' ), 'error' );
}
}
if (isset($_POST['shipping_postcode'])) {
if ( $_POST[ 'shipping_state' ] != zipToState( $_POST[ 'shipping_postcode' ] )) {
wc_add_notice( __( '<strong>Please correct the zip code area for shipping.</strong>.', 'voice-verify' ), 'error' );
}
}
}
Change billing_state, shipping_state to fit the project if applicable.
Logging out: Sun 21 Aug 2022 07:40:08 PM CDT
28 responses to “Documenting: Creating A Zip Code Validator for WordPress”
… [Trackback]
[…] Informations on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Find More here on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] There you can find 82801 additional Info on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Find More on to that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Find More on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Read More here to that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Read More on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Read More on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Read More on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Find More Information here to that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Read More on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Find More Information here on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Information on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Here you can find 81363 additional Info on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Read More Info here to that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Find More Information here on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Read More Information here to that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Find More Information here on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Here you can find 29249 additional Info on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Information to that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Find More Info here on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Information on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Here you can find 92968 more Info to that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Information on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Read More on to that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Find More to that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Find More on on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]
… [Trackback]
[…] Find More on that Topic: montelogic.com/2022/08/22/documenting-creating-a-zip-code-validator-for-wordpress/ […]