Cart

This document is for a version of Craft Commerce that is no longer supported. Please refer to the latest version →

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 active carts (carts that have been updated in the last hour) and inactive carts (carts that are older than an hour that are 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. It’s likely you would only want to make this assignment once per page request, but more than once does not affect performance.

To get cart information within your templates look at the craft\commerce\elements\Order (opens new window) class reference.