Cart
Manage Cart
get
https://<domain>/<api prefix>/<version>/commerce/cart-items/
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
$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;
}
post
https://<domain>/<api prefix>/<version>/commerce/remove-cart-item/
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
$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;
}
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. |
post
https://
<domain>/<api prefix>/<version>/commerce/update-cart/
var request = require('request');
var options = {
'method': 'GET',
'url': '<domain>/<api prefix>/<version>/commerce/update-cart/',
'headers': {
'apikey': '<apikey>',
'Authorization': 'Bearer <access token>'
},
formData: {
'cart_id': '34',
'line_item_id': '43',
'quantity': '34'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('<domain>/<api prefix>/<version>/commerce/update-cart/');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'apikey' => '<apikey>',
'Authorization' => 'Bearer <access token>'
));
$request->addPostParameter(array(
'cart_id' => '34',
'line_item_id' => '43',
'quantity' => '34'
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
Last modified 1yr ago