Skip to main content

Basket

The basket module handles the management of products within the basket and other related transactions. Each user is allowed to have a single active Basket, and a BasketItem is created for every unique item that users add to their basket. ​

Basket Model

ParameterData TypeDefinition
idintegerDatabase ID.
created_datedatetime (string)Basket created on.
modified_datedatetime (string)Basket last modified on.
statusstringBasket status. Basket status is defined on the BasketStatus enum.
versionintegerVersion info. Version information is used to control whether the cached version matches the Basket data in the database.
userintegerUser account linked to the basket.
voucher_codestringBasket discount code.

BasketItem Model

ParameterData TypeDefinition
idintegerDatabase ID.
created_datedatetime (string)Basket item created on.
modified_datedatetime (string)Basket item last modified on.
statusstringVersion info. Version information is used to control whether the cached version matches the BasketItem data in the database.
attributesdictAdditional attributes, if any, of the basket item.
attributes_kwargsdictAdditional keywords for additional attributes, if any, of the basket item.
localized_attributesdictAdditional localized attributes, if any, of the basket item.
localized_attributes_kwargsdictAdditional keywords, if any, for additional localized attributes of the basket item.
basketintegerBasket linked to the basket item.
referencestringUnique key created for related basket item.
productintegerItem linked to the basket item
quantityintegerQuantity of basket item.
tax_ratefloatTax rate of the basket item.
currency_typestringPrice currency of the basket item.
unit_pricefloatUnit price of the basket item.
imagestringThumbnail image of the basket item.
extra_product_priceintegerAdditional product price variations, if any, for the basket item.
extra_product_stockintegerAdditional stock information, if any, for the basket item.
parentintegerParent product, if the basket item is a child product.

Basket Endpoints

ParameterData TypeSection to SubmitDefinition
productintegerbodyID of the item to be added to the basket.
quantityintegerbodyQuantity of the item to be added to the basket.
attributesdictbodyProduct properties.
inquirydictbodyProduct details, if the item is exchangeable.
sub_itemsdictbodySub items.

GET Basket Items

​ Returns the basket and product information.

Path: https://{storefront_url}/baskets/basket/

Response

{
"basket": {
"basketitem_set": [
{
"quantity": 1,
"product": {
"pk": 1309,
"name": "Gitar",
"sku": "1020583031",
"base_code": "1020583",
"attributes": {},
"attribute_set": 152,
"attributes_kwargs": {},
"extra_attributes": {},
"productimage_set": [
{
"pk": 2576,
"status": "active",
"image": "HTTPs://akinon.akinoncdn.com/products/2021/09/10/3/e5b49285-7d8b-47a7-84f8-994c2217548a.jpg",
"order": 1,
"created_date": "2021-09-10T16:57:34.100718Z",
"specialimage_set": [
]
}
],
"price": "120",
"in_stock": true,
"currency_type": "try",
"retail_price": "200",
"unit_type": "qty",
"absolute_url": "/1020583031-1020583-gitar/",
"productvideo_set": [],
"product_type": "0",
"price_type": "default",
"form_schema": null,
"is_ready_to_basket": true,
"stock": 51,
"data_source": null
},
"unit_price": "120.00",
"currency_type": "try",
"tax_rate": "18.00",
"total_amount": "120.00",
"shipping_discount": null,
"attributes": {},
"id": 7387,
"attributes_kwargs": {},
"image": null,
"parent": null,
"offer_badges": [
{
"description": "Sitewide Campaign",
"discount": "24.00"
}
],
"price": "120.00",
"retail_price": "200.00",
"stock": 51,
"discount_amount": "24.00"
}
],
"total_amount": "96.00",
"total_quantity": 1,
"unavailable_basket_products": [],
"upsell_details": [],
"discounts": [
{
"description": "Sitewide Campaign",
"discount": "24.00"
}
],
"total_discount_amount": "24.00",
"total_product_amount": "120.00",
"voucher_code": null,
"pk": 6863,
"created_date": "2021-09-20T12:27:31.459026Z",
"modified_date": "2021-09-20T12:27:31.459045Z"
}
}

POST Add New Product to Basket

​ This method is used to add a new product to the basket.

Path: https://{storefront_url}/baskets/basket/

Request Body

{
"product": 49,
"quantity": 2
}

Response

Returns the same response as the GET method. ​

PATCH Update a Product Quantity

​ Used to change the quantity of a product added to the basket.

Path: https://{storefront_url}/baskets/basket/

Request Body

{
"product": 49,
"quantity": 0
}

Response

Returns the same response as the GET method. ​

PUT Update a Product Quantity

Path: https://{storefront_url}/baskets/basket/

Request Body

{
"product": 49,
"quantity": 0
}

Response

Returns the same response as the GET method. ​

DELETE Remove All Products From Basket

​ This method is used to delete all products added to the basket.

Path: https://{storefront_url}/baskets/basket/

Response

{
"basket": {
"basketitem_set": [],
"total_amount": "0.00",
"total_quantity": 0,
"unavailable_basket_products": [],
"upsell_details": [],
"discounts": [],
"total_discount_amount": "0.00",
"total_product_amount": "0.00",
"voucher_code": null,
"pk": 6863,
"created_date": "2023-06-06T12:32:41.281764Z",
"modified_date": "2023-07-05T10:22:34.911792Z",
"segment": {
"pk": null,
"stock_list": null,
"price_list": null
}
}
}

PATCH Update Single Basket Item

This method is used for making individual modification in basket items. If the basket item modification is successful, a new basket item is produced as a response. If the BasketItem to be modified cannot be found, it returns an error code of 400.

Path: basket_items/$

Request Body

The following request body parameters can be used to update single basket item.

ParameterData TypeDefinition
IDintegerDatabase ID of the BasketItem to be modified.
is_allbooleanIf true is submitted, then the update applies to all quantities of the basket item. If false is submitted, then the update applies to one basket item.
attributesbooleanAdditional attributes of the basket item to modify.
{
"id": 1720,
"is_all": true
}

Data Parameters for PUT Method

ParameterData TypeSection to SubmitDefinition
productintegerbodyID of the item to be added to the basket.
quantityintegerbodyQuantity of the item to be added to the basket.
attributesdictbodyProduct properties.
inquirydictbodyProduct details, if the item is exchangeable.

Payload Example

{
"product": 1780,
"quantity": 1,
"attributes": {
"example_attribute": 123
}
}

Data Parameters for PATCH Method

ParameterData TypeSection to SubmitDefinition
external_offer_codestringbodyWhen this field is submitted, the code is applied to the basket without instant verification, regardless of other fields.
remove_voucher_codebooleanbodyWhen True is submitted, the discount code is removed from the basket. When submitted simultaneously with external_offer_code, then the code submitted with external_offer_code is not removed.
voucher_codestringbodyDiscount code to apply to the basket. Instant verification is also applied to the code submitted here.

Payload Examples

{
"voucher_code": "aaa-bbb-ccc"
}
{
"remove_voucher_code": true
}
{
"external_offer_code": "ddd-eee-fff"
}

Data Parameters for DELETE Method

There are no data parameters for the DELETE method. ​

Response Parameters

ParameterData TypeDefinition
basketitem_setarrayDetails of basket items.
quantityintegerQuantity of basket item.
productdictDetails of basket item.
unit_pricestringItem unit price.
currency_typestringItem price currency.
tax_ratestringTax rate.
total_amountstringNet product price.
shipping_discountstringItem shipping discount amount.
attributesdictItem attributes.
idintegerDatabase ID of the item.
attributes_kwargsdictItem attribute keywords.
imagestringItem image.
parentdictIf the item is a child product, details of the parent product.
offer_badgesarrayDiscounts.
pricestringItem price.
retail_pricestringItem price before the discount.
stockintegerItem stock amount.
discount_amountstringItem discount amount.
total_amountstringTotal price of basket items.
total_quantityintegerTotal quantity of basket items.
unavailable_basket_productsarrayInvalid or unavailable items in the basket.
upsell_detailsarrayParameters and message details if there are items whose discount prices are no longer valid or if their prices increased later.
discountsarrayDiscounts.
total_discount_amountstringTotal discount amount.
total_product_amountstringTotal price of items.
voucher_codestringDiscount code.
pkintegerDatabase ID of the user's basket.
created_datestringDate when the basket was created in the database.
modified_datestringDate when the basket was last modified in the database.
segment:dictInformation on which segment the customer is in