Cart

Manage Cart

Get Cart Items

get
​

https://<domain>/<api prefix>/<version>/commerce/cart-items/
get the list of items in the cart
Request
Response
Request
Headers
apikey
required
string
apikey
Authorization
required
string
Bearer access token
Response
200: OK
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {
"cartitems": [
{
"id": <id>,
"order_id_id": <orderid>,
"vendor_id": <vendor id>,
"product_id": <produc id>,
"bundle_id": <bundle id>,
"line_item_type": <item type>,
"line_item_label": <item label>,
"quantity": <quantity>,
"price": <price>,
"data": <data>,
"status": <status>,
"unit_price": <unit price>,
"currency_code": <currency_code>,
"currency_symbol": <currency_symbol>
}
]
}
}

Sample Code

Node

var request = require("request");
​
var options = { method: 'GET',
url: 'https://<domain>/<api prefix>/<version>/commerce/cart-items/',
headers:
{ authorization: 'Bearer <access-token>',
apikey: '<apikey>' } };
​
request(options, function (error, response, body) {
if (error) throw new Error(error);
​
console.log(body);
});

PHP

<?php
​
$curl = curl_init();
​
curl_setopt_array($curl, array(
CURLOPT_PORT => "8000",
CURLOPT_URL => "https://<domain>/<api prefix>/<version>/commerce/cart-items/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"apikey: <apikey>",
"authorization: Bearer <access-token>",
),
));
​
$response = curl_exec($curl);
$err = curl_error($curl);
​
curl_close($curl);
​
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}

Remove an item from the cart

post
​

https://<domain>/<api prefix>/<version>/commerce/remove-cart-item/
remove an item from cart by passing item id and order id
Request
Response
Request
Headers
apikey
required
string
apikey
Authorization
required
string
Bearer Access token
Body Parameters
pk
required
number
item id
order_id
required
number
order id
Response
200: OK
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {}
}

Sample code

Node

var request = require("request");
​
var options = { method: 'POST',
url: 'https://<domain>/<api prefix>/<version>/commerce/remove-cart-item/',
headers:
{ authorization: 'Bearer <access-token>',
apikey: '<apikey>',
'content-type': 'multipart/form-data' },
formData: { order_id: '9558', pk: '10465' } };
​
request(options, function (error, response, body) {
if (error) throw new Error(error);
​
console.log(body);
});

PHP

<?php
​
$curl = curl_init();
​
curl_setopt_array($curl, array(
CURLOPT_PORT => "8000",
CURLOPT_URL => "https://<domain>/<api prefix>/<version>/commerce/remove-cart-item/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"order_id\"\r\n\r\n9558\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"pk\"\r\n\r\n10465\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
CURLOPT_HTTPHEADER => array(
"apikey: <apikey>",
"authorization: Bearer <access-token>",
),
));
​
$response = curl_exec($curl);
$err = curl_error($curl);
​
curl_close($curl);
​
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}

Error Responses

Status Code

Error Type

Field

Description

400

Validation Error

order_id

This field may not be blank.

400

Validation Error

pk

This field may not be blank.