Home > @shopware-pwa/composables > useAddToCart

# useAddToCart() function

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Add product to cart. Options - IUseAddToCart

Signature:

export declare function useAddToCart(params: {
    product: Ref<Product> | Product;
}): IUseAddToCart;

# Parameters

Parameter Type Description
params { product: Ref<Product> | Product; }

Returns:

IUseAddToCart

# Example

Example usage:

const {isInCart, quantity, addToCart} = useAddToCart({ product })
if (!isInCart.value) {
   quantity.value = 5
   await addToCart()
}