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.
The platform provides persistent basket across different devices capability, a basket created on the website shall be available when the user logins to the app using the logged-in userId.
Developers - API Operations
The following API operations are used for the Basket
Operation | Endpoint | Response |
---|---|---|
Get all baskets | /api/v2/commerce/basket/user/:userId/all | Returns all baskets for the users |
Get basket details | /api/v2/commerce/basket/:id | Returns the basket details along with the items |
Delete basket | /api/v2/commerce/basket/:id/delete | Delete 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
Operation | Endpoint | Response |
---|---|---|
Add item | /api/v2/commerce/basket/:id/items/add | Add items to a basket |
Remove item | /api/v2/commerce/basket/:id/items/:productId/remove | Remove an item from the basket |
Update product quantity | /api/v2/commerce/basket/:id/items/:productId/:qty | Update 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.
Operation | Endpoint | Response |
---|---|---|
Add multiple items in the basket in one call | /api/v2/commerce/basket/:id/items/add-bulk | Add 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.
The ‘auto-apply’ promotions will apply automatically on any change in the basket, so no need to make any explicit call for applying those promotions.
Developers - API Operations
The following API operations are used for the applying or removing promotion from the basket.
Operation | Endpoint | Response |
---|---|---|
Apply promo | /api/v2/commerce/basket/:id/promo/:promoCode/apply | Updated basket with the applied promo, if its valid. |
Remove Promotion | /api/v2/commerce/basket/:id/promo/:promoCode/remove | Updated basket with the promotion removed. |
Validate Promotion | /api/v2/commerce/basket/:id/promo/:promoCode/validate | Validate 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
Operation | Endpoint | Response |
---|---|---|
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/plan | Update the delivery plan at the header level |
Update the line level level delivery plan | /api/v2/commerce/basket/:id/delivery/line-plan | Update delivery plan at line level |
Get related products | /api/v2/commerce/basket/:id/related-products | Get related products based on items in basket |
Udpate selected store for pickup | /api/v2/commerce/basket/:id/delivery/click-collect-store | Update selected store info for click and collect |
Update campaign code | /api/v2/commerce/basket/:id/campaign | Update 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-info | Update custom info fields, these are free text fields to capture elements as needed by the business. |