Commerce extra - ZIP and State validation on backend

Hi everyone,

I’m using the Commerce extra and need to validate that the ZIP code and state match to prevent unnecessary calls to the TaxJar API.

I’ve already implemented this validation on the frontend using JavaScript, but I also need to validate it on the backend to ensure the form isn’t submitted and the API isn’t called if the data is invalid.

What’s the best way to handle this validation on the backend without interfering with future updates to the Commerce extra?

Thanks in advance for your guidance!

The best way to approach that would involve building a Commerce module that listens to the AddressValidation event. That has access to the address provided by the customer and the ability to mark specific fields as invalid and feed that information back into the checkout.

That sounds interesting, I’ll give it a try, thanks markh!