In Craft Commerce, is it possible to make the product variant weight a required field? In Craft Commerce, is it possible to make the product variant weight a required field?
We are using weight to calculate shipping so it would be good if we could make it a required field to ensure that the store admin doesn't forget to enter it.
Thanks
Yes you can, using the Model::EVENT_DEFINE_RULES Put this in your customer module or plugin.
        use craft\commerce\elements\Variant;
        use craft\base\Model;
       use craft\events\DefineRulesEvent;
        
        Event::on(
            Variant::class,
            Model::EVENT_DEFINE_RULES,
            function(DefineRulesEvent $event) {
                $rules = $event-&gt;rules;
                $rules[] = [['weight'], 'required'];
                $event-&gt;rules = $rules;
            }
        );