# Carts

Here you can find an overview of the Emporix carts concept, along with its features and benefits.

{% hint style="info" %}

* Looking for code tutorials? Check out the [Cart Service guide](/api-references/api-guides/checkout/cart/cart.md).
* Looking for API reference? Check out the [Cart Service](/api-references/api-guides/checkout/cart.md) in the Emporix API Reference.
  {% endhint %}

## Purpose

Carts allow your customers to compile a list of items for purchase. The Emporix carts concept aims to simplify cart management by introducing features such as cart merging or automatic deleting of inactive carts.

## Features

The Emporix carts concept introduces a set of features that make cart management easier:

| Feature                          | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Anonymous and customer carts** | <p>The Emporix e-commerce system distinguishes two types of carts:</p><ul><li>Anonymous carts for customers who are browsing the store without logging in.</li><li>Customer carts for logged-in customers.</li></ul>                                                                                                                                                                                                                                                                                                                    |
| **Cart merging**                 | <p>You can merge a customer's anonymous cart with their customer cart to preserve the shopping flow.</p><p><span data-gb-custom-inline data-tag="emoji" data-code="2139">ℹ️</span> <mark style="background-color:blue;">See:</mark> <a href="#cart-merging"><mark style="background-color:blue;">Cart merging</mark></a><mark style="background-color:blue;">.</mark></p>                                                                                                                                                               |
| **Inactivity time**              | If a cart is inactive for over 30 consecutive days, it is automatically deleted from the database.                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| **Statuses**                     | <p>A cart can either be active (<code>OPEN</code>) or inactive (<code>CLOSED</code>). A cart's status is automatically set to <code>CLOSED</code> in the following cases:</p><ul><li>The cart belonged to an anonymous customer, and it was merged with a logged-in customer's cart.</li><li>The cart went through the checkout process.</li></ul><p><span data-gb-custom-inline data-tag="emoji" data-code="26a0">⚠️</span> <mark style="background-color:red;">You can only perform operations on <code>OPEN</code> carts.</mark></p> |

## Overview

The following section provides more information on cart management features in the Emporix e-commerce system.

### Cart merging

Sometimes a customer will browse products and add them to the cart before logging in. In such a case, you can merge their anonymous cart with their customer cart to preserve the shopping flow.

Once the carts are merged, the anonymous cart's status is set to `CLOSED`.

You can use the merging functionality to perform the following actions:

* Merge an anonymous cart with a customer cart.
* Merge multiple anonymous carts with a customer cart.

{% hint style="danger" %}
You cannot use the merging functionality to perform the following actions:

* Merge a customer cart with an anonymous cart.
* Merge a customer cart with another customer cart.
* Merge two non-empty carts that use different currencies.
  {% endhint %}

Common conflicts that may occur while merging carts are described in the table below.

| Conflict                                                                                              | Approach of the merging functionality                                                                                                                                                                                                                                                  |
| ----------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Both carts contain the same items.                                                                    | The quantities of the items are added together.                                                                                                                                                                                                                                        |
| The same item is added to both carts, but one is added as an `itemYrn` and one as a `Product` object. | The item is treated as two separate entries. The quantities of the item are not added together.                                                                                                                                                                                        |
| The carts use different currencies. Both carts are empty.                                             | The currency of the customer cart is preserved.                                                                                                                                                                                                                                        |
| The anonymous cart includes items that are out of stock.                                              | <p>The items are preserved.</p><p><span data-gb-custom-inline data-tag="emoji" data-code="26a0">⚠️</span> <mark style="background-color:yellow;">If a customer proceeds to checkout, an error message appears, prompting the customer to remove said items from their cart.</mark></p> |
| The carts use different custom attributes.                                                            | The custom attributes are consolidated.                                                                                                                                                                                                                                                |
| The carts use the same custom attributes, but their values are different.                             | The anonymous cart's custom attribute values are preserved.                                                                                                                                                                                                                            |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.emporix.io/ce/core-commerce/carts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
