You are reading the documentation for v7.x and earlier, which is no longer the latest version. Switch to v8.x
updateEntryAndGetCart
Update cart entry (its quantity, store details) and getting the updated cart from SAP Commerce Cloud.
This method exchanges data with two endpoints exposed by the SAP OCC API: updateCartEntry and getCart.
When vsf-sap-token cookie is present in the request, this method will update an entry of the current user's cart. In case there is no cookie, it will update it in the anonymous user's cart. For logged-in users, make sure to pass cart code as the cartId param. In case of anonymous users, pass cart guid instead.
Signature
export declare function updateEntryAndGetCart(
context: SapccIntegrationContext,
props: UpdateCartProps
): Promise<Cart>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
context | Required | SapccIntegrationContext | |
props | Required | UpdateCartProps | 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 Cart.
Referenced Types
Examples
Updating quantity of a cart entry with a given entryNumber.
import { sdk } from '~/sdk';
const updatedCart = await sdk.commerce.updateEntryAndGetCart({
cartId: '00035084',
entryNumber: 0,
entry: { quantity: 2 }
});Updating quantity of a cart entry and selecting response fields.
import { sdk } from '~/sdk';
const updatedCart = await sdk.commerce.updateEntryAndGetCart({
cartId: '00035084',
entryNumber: 0,
entry: { quantity: 2 },
fields: 'guid,entries(quantity,product(code))'
});Updating quantity and deliveryPointOfService of a cart entry.
import { sdk } from '~/sdk';
const updatedCart = await sdk.commerce.updateEntryAndGetCart({
cartId: '00035084',
entryNumber: 0,
entry: {
quantity: 2,
deliveryPointOfService: { name: 'ap_warehouse_e' }
}
});