https://github.com/vedranbe/woocommerce-shipping-postal-codes
Generate Press child theme for validation of shipping zip codes in Woocommerce.
https://github.com/vedranbe/woocommerce-shipping-postal-codes
woocommerce wordpress
Last synced: 2 months ago
JSON representation
Generate Press child theme for validation of shipping zip codes in Woocommerce.
- Host: GitHub
- URL: https://github.com/vedranbe/woocommerce-shipping-postal-codes
- Owner: vedranbe
- License: gpl-3.0
- Created: 2024-03-13T21:58:08.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-19T16:41:41.000Z (almost 2 years ago)
- Last Synced: 2025-02-11T18:14:43.763Z (over 1 year ago)
- Topics: woocommerce, wordpress
- Language: JavaScript
- Homepage:
- Size: 60.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Woocommerce Shipping Postal Codes Validation
## Generate Press Child Theme
This repository implements a concise shipping ZIP code validation for WooCommerce, exclusively affecting the checkout process while leaving billing codes unaffected. This was made using VS Code and Local by Flywheel (WP Engine). Products where imported from here: https://github.com/woocommerce/woocommerce/tree/master/sample-data
## Backend Configuration
To manage shipping postal codes, navigate to the WooCommerce menu under "Shipping Postal Codes" in the backend.
- Only numeric codes with precisely 5 digits are accepted.
- Multiple codes should be comma-separated.
- No duplicates are allowed.
- The validation restricts entry of codes that do not adhere to these rules.
## Frontend Implementation
The code validation is integrated into the Checkout page:
- **Trigger:** Validation activates upon entering 5 numeric digits in the designated field.
- **Comparison:** The input value is compared against the `vb_valid_postal_codes` value stored in the `wp_options` table.
- **Hidden Field:** An invisible DOM element (``) is dynamically added.
- **Form Behavior:** If the hidden field value is 0, the form submission is allowed; if 1, the form is disabled.
- **Invalid Codes:** In case of an invalid code, the submit button is disabled and an error message is displayed.