addToCart( )

Deprecated. This function will continue to work, but a newer version is available at wix-stores.cart.addProducts().

The addToCart() function returns a Promise that is resolved when the specified product is added to the shopping cart.

Migration Instructions

If this function is already in your code, it will continue to work. To stay compatible with future changes, migrate to wix-stores.cart.addProducts().

To migrate to the new function:

  1. Add the new import statement:

  2. Look for any code that uses $w('#shoppingCartIcon').addToCart(), and replace it with with cart.addProducts().

    Note: '#shoppingCartIcon' might be named differently in your code.

  3. Update your code to work with the new cart.addProducts() call and response properties.

  4. Test your changes to make sure your code behaves as expected.

Method Declaration
Method Parameters

The ID of the product to add to the cart.


The number of product units to add to the cart. If omitted, one product unit will be added.


Product options.

Was this helpful?