Was wondering how to do this in Commerce 3 as there were a few different older methods discussed here.


According to Luke, this is the preferred method for Commerce 3.

In a custom module or plugin:

Event::on(\craft\commerce\models\Address::class, \craft\base\Model::EVENT_DEFINE_RULES, static function(\craft\events\DefineRulesEvent $event) {
    $rules = $event->rules;
    $rules[] = [['firstName','lastName'], 'required'];
    $event->rules = $rules;

Some more details about what kind of rules you can add here, if you want something more complex than a list of required fields: https://www.yiiframework.com/doc/guide/2.0/en/tutorial-core-validators


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.