Answers.Body: <p>There is a setting for this specific instance <code>allowEmptyCartOnCheckout</code>.</p>
  
  <p>Creating a <code>commerce.php</code> file in the <code>config</code> directory with the following code will prevent customers from checkout out with an empty cart.</p>
  
  <pre><code>&lt;?php
  
  return [
    'allowEmptyCartOnCheckout' =&gt; false
  ];
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-13T23:22:52.020Z
Answers.LastActivityDate: 2019-12-13T23:22:52.020Z
Answers.UserDisplayName: nfourtythree
Body: <p>Ist it possible to add validation rules for Carts/Orders? I need to check whether there is at least one list item added to the cart before payment is initiated.</p>
  
  <p>Unlike addresses (<em>Address::EVENT_REGISTER_ADDRESS_VALIDATION_RULES</em>) there seems not to be an event for manipulating rules.</p>
  
  <p>I’d prefer a server-side solution.</p>
  
Tags: <plugin-craftcommerce2>
Title: Mandatory order fields in Craft Commerce 2
ThreadText: # Mandatory order fields in Craft Commerce 2
  
  (Asked by: username_0 on 2019-12-13)
  
  Ist it possible to add validation rules for Carts/Orders? I need to check whether there is at least one list item added to the cart before payment is initiated.
  
  Unlike addresses (*Address::EVENT\_REGISTER\_ADDRESS\_VALIDATION\_RULES*) there seems not to be an event for manipulating rules.
  
  I’d prefer a server-side solution.
  
  **Tags:** plugin-craftcommerce2
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-12-13. Score: 1 | Accepted answer
  
  There is a setting for this specific instance `allowEmptyCartOnCheckout`.
  
  Creating a `commerce.php` file in the `config` directory with the following code will prevent customers from checkout out with an empty cart.
  
  ```
  <?php
  
  return [
    'allowEmptyCartOnCheckout' => false
  ];
  
  ```
  
  
  ---
  
  