Body: <p>I want to make a craft commerce custom order field required (server side). I already use this for require the default address fields. But how to add custom fields? Because this is done on the Address class.</p>
  <pre><code>        /**
           * Server require custom order fields
           */
          Event::on(
            Address::class,
            Model::EVENT_DEFINE_RULES,
            function(DefineRulesEvent $event) {
                $rules = $event-&gt;rules;
                $rules[] = [['firstName', 'lastName'], 'required'];
                $rules[] = ['field:fieldHandle', 'required']; // &lt;- this is not working
                $event-&gt;rules = $rules;
            }
          );
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-01-25T12:09:29.527Z
Comments.Text: I'm surprised that the update cart method in Commerce doesn't seem to respect the required lightswitch of an order field. This seems like a bug to me - I don't think you should have to use a custom module to do it.
Comments.UserDisplayName: James Smith
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-01-26T14:09:21.960Z
Comments.Text: But is it possible with some kind of event? I tried making the field required but that's not working. I also think this should work but because it doesn't I'm looking for an alternative also because I work with a onepagecheckout with ajax calls
Comments.UserDisplayName: Maarten Heideman
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-01-26T14:13:33.490Z
Comments.Text: I'm not sure, but I'd probably raise this as a bug report with Craft Commerce, as it doesn't seem right that you are able to mark an order field as "required" but that choice is not respected.
Comments.UserDisplayName: James Smith
Tags: <craft3><plugin-craftcommerce><custom-field><required>
Title: How make custom order fields required with "event_define_rules" like a required address fields?
ThreadText: # How make custom order fields required with "event_define_rules" like a required address fields?
  
  (Asked by: username_0 on 2023-01-24)
  
  I want to make a craft commerce custom order field required (server side). I already use this for require the default address fields. But how to add custom fields? Because this is done on the Address class.
  
  ```
          /**
           * Server require custom order fields
           */
          Event::on(
            Address::class,
            Model::EVENT_DEFINE_RULES,
            function(DefineRulesEvent $event) {
                $rules = $event->rules;
                $rules[] = [['firstName', 'lastName'], 'required'];
                $rules[] = ['field:fieldHandle', 'required']; // <- this is not working
                $event->rules = $rules;
            }
          );
  
  ```
  
  **Tags:** craft3, plugin-craftcommerce, custom-field, required
  
  > **Comments:**
  > **username_1**: I'm surprised that the update cart method in Commerce doesn't seem to respect the required lightswitch of an order field. This seems like a bug to me - I don't think you should have to use a custom module to do it.  
  > **username_0**: But is it possible with some kind of event? I tried making the field required but that's not working. I also think this should work but because it doesn't I'm looking for an alternative also because I work with a onepagecheckout with ajax calls  
  > **username_1**: I'm not sure, but I'd probably raise this as a bug report with Craft Commerce, as it doesn't seem right that you are able to mark an order field as "required" but that choice is not respected.  
  
  ---
  
  ## 0 answers
  
  