» Carts PATCH API Documentation

Update Cart

Endpoint: PATCH /carts/{session_id}

Purpose

The  endpoint used to update the contents and shipping details of an existing shopping cart session. This endpoint allows users to modify specific cart items such as updating the quantity or apply new shipping information.

Path Parameters

Field
Type
Description
session_id
Integer
The unique identifier of the cart session to be updated.

Query Parameters

This endpoint does not require any query parameters.

Use Case

A user updates the cart to reflect changes in product quantity or shipping address before completing the checkout process. This ensures the cart accurately reflects the customer's preferences and delivery information, enabling smooth order placement and correct calculation of totals, taxes, and shipping costs.

Request Body

Parameter Type Description
cart_item_id string Unique identifier of the specific item in the cart.
quantity integer Number of units for this cart item.
customer_id string Unique identifier of the customer who owns the cart.

{
    "cart_item_id": "CART_ITEM_ID",    
    "quantity": "QUANTITY",
    "shipping_address": {
        "first_name": "FIRST_NAME",
        "last_name": "LAST_NAME",
        "address_line_1": "ADDRESS_LINE_1",
        "address_line_2": "ADDRESS_LINE_2",
        "city": "CITY",
        "post_code": "POST_CODE",
        "country_id": "COUNTRY_ID",
        "state_id": "STATE_ID",
        "email": "EMAIL",
        "customer_id": "CUSTOMER_ID"
    }
}

Response

The response contains the updated cart details, including the session ID, currency used, delivery type, and updated totals such as subtotal, tax, discount, and grand total. It also includes the revised shipping address and shipping-related costs like handling fees and taxes. The cart items section details the product ID, quantity, selected variations, and pricing breakdown including unit price, total, and tax. This response ensures that customers and businesses have an accurate view of the cart's contents and charges, supporting informed decisions before checkout.

PATCH
https://{your_site_domain}/api/v4/carts/{session_id}
Try It Out
"cart": {
    "customer_id": CUSTOMER_ID,
    "session_id": "SESSION_ID",
    "currency_code": "CURRENCY_CODE",
    "currency_symbol": "CURRENCY_SYMBOL",
    "delivery_type": "DELIVERY_TYPE",
    "sub_total": SUBTOTAL,
    "shipping_cost": SHIPPING_COST,
    "shipping_tax": SHIPPING_TAX,
    "handling_fee": HANDLING_FEE,
    "handling_tax": HANDLING_TAX,
    "total_discount": TOTAL_DISCOUNT,
    "total_tax": TOTAL_TAX,
    "grand_total": GRAND_TOTAL,
    "paid": PAID_AMOUNT,
    "items_total": ITEMS_TOTAL,
    "payment_status": "PAYMENT_STATUS",
    "ip_address": IP_ADDRESS,
    "items": [
        {
            "item_id": ITEM_ID,
            "quantity": QUANTITY,
            "variations": [
                "VARIATION_1",
                "VARIATION_2"
            ],
            "taxable": TAXABLE,
            "shippable": SHIPPABLE,
            "unit_price": UNIT_PRICE,
            "total_price": TOTAL_PRICE,
            "product": {
                "product_id": PRODUCT_ID,
                "sku": "PRODUCT_SKU",
                "base_price": BASE_PRICE,
                "available_stock": AVAILABLE_STOCK,
                "on_sale": ON_SALE,
                "cost_price": COST_PRICE,
                "sale_price": SALE_PRICE,
                "url": "PRODUCT_URL",
                "name": "PRODUCT_NAME",
                "product_type": "PRODUCT_TYPE",
                "image_link": "PRODUCT_IMAGE_URL"
            }
        }
    ],
    "discount_messages": {
        "message": "DISCOUNT_MESSAGE",
        "status": "DISCOUNT_STATUS"
    }
}