Add a product variant to the shopping cart
curl --request POST \
--url https://api.example.com/api/v1/cart/ \
--header 'Content-Type: application/json' \
--data '
{
"variant_sku": "<string>",
"quantity": 123
}
'{
"success": "<string>",
"cart_total": 123
}Add a product to the shopping cart by specifying the variant SKU and desired quantity. The cart automatically applies any eligible offers and calculates pricing with discounts.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/klvxn/ecommerce-api/llms.txt
Use this file to discover all available pages before exploring further.
curl -X POST http://localhost:8000/api/v1/cart/ \
-H "Content-Type: application/json" \
-H "Cookie: sessionid=your_session_id" \
-d '{
"variant_sku": "2f23232242f2f3f",
"quantity": 2
}'
import requests
url = "http://localhost:8000/api/v1/cart/"
headers = {
"Content-Type": "application/json"
}
cookies = {
"sessionid": "your_session_id"
}
data = {
"variant_sku": "2f23232242f2f3f",
"quantity": 2
}
response = requests.post(url, headers=headers, cookies=cookies, json=data)
print(response.json())
const response = await fetch('http://localhost:8000/api/v1/cart/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
credentials: 'include', // Include session cookie
body: JSON.stringify({
variant_sku: '2f23232242f2f3f',
quantity: 2
})
});
const data = await response.json();
console.log(data);
{
"success": "2x Wireless Headphones - Black has been added",
"cart_total": 192.97
}
{
"variant_sku": ["This field is required."],
"quantity": ["Ensure this value is greater than or equal to 1."]
}
{
"variant": ["Product variant not found or is no longer available."]
}
{
"quantity": ["Only 3 units available in stock."]
}
sessionid) is automatically created~/workspace/source/cart/views.py:65-79curl --request POST \
--url https://api.example.com/api/v1/cart/ \
--header 'Content-Type: application/json' \
--data '
{
"variant_sku": "<string>",
"quantity": 123
}
'{
"success": "<string>",
"cart_total": 123
}