1

I want to verify if the zip code entered by the customer matches correctly with the region.

For example:

zip code:10001

Region: New york

If the customer enters the wrong zip code for the region, it throws an error "your zipcode and region need to match"

I think I need to use the USPS API.

I created an account in USPS API.

How to implement this functionality in the checkout page and my account save address page.

I followed this below link. But It doesn't work for me.

https://www.w3solver.com/magento-2-address-verification-using-usps-api-on-checkout/

Any help, experience and knowledge sharing would be appreciated

1
  • This is module is not good for your requirement
    – Amit Bera
    Jul 25, 2019 at 18:52

1 Answer 1

2

You have put the postcode/Region checking at

\Magento\Quote\Model\ShippingMethodManagement::estimateByExtendedAddress \Magento\Quote\Model\ShippingMethodManagement::estimateByAddressId

because of these functions, the shipping methods are rendered at the checkout page.

Note that, Magento 2 does not save the Shipping address till database 's quote until select the Shipping method .

So, the above two methods is best way to checking ZipCode/region at checkout.

3
  • It is working fine. Jul 29, 2019 at 11:54
  • How to show pop error message and stop to redirect to checkout page from cart page Jul 29, 2019 at 11:55
  • If you want to show this message at pop then you have work more and logic will different from current.
    – Amit Bera
    Jul 29, 2019 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.