When using EVENT_DEFINE_RULES in module adding items to cart fails as address validation is run.

Should address validation only happen when address fields are present in the post data to 'commerce/cart/update-cart' or when progressing to payment as it is normal practice for users to add items to cart before submitting a shipping address.

module function;

            function(DefineRulesEvent $event) {
                $rules = $event->rules;
                $rules[] = [['firstName', 'lastName'], 'required'];
                $event->rules = $rules;

enter image description here

Your Answer

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

Browse other questions tagged or ask your own question.