An empty order is an Order
containing no CommerceItems
(an empty shopping cart). When the ShoppingCart
’s current Order
is first fetched, the system tries to find an existing order. If it fails to find one, it creates a new empty transient order. If the persistOrders
property of the ShoppingCart
component is set to true, the order is persisted. In some cases, for example if a site typically handles many anonymous visitors, it may not be desirable to persist all empty orders to the database.
To prevent empty orders from being persisted, set the persistEmptyOrders
property of the ShoppingCart
component to false. It is possible to turn off empty order persistence for anonymous visitors only (a common requirement), or for logged-in visitors only (less common). To do so, set the persistOrdersForAnonymousUsers
and persistEmptyOrders
properties as appropriate.
Persistence Settings | Effect |
---|---|
| All orders, empty and non-empty, are persisted for all visitors. |
| No orders are persisted for anonymous visitors. Only orders containing at least one item are persisted for logged-in visitors. |
| Only orders containing at least one item are persisted for all visitors. |
| No orders are persisted for anonymous visitors. All orders, empty and non-empty, are persisted for logged-in visitors. |