Home > @shopware-pwa/shopware-6-client > addProductToCart
# addProductToCart() function
Adds specific quantity of the product to the cart by productId. It creates a new cart line item.
Warning: This method does not change the state of the cart in any way if productId already exists in a cart. For changing the quantity use addQuantityToCartLineItem() or changeCartLineItemQuantity() methods.
Signature:
export declare function addProductToCart(productId: string, quantity?: number, contextInstance?: ShopwareApiInstance): Promise<Cart>;
# Parameters
Parameter | Type | Description |
---|---|---|
productId | string | |
quantity | number | |
contextInstance | ShopwareApiInstance |
Returns:
Promise<Cart>
# Exceptions
ClientApiError