Skip to main content

Shopping Cart & Checkout

5 API calls in this section.

Get Cart

Storefront & Commerce / Shopping Cart & Checkout
GET/storefront/stores/:store_id/cart

Retrieves the authenticated user's shopping cart for the store (market), with items, pricing, and totals.

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request GET "$ONDI_BASE_URL/storefront/stores/:store_id/cart" \2  --header "Authorization: Bearer {{access_token}}"

Path parameters

store_idRequired
path string

{{store_id}}

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

JWT (required). Cart is keyed by authenticated user.

Responses

Success - Cart with Items200OK
Response body
json
1{2  "success": true,3  "data": {4    "cart": {5      "id": "cart-uuid-123",6      "market_id": "{{store_id}}",7      "enriched_items": [8        {9          "variant_id": "variant-uuid-1",10          "quantity": 2,11          "variant_slug": "iphone-15-pro-space-gray-256gb",12          "product_slug": "iphone-15-pro",13          "has_variant": true,14          "variant": {15            "id": "variant-uuid-1",16            "slug": "iphone-15-pro-space-gray-256gb",17            "name": {18              "en": "iPhone 15 Pro - 256GB"19            },20            "price": 999.99,21            "images": [22              "https://example.com/iphone15-pro-1.jpg"23            ],24            "stock_quantity": 25,25            "attributes": {26              "color": "Space Gray",27              "storage": "256GB"28            },29            "product": {30              "id": "product-uuid-1",31              "name": {32                "en": "iPhone 15 Pro"33              },34              "market_id": "market-uuid",35              "slug": "iphone-15-pro",36              "has_variant": true37            }38          }39        }40      ],41      "total_items": 2,42      "updated_at": "2023-12-01T15:30:00Z"43    }44  }45}
Success - Empty Cart200OK
Response body
json
1{2  "success": true,3  "cart": null4}

Add to Cart

Storefront & Commerce / Shopping Cart & Checkout
POST/storefront/stores/:store_id/cart/items

Adds a product variant to the authenticated user's shopping cart.

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request POST "$ONDI_BASE_URL/storefront/stores/:store_id/cart/items" \2  --header "Authorization: Bearer {{access_token}}" \3  --header "Content-Type: application/json" \4  --header "Content-Type: application/json" \5  --data '{6  "variant_id": "variant-uuid-123",7  "quantity": 18}'
Request body
json
1{2  "variant_id": "variant-uuid-123",3  "quantity": 14}

Path parameters

store_idRequired
path string

{{store_id}}

Request body fields

variant_idExample
string

Example field from the request body.

quantityExample
number

Example field from the request body.

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

JWT (required)

Content-TypeOptional
header string

application/json

Responses

Success - Item Added200OK
Response body
json
1{2  "success": true,3  "message": "Item added to cart"4}
Error - Insufficient Stock400Bad Request
Response body
json
1{2  "success": false,3  "message": "Insufficient stock available"4}
Error - Product Not Found404Not Found
Response body
json
1{2  "success": false,3  "message": "Product not found or not available"4}

Update Cart Item

Storefront & Commerce / Shopping Cart & Checkout
PUT/storefront/stores/:store_id/cart/items

Updates the quantity of an item in the shopping cart. To remove an item, set quantity to 0.

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request PUT "$ONDI_BASE_URL/storefront/stores/:store_id/cart/items" \2  --header "Authorization: Bearer {{access_token}}" \3  --header "Content-Type: application/json" \4  --header "Content-Type: application/json" \5  --data '{6  "variant_id": "variant-uuid-123",7  "quantity": 38}'
Request body
json
1{2  "variant_id": "variant-uuid-123",3  "quantity": 34}

Path parameters

store_idRequired
path string

{{store_id}}

Request body fields

variant_idExample
string

Example field from the request body.

quantityExample
number

Example field from the request body.

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

JWT (required)

Content-TypeOptional
header string

application/json

Responses

Success - Quantity Updated200OK
Response body
json
1{2  "success": true,3  "message": "Cart updated"4}

Remove from Cart

Storefront & Commerce / Shopping Cart & Checkout
PUT/storefront/stores/:store_id/cart/items

Removes an item from the cart by setting its quantity to 0.

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request PUT "$ONDI_BASE_URL/storefront/stores/:store_id/cart/items" \2  --header "Authorization: Bearer {{access_token}}" \3  --header "Content-Type: application/json" \4  --header "Content-Type: application/json" \5  --data '{6  "variant_id": "variant-uuid-123",7  "quantity": 08}'
Request body
json
1{2  "variant_id": "variant-uuid-123",3  "quantity": 04}

Path parameters

store_idRequired
path string

{{store_id}}

Request body fields

variant_idExample
string

Example field from the request body.

quantityExample
number

Example field from the request body.

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

JWT (required)

Content-TypeOptional
header string

application/json

Responses

Success - Item Removed200OK
Response body
json
1{2  "success": true,3  "message": "Cart updated"4}

Checkout - Create Order from Cart

Storefront & Commerce / Shopping Cart & Checkout
POST/storefront/stores/{{store_id}}/checkout

Creates a pending order from the authenticated user's cart. No request body required. Payment method and shipping address will be handled in a separate payment initiation API.

Send a bearer token in Authorization and a tenant API key when the integration requires X-APIKey or X-API-Key.
Request
curl
1curl --request POST "$ONDI_BASE_URL/storefront/stores/{{store_id}}/checkout" \2  --header "Authorization: Bearer {{access_token}}" \3  --header "X-API-Key: {{api_key}}"

Path parameters

store_idRequired
path string

Variable used inside the request path.

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

X-API-KeyOptional
header string

{{api_key}}

Alternative authentication method

Responses

No response example is available for this endpoint yet.