Shoptrader API docs

Image Description

Baskets

Retrieve, add, delete and edit baskets.

Requests

Type Call Omschrijving
GET
/api/v2/baskets
Retrieves all baskets. This call is paginated
GET
/api/v2/baskets/{basketKey}
Retrieves a specific basket indicated by the basketKey. The basketKey is a GUID.
GET
/api/v2/baskets/{basketKey}/{productId}
Retrieves a specific product from the basket
POST
/api/v2/baskets
Adds a new basket to the database
PATCH
/api/v2/baskets/{basketKey}
Alters a basket
PATCH
/api/v2/baskets/{basketKey}/{productId}
Alters a product
DELETE
/api/v2/baskets/{basketKey}/{productId}
Removes a product from the basket
DELETE
/api/v2/baskets/{basketKey}
Removes a basket

PHP Examples


Endpoint

GET /api/v2/baskets/{basketKey}

<?php

$strApiBaseUrl 
'uwdomein.uwdomeinextentie'// base URL
$basketKey '{5885b24e-77b3-4151-b91f-3e8234386d5e}'// basket key
$token    '8f00f89310945a0ca35666c8c9ced2e314e37aa6c32e900932e19902b42208767'// your API token

$strUrl 'http://'.$strApiBaseUrl.'/api/v2/baskets/'.$basketKey.'?token='.$token;

$objCurl curl_init();
curl_setopt($objCurlCURLOPT_URL$strUrl);
curl_setopt($objCurlCURLOPT_RETURNTRANSFERtrue);
curl_setopt($objCurlCURLOPT_TIMEOUT60);
curl_setopt($objCurlCURLOPT_USERAGENT'Shoptrader');

// execute cURL
$responseCurl curl_exec($objCurl);

if (
$responseCurl === FALSE) {
    echo 
"cURL Error: ".curl_error($objCurl);
} else {
    
print_r($responseCurl); // the successful response contains a JSON as shown below
}

?>

Show response

Endpoint

POST/PATCH /api/v2/baskets

customerId
integer
Customer id
products
array
Use this member variable to add products to the cart. De variable contains an array with the following memebers:

uprid
string
A number followed optionally by one or more sets of option/values. Example: 1234{1}2{3}4
quantity
integer
If excluded or empty, the quantity is set to 1
title
string
Only included for special custom products
price
float
Only included for special custom products. The price excludes VAT and a VAT percentage of 21% is always assumed
billingAddressId
integer
addressBookId used for billing. If empty the default addressBookId is used.
deliveryAddressId
integer
addressBookId used for shipping. If empty the default addressBookId is used.
shippingModule
string
One of the shipping modules as set up in the backoffice/modules section. If empty, a default shipping module is set.
paymentModule
string
One of the payment modules as set up in the backoffice/modules section. If empty, a default payment module is set.
coupon
string
A discount coupon
loyaltyPoints
int
The number of loyalty points to cash in. If the number of points exceeds the maximum, the maximum is filled in instead.
<?php

$strApiBaseUrl 
'uwdomein.uwdomeinextentie'// base URL
$token    '8f00f89310945a0ca35666c8c9ced2e314e37aa6c32e900932e19902b42208767'// your API token

$strUrl 'http://'.$strApiBaseUrl.'/api/v2/baskets?token='.$token;

$parameters = array(
    
"customerId" => "12345",
    
"products" => array(
        
"uprid" => "1234{1}2{3}4",
        
"quantity" => "1",
        
"title" => "Product title",
        
"price" => "11.59"
    
),
    
"billingAddressId" => "3",
    
"deliveryAddressId" => "2",
    
"shippingModule" => "",
    
"paymentModule" => "",
    
"coupon" => "",
    
"loyaltyPoints" => ""
);

$objCurl curl_init();
curl_setopt($objCurlCURLOPT_URL$strUrl);
curl_setopt($objCurlCURLOPT_RETURNTRANSFERtrue);
curl_setopt($objCurlCURLOPT_TIMEOUT60);
curl_setopt($objCurlCURLOPT_USERAGENT'Shoptrader');
curl_setopt($objCurlCURLOPT_CUSTOMREQUEST'POST');
curl_setopt($objCurlCURLOPT_POSTFIELDSjson_encode($parameters));
curl_setopt($objCurlCURLOPT_HTTPHEADER, array("Content-Type: application/json"));

// execute cURL
$responseCurl curl_exec($objCurl);

if (
$responseCurl === FALSE) {
    echo 
"cURL Error: ".curl_error($objCurl);
} else {
    
print_r($responseCurl); // the successful response contains a JSON as shown below
}

?>

Success response (JSON)

							{
    "id": "206",
    "basketKey": "{51271f4e-4acb-4583-a357-ac136f622f1d}",
    "basketType": "100",
    "customerId": "0",
    "orderId": null,
    "guestAccount": "1",
    "value": "0.0000",
    "valuePerRate": null,
    "tax": null,
    "taxPerRate": null,
    "billingAddressId": "0",
    "deliveryAddressId": "0",
    "billingCountryId": "1",
    "deliveryCountryId": "1",
    "btwNumber": "",
    "shippingModule": null,
    "shippingProvider": false,
    "shippingValue": "0.0000",
    "shippingTax": "0.0000",
    "shippingTaxClassId": "4",
    "shippingTaxRate": "0.0000",
    "paymentModule": null,
    "paymentOption": "",
    "paymentCommission": "0.0000",
    "paymentCommissionTitle": "",
    "coupon": "",
    "couponValid": "0",
    "couponDiscount": "0.0000",
    "couponTaxCalculated": "0.0000",
    "loyaltyPoints": "0",
    "loyaltyPointsMax": "0",
    "loyaltyPointsDiscount": "0.0000",
    "deletedFreeProducts": [],
    "geoZoneId": "4",
    "calculateTax": true,
    "contentType": "physical",
    "invalidate": "0",
    "dateCreated": "2019-01-31 13:37:33",
    "lastModified": null,
    "displayTax": true,
    "products": []
}
						

Endpoint

PATCH /api/v2/baskets/{basketKey}/{productId}

quantity
integer
The product's quantity
title
string
In case of as custom product: the product's title
price
string
In case of as custom product: the product's price excluding VAT
<?php

$strApiBaseUrl 
'uwdomein.uwdomeinextentie'// base URL
$token    '8f00f89310945a0ca35666c8c9ced2e314e37aa6c32e900932e19902b42208767'// your API token
$basketKey '{5885b24e-77b3-4151-b91f-3e8234386d5e}'// basket key
$productId '50';

$strUrl 'http://'.$strApiBaseUrl.'/api/v2/baskets/'.$basketKey.'/'.$productId.'?token='.$token;

$parameters = array(
    
"quantity" => "1",
    
"title" => "Product title",
    
"price" => "11.59"
);

$objCurl curl_init();
curl_setopt($objCurlCURLOPT_URL$strUrl);
curl_setopt($objCurlCURLOPT_RETURNTRANSFERtrue);
curl_setopt($objCurlCURLOPT_TIMEOUT60);
curl_setopt($objCurlCURLOPT_USERAGENT'Shoptrader');
curl_setopt($objCurlCURLOPT_CUSTOMREQUEST'PATCH');
curl_setopt($objCurlCURLOPT_POSTFIELDSjson_encode($parameters));
curl_setopt($objCurlCURLOPT_HTTPHEADER, array("Content-Type: application/json"));

// execute cURL
$responseCurl curl_exec($objCurl);

if (
$responseCurl === FALSE) {
    echo 
"cURL Error: ".curl_error($objCurl);
} else {
    
print_r($responseCurl); // the successful response contains a JSON as shown below
}

?>