Craft CMS Asked by SirJay on November 30, 2020
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;
Event::on(
Address::class,
Model::EVENT_DEFINE_RULES,
function(DefineRulesEvent $event) {
$rules = $event->rules;
$rules[] = [['firstName', 'lastName'], 'required'];
$event->rules = $rules;
}
);
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP