addToCart( )


Deprecated. This function will continue to work, but a newer version is available at wix-ecom-backend.currentCart.addToCurrentCart().

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-ecom-backend.currentCart.addToCurrentCart().

To migrate to the new function:

  1. Add the new import statement:

    Copy
  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
Copy
Method Parameters
productIDstringRequired

The ID of the product to add to the cart.


quantitynumberRequired

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


optionsAddToCartOptions

Product options.

Did this help?