Basket

Basket or Bag or Cart is the most critical element of any ecommerce business. On this page, we'll dive into the different basket related functionalities offered natively out of the box - get baskets, add/remove items, bulk add, apply/remove promotions.

Retrieve Basket(s)

The platform supports the capability to have multiple baskets per user, if its enabled at the time of signup configuration. Each basket can have a separate name and be referred to by the name. When no name is passed, the default basket is used and updated with the items. If the user is not logged in, a unique id (used as pseudo userId) is generated for the device and stored in the offline storage based on which the basket is identified for anonymous users.

Developers - API Operations

The following API operations are used for the Basket

OperationEndpointResponse
Get all baskets/api/v2/commerce/basket/user/:userId/allReturns all baskets for the users
Get basket details/api/v2/commerce/basket/:idReturns the basket details along with the items
Delete basket/api/v2/commerce/basket/:id/deleteDelete the basket

Add or Remove Items

This feature allows the visitors to add items to basket, remove items from basket and perform several additional actions on the basket.

Developers - API Operations

The following API operations are used for the Product Detail Page

OperationEndpointResponse
Add item/api/v2/commerce/basket/:id/items/addAdd items to a basket
Remove item/api/v2/commerce/basket/:id/items/:productId/removeRemove an item from the basket
Update product quantity/api/v2/commerce/basket/:id/items/:productId/:qtyUpdate the item qty in the basket

Bulk Add Items

Allows the user to add multiple items to the basket in one click. Typically very useful in B2B commerce and lookbook where you want to add multiple items in the basket in one go.

OperationEndpointResponse
Add multiple items in the basket in one call/api/v2/commerce/basket/:id/items/add-bulkAdd multiple items in the basket in one click.

Promotions

When user enters any promo code in the basket promo text box, the same can be applied straight away to the basket by making the following API call. In general, there is no need to make a separate ‘validate’ promo call and apply call will validate & then apply the promo. In some cases, as a developer when you only want to validate the promotion if its valid or not, you can then use the separate ‘validate’ api call.

Developers - API Operations

The following API operations are used for the applying or removing promotion from the basket.

OperationEndpointResponse
Apply promo/api/v2/commerce/basket/:id/promo/:promoCode/applyUpdated basket with the applied promo, if its valid.
Remove Promotion/api/v2/commerce/basket/:id/promo/:promoCode/removeUpdated basket with the promotion removed.
Validate Promotion/api/v2/commerce/basket/:id/promo/:promoCode/validateValidate the promo qualification against a basket.

Additional Functions

Besides the standard basket functions, several additional functionalities are available in the basket.

Developers - API Operations

The following API operations are used for the additional functions on Basket

OperationEndpointResponse
Update userId in Basket/api/v2/commerce/basket/:id/user?userId=<<user_id>>Maps the user to a specific basket, useful when the user logins after the basket has already been created.
Update shipping method/api/v2/commerce/basket/:id/delivery/shipping-method?shippingMethodId=<<bc_shipping_method_id>>&countryCode=<<country_code>>Update selected shipping method for basket
Update delivery plan/api/v2/commerce/basket/:id/delivery/planUpdate the delivery plan at the header level
Update the line level level delivery plan/api/v2/commerce/basket/:id/delivery/line-planUpdate delivery plan at line level
Get related products/api/v2/commerce/basket/:id/related-productsGet related products based on items in basket
Udpate selected store for pickup/api/v2/commerce/basket/:id/delivery/click-collect-storeUpdate selected store info for click and collect
Update campaign code/api/v2/commerce/basket/:id/campaignUpdate campaign code for basket, if some specific campaigns are executed and need to be associated with the basket
Update custom info/api/v2/commerce/basket/:id/custom-infoUpdate custom info fields, these are free text fields to capture elements as needed by the business.