updateCartEntry
Method updating a cart entry (its quantity, store details) in SAP Commerce Cloud.
This method sends a POST request to the updateCart endpoint of the Alokai Middleware. In turn, it exchanges data with the updateCartEntry endpoint exposed by the SAP OCC API Cart Entries Controller.
When vsf-sap-token cookie is present in the browser, 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.
You might also want to see the updateEntryAndGetCart method.
Signature
export declare function updateCartEntry<Res extends CartModification = CartModification,
Props extends UpdateCartProps = UpdateCartProps>(
props: Props,
options?: MethodOptions
): Promise<Res>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
props | Required | Props | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
options | Optional | MethodOptions | Options that can be passed to additionally configure the request or customize the logic in a plugin. |
Returns
Returns a representation of a Cart Modification.
Referenced Types
Examples
Updating quantity of a cart entry with a given entryNumber.
import { sdk } from '~/sdk';
const cartModification = await sdk.commerce.updateCartEntry({
cartId: '00035084',
entryNumber: 0,
entry: { quantity: 2 }
});Updating quantity of a cart entry and selecting response fields.
import { sdk } from '~/sdk';
const cartModification = await sdk.commerce.updateCartEntry({
cartId: '00035084',
entryNumber: 0,
entry: { quantity: 2 },
fields: 'quantityAdded,statusCode'
});Updating quantity and deliveryPointOfService of a cart entry.
import { sdk } from '~/sdk';
const cartModification = await sdk.commerce.updateCartEntry({
cartId: '00035084',
entryNumber: 0,
entry: {
quantity: 2,
deliveryPointOfService: { name: 'ap_warehouse_e' }
}
});