> For the complete documentation index, see [llms.txt](https://docs.growlytics.in/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.growlytics.in/integration/browser/syncing-cart-items.md).

# Syncing Cart Items

With Growlytics browser SDK, you can sync customer's cart items and use it to personalize campaign messages like showing abandoned cart items or showing total cart amount etc.

Once cart items synced using Browser SDK, you can use those cart details inside Email, SMS, WhatsApp, and other campaigns.

![Cart Email Preview](/files/-M_TrcXtRVGlQfTeSnRh)

## Sync Cart

To sync cart you can use`Growlytics.cart.sync()` method. This method excepts very specific input parameters that you will need to follow.

```javascript
// Sync Cart with Growlytics
Growlytics.cart.sync({
    id: '---cart id of your system goes here--',
    amount: 123,    // Total cart amount goes here,
    url: 'https://myapp.com/checkout/123324',    // Abandoned Cart URL
    items:[         // List of cart items
        {
            id: '--product id goes here--',
            name: '--product name goes here--',
            variant: '--product variant name goes here--',
            image: '--product goes here--',
            price: '--product price goes here',
            originalPrice: '--product original price - to show discount in emails',
            quantity: 2, // Number of products in cart
            notes: '--notes to show with cart items in email--'
        }
    ]
})
```

{% hint style="warning" %}
The input of the `sync()` method should exactly match with the structure mentioned above. Cart sync will fail otherwise.
{% endhint %}

### Cart Object

| Input Parameter | Required? | Type    | Description                                                                |
| --------------- | --------- | ------- | -------------------------------------------------------------------------- |
| id              | Yes       | String  | Cart id that you manage in your system.                                    |
| amout           | Yes       | Decimal | Total Cart Amount                                                          |
| items           | Yes       | Array   | List of all cart items.                                                    |
| url             | Yes       | String  | Abandoned cart URL, to be mentioned on email, SMS, and WhatsApp campaigns. |

### Cart Item Object

| Input Parameter | Required? | Type    | Description                      |
| --------------- | --------- | ------- | -------------------------------- |
| id              | Yes       | String  | Id of the product added in cart. |
| name            | Yes       | String  | Product Name                     |
| variant         | Optional  | String  | Product variant name             |
| image           | Yes       | String  | Product Image Url                |
| price           | Yes       | Decimal | Product Price                    |
| quantity        | Yes       | Number  | Product quantity in cart.        |

## Clear Cart

Once the purchase is made or cart items has expiry, its important to clear cart items from Growlytics. To clear cart use following sdk method.

```js
Growlytics.cart.clear();
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.growlytics.in/integration/browser/syncing-cart-items.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
