<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>

CC BY-SA 4.0
2019-12-13T23:22:52.020Z
2019-12-13T23:22:52.020Z
nfourtythree
<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>

<plugin-craftcommerce2>
Mandatory order fields in Craft Commerce 2
# 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.
 false
];


---

