curl --location --request POST 'https://api.stateset.com/v1/carts/cart_customer_123/merge' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data-raw '{
"source_cart_id": "cart_guest_456",
"merge_strategy": "combine",
"delete_source_cart": true
}'
{
"id": "cart_customer_123",
"object": "cart",
"customer_id": "cust_abc123",
"status": "active",
"items": [
{
"id": "ci_abc123",
"product_id": "prod_123",
"variant_id": "var_blue_large",
"product_name": "Wireless Headphones",
"variant_name": "Blue - Large",
"quantity": 5,
"unit_price": 9999,
"subtotal": 49995,
"source": "merged",
"metadata": {
"original_cart": "cart_customer_123",
"merged_quantity": 2,
"merge_timestamp": "2024-06-20T18:00:00Z"
}
},
{
"id": "ci_new789",
"product_id": "prod_456",
"product_name": "USB-C Cable",
"quantity": 2,
"unit_price": 1999,
"subtotal": 3998,
"source": "merged",
"metadata": {
"original_cart": "cart_guest_456",
"merge_timestamp": "2024-06-20T18:00:00Z"
}
}
],
"item_count": 7,
"unique_item_count": 2,
"subtotal": 53993,
"total": 58792,
"merge_details": {
"source_cart_id": "cart_guest_456",
"items_merged": 2,
"items_combined": 1,
"merge_timestamp": "2024-06-20T18:00:00Z",
"source_cart_deleted": true
},
"updated_at": "2024-06-20T18:00:00Z",
"messages": [
{
"type": "success",
"message": "Successfully merged 2 items from guest cart"
}
]
}
Merge a guest cart with a customer cart after login
curl --location --request POST 'https://api.stateset.com/v1/carts/cart_customer_123/merge' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data-raw '{
"source_cart_id": "cart_guest_456",
"merge_strategy": "combine",
"delete_source_cart": true
}'
{
"id": "cart_customer_123",
"object": "cart",
"customer_id": "cust_abc123",
"status": "active",
"items": [
{
"id": "ci_abc123",
"product_id": "prod_123",
"variant_id": "var_blue_large",
"product_name": "Wireless Headphones",
"variant_name": "Blue - Large",
"quantity": 5,
"unit_price": 9999,
"subtotal": 49995,
"source": "merged",
"metadata": {
"original_cart": "cart_customer_123",
"merged_quantity": 2,
"merge_timestamp": "2024-06-20T18:00:00Z"
}
},
{
"id": "ci_new789",
"product_id": "prod_456",
"product_name": "USB-C Cable",
"quantity": 2,
"unit_price": 1999,
"subtotal": 3998,
"source": "merged",
"metadata": {
"original_cart": "cart_guest_456",
"merge_timestamp": "2024-06-20T18:00:00Z"
}
}
],
"item_count": 7,
"unique_item_count": 2,
"subtotal": 53993,
"total": 58792,
"merge_details": {
"source_cart_id": "cart_guest_456",
"items_merged": 2,
"items_combined": 1,
"merge_timestamp": "2024-06-20T18:00:00Z",
"source_cart_deleted": true
},
"updated_at": "2024-06-20T18:00:00Z",
"messages": [
{
"type": "success",
"message": "Successfully merged 2 items from guest cart"
}
]
}
carts:write
permissions.
Authorization: Bearer YOUR_API_KEY
curl --location --request POST 'https://api.stateset.com/v1/carts/cart_customer_123/merge' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data-raw '{
"source_cart_id": "cart_guest_456",
"merge_strategy": "combine",
"delete_source_cart": true
}'
{
"id": "cart_customer_123",
"object": "cart",
"customer_id": "cust_abc123",
"status": "active",
"items": [
{
"id": "ci_abc123",
"product_id": "prod_123",
"variant_id": "var_blue_large",
"product_name": "Wireless Headphones",
"variant_name": "Blue - Large",
"quantity": 5,
"unit_price": 9999,
"subtotal": 49995,
"source": "merged",
"metadata": {
"original_cart": "cart_customer_123",
"merged_quantity": 2,
"merge_timestamp": "2024-06-20T18:00:00Z"
}
},
{
"id": "ci_new789",
"product_id": "prod_456",
"product_name": "USB-C Cable",
"quantity": 2,
"unit_price": 1999,
"subtotal": 3998,
"source": "merged",
"metadata": {
"original_cart": "cart_guest_456",
"merge_timestamp": "2024-06-20T18:00:00Z"
}
}
],
"item_count": 7,
"unique_item_count": 2,
"subtotal": 53993,
"total": 58792,
"merge_details": {
"source_cart_id": "cart_guest_456",
"items_merged": 2,
"items_combined": 1,
"merge_timestamp": "2024-06-20T18:00:00Z",
"source_cart_deleted": true
},
"updated_at": "2024-06-20T18:00:00Z",
"messages": [
{
"type": "success",
"message": "Successfully merged 2 items from guest cart"
}
]
}