Syncing Cart Items
This article will help you to sync your customer's cart items with Growlytics.
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

Syncing Cart

To sync cart you can useGrowlytics.cart.sync() method. This method excepts very specific input parameters that you will need to follow.
1
// Sync Cart with Growlytics
2
Growlytics.cart.sync({
3
id: '---cart id of your system goes here--',
4
amount: 123, // Total cart amount goes here,
5
url: 'https://myapp.com/checkout/123324', // Abandoned Cart URL
6
items:[ // List of cart items
7
{
8
id: '--product id goes here--',
9
name: '--product name goes here--',
10
variant: '--product variant name goes here--',
11
image: '--product goes here--',
12
price: '--product price goes here',
13
originalPrice: '--product original price - to show discount in emails',
14
quantity: 2, // Number of products in cart
15
notes: '--notes to show with cart items in email--'
16
}
17
]
18
})
Copied!
The input of the sync() method should exactly match with the structure mentioned above. Cart sync will fail otherwise.

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.