UpdateCartLineItem
Implements UpdateCartLineItem
Unified Method.
Source
import { defineApi } from "@vsf-enterprise/unified-api-sfcc";
import { getNormalizedCart } from "@vsf-enterprise/unified-api-sfcc";
import { KnownKeys } from "@vsf-enterprise/unified-api-sfcc";
import { BasketProductUpdateParams } from "@vsf-enterprise/sfcc-types";
import from "@vsf-enterprise/unified-api-sfcc/udl";
declare module "@vsf-enterprise/unified-api-sfcc" {
interface UpdateCartLineItemExtendedArgs {
/**
* The additional cart line item parameters to be updated.
* {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-baskets?meta=updateItemInBasket SFCC method reference}
*
*/
lineItem?: Omit<KnownKeys<BasketProductUpdateParams>, "itemId" | "quantity">;
}
}
export const updateCartLineItem = defineApi.updateCartLineItem(async (context, args) => {
const { lineItemId, quantity, cartId } = args;
const cart = await context.api.updateProductInBasket({
basketId: cartId,
itemId: lineItemId,
quantity,
});
return await getNormalizedCart(context, cart);
});