Download the PHP package mage2kishan/module-zipcode-validation without Composer

On this page you can find all versions of the php package mage2kishan/module-zipcode-validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package module-zipcode-validation

Magento 2 Zipcode Validation

Panth ZipcodeValidation checks the postal code a customer types into a Magento 2 address form against a table of ZIP/PIN code ranges stored in the database. The check runs as an AJAX request while the customer is still on the form: the checkout postcode field (through a RequireJS mixin on the standard Magento_Ui/js/form/element/post-code component) and any other storefront form with a postcode field (through a script loaded on every frontend page) send the code, country and region to the module's controller, and the field shows an inline error or a confirmation with the matched state/region name.

Ranges are managed in a dedicated admin grid and form and can be exported as JSON. The module ships a data patch that pre-loads ranges for India, the United States, the United Kingdom, Canada, Australia, Germany, France, Italy, Spain and the Netherlands. It is aimed at merchants who deliver only to defined postal areas and want customers to see a problem with their postcode before an order is placed. The storefront code is written for the Luma theme and themes based on it (RequireJS, jQuery and Magento UI components). On Hyva themes the page script block is removed by view/frontend/layout/hyva_default.xml, so no inline storefront validation runs there; the endpoint, the helper and the optional server-side enforcement still work.

Product page: kishansavaliya.com/magento-2-zipcode-validation.html

Features

Compatibility

Requirement Supported versions
Magento Open Source 2.4.4, 2.4.5, 2.4.6, 2.4.7, 2.4.8
Adobe Commerce 2.4.4, 2.4.5, 2.4.6, 2.4.7, 2.4.8
PHP 8.1, 8.2, 8.3, 8.4 (~8.1.0||~8.2.0||~8.3.0||~8.4.0)
Themes Luma and Luma-based themes (RequireJS / Magento UI checkout)

Composer constraints from composer.json: magento/framework ^103.0, magento/module-backend ^102.0, magento/module-config ^101.2, magento/module-store ^101.1, magento/module-directory ^100.4, magento/module-customer ^103.0, magento/module-checkout ^100.4, magento/module-quote ^101.2, magento/module-ui ^101.2.

Requirements

Installation

setup:di:compile is only needed when the store runs in production mode. setup:static-content:deploy is needed because the module ships JavaScript under view/frontend/web. setup:upgrade creates the panth_zipcode_range table and runs the data patch that pre-loads the ranges.

Check that the module is enabled:

Configuration

The configuration section is at Stores > Configuration > Panth Extensions > "Zipcode Validation" (section id zipcode_validation, also reachable from the "Zipcode Validation" > "Configuration" admin menu entry). All fields can be set at default, website and store view scope.

General Settings

Setting Default What it does
"Enable Zipcode Validation" Yes Yes/No select, read at store view scope. When No, the page script block is not rendered, the checkout mixin does nothing, the endpoint answers every request with {"valid": true, "message": ""} and no server-side enforcement runs.
"Enforce on Shipping Information and Order Placement" No When Yes, the server rejects saving shipping information and placing an order (storefront, REST and GraphQL) if the shipping postcode is outside the active ranges of its country. See "Server-side enforcement" below before enabling it. Path zipcode_validation/general/enforce_on_order.
"Validate on Checkout" Yes Runs the inline check on checkout (checkout_* and multishipping_* pages, including the cart shipping estimate and the checkout postcode mixin).
"Validate on Customer Account" Yes Runs the inline check on the customer address add/edit pages (customer_address_form, customer_address_new, customer_address_edit).
"Validate on Registration" Yes Runs the inline check on customer_account_create. Other pages with a postcode field are always checked while the module is enabled.
"Error Message" We couldn't verify this postal code. Please double-check and try again. Message returned when a code is outside every active range of its country (endpoint and enforcement). The India format and region mismatch messages are built in.
"Show Success Message" Yes When No, a valid code only clears the error; no confirmation is shown.
"Success Message Format" Valid postal code for {state} Confirmation text; {state} is replaced with the matched state name. Used by the page script and the checkout mixin.

Display Settings

Setting Default What it does
"Success Message Color" #007a33 Colour of the confirmation added by the page script (account, registration and other non-checkout forms). Must be a hex colour (#rgb, #rrggbb or #rrggbbaa); other values fall back to the default.
"Error Message Color" #e02b27 Colour of the error added by the page script, same rules. The checkout mixin uses the theme's field error styling.

Abuse Protection

Setting Default What it does
"Requests per Window" 60 Maximum check requests one client IP address may send to zipcodevalidation/validate/pincode per window. Further requests get HTTP 429 with {"valid": true, "rate_limited": true} and are not validated; the storefront scripts ignore that answer. 0 disables the limit.
"Window Length (seconds)" 300 Length of the fixed rate limit window.

Counters are kept in the Magento cache. The client IP is read with Magento\Framework\HTTP\PhpEnvironment\RemoteAddress, so behind a proxy or load balancer configure the trusted forwarded-for headers in app/etc/env.php; otherwise all visitors share the proxy's address.

ZIP/PIN Code Ranges

This group has no fields. Its comment points to the "Manage Ranges" grid, which is where the ranges are maintained. Ranges are global: the panth_zipcode_range table has no website or store view column, so the same ranges apply to every store view.

Config paths: zipcode_validation/general/enabled, zipcode_validation/general/enforce_on_order, zipcode_validation/general/validate_on_checkout, zipcode_validation/general/validate_on_account, zipcode_validation/general/validate_on_registration, zipcode_validation/general/error_message, zipcode_validation/general/show_success_message, zipcode_validation/general/success_message_format, zipcode_validation/display/success_color, zipcode_validation/display/error_color, zipcode_validation/security/rate_limit, zipcode_validation/security/rate_limit_window.

Managing ranges

Open "Zipcode Validation" > "Manage Ranges" in the admin menu (route zipcodevalidation/range/index, page title "Manage ZIP/PIN Code Ranges"). The grid lists the rows of the panth_zipcode_range table with the columns "ID", "Country", "State Code", "State/Region Name", "ZIP/PIN Start", "ZIP/PIN End", "Active" and "Created", plus an "Actions" column with "Edit" and "Delete".

Import format: POST a JSON array with the same keys as the export file to zipcodevalidation/range/import (admin route, requires the admin form key and the Panth_ZipcodeValidation::config ACL resource). country_id (two letters), state_name (up to 255 characters), zip_start and zip_end (up to 20 characters each) are required per row; state_code (up to 10 characters) defaults to an empty string and is_active to 1. Rows that break these rules are skipped and reported. The response is {"success": true, "message": "Successfully imported N range(s). ...", "imported": N}; the message lists up to five row errors. There is no button for this endpoint in the grid in this release.

Usage

Where the check runs

Server-side enforcement

With zipcode_validation/general/enforce_on_order = 1 (and the module enabled for the store view):

Enable it only after the ranges cover every postcode you deliver to: a missing range blocks checkout for that area.

AJAX endpoint

POST (or GET) /zipcodevalidation/validate/pincode with pincode, country_id (defaults to IN when empty) and optional region_id (numeric Magento region id or a region code, up to 20 letters, digits, spaces, _ or -; any other value is ignored). The response is JSON and is sent with Cache-Control: max-age=0, must-revalidate, no-cache, no-store:

How codes are matched

Non-alphanumeric characters (including spaces and hyphens) are stripped from the code and from both bounds, and the code is upper-cased. Only rows with is_active = 1 for the requested country_id are loaded (once per request and cached in memory). If the code is longer than the longer of the two bounds, only that many leading characters are compared. If the code, zip_start and zip_end are all digits, the comparison is start <= code <= end as integers; otherwise it is a case-insensitive natural-order comparison (strnatcasecmp) against both bounds. For GB, when both bounds have at most four characters and the code is a full postcode, the last three characters (the inward code) are removed before the comparison. Ranges are global: they have no website or store view scope. A code may fall in several ranges; the first match supplies the state name, and the region check passes if any matching range has the selected region's code.

Pre-loaded data

Setup/Patch/Data/AddGlobalZipcodeRanges.php inserts 83 rows into panth_zipcode_range during setup:upgrade, but only if the table is empty at that moment. All rows are active and can be edited or deleted in the grid. A second patch, AddIndianPincodeRanges.php, writes 37 Indian ranges to the config path zipcode_validation/pincode_ranges/custom_ranges in core_config_data; this value is not used by the validator and no admin screen reads it since 1.1.0.

Templates and assets that can be overridden

Developer Notes

Uninstallation

The module has no uninstall script. The panth_zipcode_range table and its rows, the zipcode_validation/* values in core_config_data (including zipcode_validation/pincode_ranges/custom_ranges) and the two data patch entries in patch_list remain after removal and have to be dropped manually if no longer wanted. Remove Panth_Core only if no other Panth module depends on it.

Support

Documentation

USER_GUIDE.md is the administrator guide. It covers installation, checking that the module is active, configuration, adding, editing and deleting ranges in the admin grid, JSON import and export, how validation behaves on the storefront, and troubleshooting.

License

Commercial software license. See LICENSE.txt in this repository.

Changelog

See CHANGELOG.md.

Links


All versions of module-zipcode-validation with dependencies

PHP Build Version
Package Version
Requires php Version ~8.1.0||~8.2.0||~8.3.0||~8.4.0
magento/framework Version ^103.0
magento/module-backend Version ^102.0
magento/module-config Version ^101.2
magento/module-store Version ^101.1
magento/module-directory Version ^100.4
magento/module-customer Version ^103.0
magento/module-checkout Version ^100.4
magento/module-quote Version ^101.2
magento/module-ui Version ^101.2
mage2kishan/module-core Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mage2kishan/module-zipcode-validation contains the following files

Loading the files please wait ...