How/Where/Can I add more address model validations than just "firstName" and "lastName"...?

1 Answer 1


You can do either or both of:

  1. Use javascript validation on the front end (with e.g. parsley)

  2. Create a plugin with a method that is registered as a listener on this event: https://craftcommerce.com/docs/events-reference#commerce_addresses.onbeforesaveaddress

...and perform validation on the address model before it is saved. use $event->performAction = false; to stop the address actually being saved if need be.

General notes on how to listen to events and get at parameters is here.

Most likely, the best way will be to use a bit of both front end and back end validation here to make sure you're getting the data you want in the format you want in to your address fields.

(If you don't yet have a business logic plugin for your Commerce setup, then create one using either of two excellent options: Business Logic Plugin or via http://pluginfactory.io)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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