Documentation is still being updated. Some content maybe unfinished.
A valid request URL is required to generate request examples{
"cart_hash": "e629fa6598d732768f7c726b4b621285",
"cart_key": "cb7a23af96a3f23af3c28a8b4b8c6d5e",
"currency": {
"currency_code": "USD",
"currency_symbol": "$",
"currency_symbol_pos": "left",
"currency_minor_unit": 2,
"currency_decimal_separator": ".",
"currency_thousand_separator": ",",
"currency_prefix": "$",
"currency_suffix": ""
},
"customer": {
"billing_address": {
"billing_first_name": "",
"billing_last_name": "",
"billing_company": "",
"billing_country": "",
"billing_address_1": "",
"billing_address_2": "",
"billing_postcode": "",
"billing_city": "",
"billing_state": "",
"billing_phone": "",
"billing_email": ""
},
"shipping_address": {
"shipping_first_name": "",
"shipping_last_name": "",
"shipping_company": "",
"shipping_country": "",
"shipping_address_1": "",
"shipping_address_2": "",
"shipping_postcode": "",
"shipping_city": "",
"shipping_state": ""
}
},
"items": {
"a3c5e7f9b1d3e5f7a9b1c3d5e7f9a1b3": {
"item_key": "a3c5e7f9b1d3e5f7a9b1c3d5e7f9a1b3",
"id": 145,
"name": "Wireless Bluetooth Headphones",
"title": "Wireless Bluetooth Headphones",
"price": "$18.00",
"quantity": {
"value": 1,
"min_purchase": 1,
"max_purchase": -1
},
"totals": {
"subtotal": 18,
"subtotal_tax": 0,
"total": 18,
"tax": 0
},
"slug": "wireless-bluetooth-headphones",
"meta": {
"product_type": "simple",
"sku": "WBH-001",
"dimensions": {
"length": "",
"width": "",
"height": "",
"unit": "cm"
},
"weight": "0.5",
"variation": {}
},
"backorders": "no",
"cart_item_data": {},
"featured_image": "https://example-store.com/wp-content/uploads/2024/03/headphones-blue.jpg"
}
},
"item_count": 1,
"items_weight": 0.5,
"coupons": [],
"needs_payment": true,
"needs_shipping": true,
"shipping": {
"total_packages": 0,
"show_package_details": true,
"has_calculated_shipping": false,
"packages": []
},
"fees": [],
"taxes": [],
"totals": {
"subtotal": "18.00",
"subtotal_tax": "0.00",
"fee_total": "0.00",
"fee_tax": "0.00",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "0.00",
"shipping_tax": "0.00",
"total": "18.00",
"total_tax": "0.00"
},
"removed_items": [],
"cross_sells": [],
"notices": {
"success": [
"Wireless Bluetooth Headphones has been added to your cart."
]
}
}Adds a single product item to the customer’s cart.
curl --request POST \
--url {protocol}://{host}/wp-json/cocart/v2/cart/add-item \
--header 'Content-Type: application/json' \
--data '
{
"id": "<string>",
"quantity": "1",
"variation": {},
"item_data": {},
"email": "jsmith@example.com",
"phone": "<string>",
"price": "<string>",
"return_item": false
}
'{
"cart_hash": "e629fa6598d732768f7c726b4b621285",
"cart_key": "cb7a23af96a3f23af3c28a8b4b8c6d5e",
"currency": {
"currency_code": "USD",
"currency_symbol": "$",
"currency_symbol_pos": "left",
"currency_minor_unit": 2,
"currency_decimal_separator": ".",
"currency_thousand_separator": ",",
"currency_prefix": "$",
"currency_suffix": ""
},
"customer": {
"billing_address": {
"billing_first_name": "",
"billing_last_name": "",
"billing_company": "",
"billing_country": "",
"billing_address_1": "",
"billing_address_2": "",
"billing_postcode": "",
"billing_city": "",
"billing_state": "",
"billing_phone": "",
"billing_email": ""
},
"shipping_address": {
"shipping_first_name": "",
"shipping_last_name": "",
"shipping_company": "",
"shipping_country": "",
"shipping_address_1": "",
"shipping_address_2": "",
"shipping_postcode": "",
"shipping_city": "",
"shipping_state": ""
}
},
"items": {
"a3c5e7f9b1d3e5f7a9b1c3d5e7f9a1b3": {
"item_key": "a3c5e7f9b1d3e5f7a9b1c3d5e7f9a1b3",
"id": 145,
"name": "Wireless Bluetooth Headphones",
"title": "Wireless Bluetooth Headphones",
"price": "$18.00",
"quantity": {
"value": 1,
"min_purchase": 1,
"max_purchase": -1
},
"totals": {
"subtotal": 18,
"subtotal_tax": 0,
"total": 18,
"tax": 0
},
"slug": "wireless-bluetooth-headphones",
"meta": {
"product_type": "simple",
"sku": "WBH-001",
"dimensions": {
"length": "",
"width": "",
"height": "",
"unit": "cm"
},
"weight": "0.5",
"variation": {}
},
"backorders": "no",
"cart_item_data": {},
"featured_image": "https://example-store.com/wp-content/uploads/2024/03/headphones-blue.jpg"
}
},
"item_count": 1,
"items_weight": 0.5,
"coupons": [],
"needs_payment": true,
"needs_shipping": true,
"shipping": {
"total_packages": 0,
"show_package_details": true,
"has_calculated_shipping": false,
"packages": []
},
"fees": [],
"taxes": [],
"totals": {
"subtotal": "18.00",
"subtotal_tax": "0.00",
"fee_total": "0.00",
"fee_tax": "0.00",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "0.00",
"shipping_tax": "0.00",
"total": "18.00",
"total_tax": "0.00"
},
"removed_items": [],
"cross_sells": [],
"notices": {
"success": [
"Wireless Bluetooth Headphones has been added to your cart."
]
}
}Unique identifier for the product or variation ID.
Quantity of this item to add to the cart.
Variable attributes that identify the variation of the item.
Additional item data passed to make item unique.
Set the customers billing email address.
Set the customers billing phone number.
Overrides the general or sale price with a custom price for the item if set.
Returns the item details once added.
Item added to cart successfully.
Returns a full updated cart response.
Unique cart hash.
Unique cart key for the customer.
Show child attributes
Show child attributes
Cart items indexed by item key.
Show child attributes
Total number of items in cart.
Total weight of all items.
Applied coupons.
Show child attributes
Whether the cart needs payment.
Whether the cart needs shipping.
Show child attributes
Cart fees.
Show child attributes
Cart taxes.
Show child attributes
Show child attributes
Recently removed items that can be restored.
Show child attributes
Cross-sell products.
Show child attributes
Cart notices and messages.
Additional data from extensions.
Was this page helpful?