Modify Items in Cart
Items in a cart can be modified in two ways:
Update SKU Quantity
Delete SKU from Cart
Update SKU Quantity
Once an item is added to a cart, you may want to let the shopper increase or decrease the quantity of the SKU in the cart.
Let’s start with a Cart shown below:
{
"id": 76448,
"token": "f4fc7b7afc504898b532d2e6668e3504",
"user_id": 10397,
"app_id": 10382,
"developer_id": 10292,
"bags": [
{
"id": 62158,
"order_id": 76448,
"merchant_id": 10189,
"app_id": 10382,
"status": "IN_PROGRESS",
"fulfillment_status": "PROCESSING",
"financial_status": "UNPAID",
"skus": [
{
"id": 81227,
"merchant_id": 10189,
"app_id": 10382,
"product_id": "87f88388d8a44de6b7ea74d1b822926f",
"sku_id": 196585,
"external_id": "45101059440941",
"name": "Pastel Flower Land - Extra-Large / Design Three / Blue",
"brand": "The Violet Garden",
"thumbnail": "https://cdn.shopify.com/s/files/1/0758/9363/7421/files/wealthy_floral_design_tshirt_with_a_blue_pastel_colour_backgrou_caefa8e2-b19a-4eb7-84a1-1855591d017b.png",
"quantity": 1,
"price": 3500,
"weight": 3.0,
"available": true,
"status": "IN_PROGRESS",
"product_type": "PHYSICAL",
"line_price": 3500
}
],
"taxes": [],
"sub_total": 3500,
"taxes_included": false,
"transactions": [],
"external_checkout": true,
"commission_rate": 25.0,
"date_created": "2023-10-01T02:37:47+0000",
"remorse_period_ends": "2023-10-31T02:37:47+0000",
"currency": "USD",
"external_currency": "USD",
"channel": "APP",
"platform": "SHOPIFY",
"fulfillments": [],
"discounts": [],
"wallet_based_checkout": false,
"bag_status": "IN_PROGRESS",
"bag_id": 62158,
"merchant_name": "the violet garden"
}
],
"sub_total": 3500,
"status": "IN_PROGRESS",
"is_guest": true,
"date_created": "2023-10-01T02:37:46+0000",
"date_last_modified": "2023-10-01T02:37:46+0000",
"priced": false,
"wallet_based_checkout": false,
"currency": "USD",
"errors": [],
"channel": "APP",
"currency_symbol": "$",
"stripe_key": "pk_test_UHg8oLvg4rrDCbvtqfwTE8qd",
"guest": true,
"order_status": "IN_PROGRESS",
"order_id": 76448,
"intent_based_checkout": false
}
You can update the quantity of a SKU in the cart using the Update SKU in Cart endpoint.
curl --location --request PUT 'https://sandbox-api.violet.io/v1/checkout/cart/76448/skus/81227' \
--header 'Content-Type: application/json' \
--header 'X-Violet-Token: <TOKEN>' \
--header 'X-Violet-App-Secret: <SECRET>' \
--header 'X-Violet-App-Id: <APP_ID>' \
--data-raw '{
"quantity": 10
}'
The response will be a standard Cart
response with the updated SKU values reflected in their respective Bags
.
Delete SKU from Cart
If you want to delete the SKU from the Cart altogether, you can use the Delete SKU from Cart API. This will delete the item in the cart that matches the order_sku_id
that you pass in.
curl --request DELETE \
--url https://sandbox-api.violet.io/v1/checkout/cart/{cart_id}/skus/{order_sku_id}
--header 'Content-Type: application/json' \
--header 'X-Violet-Token: <TOKEN>' \
--header 'X-Violet-App-Secret: <SECRET>' \
--header 'X-Violet-App-Id: <APP_ID>' \
The response will be a standard Cart
response with the updated SKU values reflected in their respective Bags
.
Last updated
Was this helpful?