Cart

A cart is an order that has not yet been completed. A customer can edit the contents of a cart, but once the cart becomes an order it is no longer editable by the customer.

You can view all carts on the Orders index page. You can also only view only active carts (carts that have been updated in the last 24 hours) and inactive carts (carts that are older than 24 hours and likely to be abandoned).

You can set the system to purge (delete) abandoned carts after a given time period in your config, the default of which is 3 months.

In your templates, you can get the current user’s cart with craft.commerce.carts.cart.

{% set cart = craft.commerce.carts.cart %}

The above code will generate a new cart in the session if none exists. Its likely you would only want to make this assignment once per page request, but more than once does not affect performance.

To see how to use the cart in templates look at the craft\commerce\elements\Order class reference.