Alokai

updateProductInBasket

Updates an item in a basket.

This method communicates with the updateProductInBasket endpoint of the Vue Storefront API Middleware. In turn, it receives data from the updateItemInBasket or the Update an item of a basket endpoints exposed by SCAPI / OCAPI depending on the middleware configuration.

The following values in the request body are considered by the server: - product_id: a valid product id. The purpose of this value is to exchange a variation of a variation product. - shipment_id: a valid shipment id. The purpose of this value is to move a product item to another shipment. - quantity: a number between 0 and 999. The purpose of this value is to change quantity of the product item. If quantity is 0, the product item is removed. - option_items/option_value_id: a valid option value id. The purpose of this value is to exchange an option value for an option item of an option product. This is only possible if the product item is an option product. To change option values a collection of option items to be changed need to be provided in property option_items. Those option_items need to contain option_id and option_value_id. The provided values must be valid for the option product that this product item represents. Otherwise InvalidProductOptionItemException or InvalidProductOptionValueItemException will be thrown. - custom properties* c_<custom_name>: a value corresponding to the type defined for custom attribute of ProductLineItem. The purpose of this value is to add or change the value of a custom attribute defined for ProductLineItem.

Possible Responses 400 - InvalidProductItemException - Indicates that the product with the given product id in the request body is invalid. - InvalidProductOptionItemException - Indicates that an option with the specified option id is unknown. - InvalidProductOptionValueItemException - Indicates that an option with the specified option value id is unknown. - InvalidProductItemQuantityException - Indicates a null quantity value

Signature

export declare function updateProductInBasket(
	props: BasketProductUpdateParams & {
    basketId?: string;
}
): Promise<import("commerce-sdk/dist/checkout/checkout").ShopperBaskets.Basket>;

Parameters

NameRequiredTypeDescription
propsRequiredBasketProductUpdateParams & { basketId?: string; }Parameter object which can be used with this method. Refer to its type definition to learn about possible properties.

Returns

Returns a representation of a Basket object.

Referenced Types

  • BasketProductUpdateParams
  • ShopperBaskets.Basket

Examples

Updating a product quantity by quantity.

import { sdk } from '~/sdk.config.ts';

const basket = await sdk.commerce.updateProductInBasket({ quantity: 3, itemId: '43c38652bc3844e14cd482ff28' });

Updating the product options by priceAdjustments

import { sdk } from '~/sdk.config.ts';

const basket = await sdk.commerce.updateProductInBasket({
 quantity: 1,
 itemId: '43c38652bc3844e14cd482ff28',
 optionItems: [{
  optionId: "consoleWarranty",
  optionValueId: "001",
 }]
});

On this page