addProductsToCart( )


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

The addProductsToCart() function returns a Promise that is resolved when the specified products are 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:

    Copy
  2. Look for any code that uses $w('#shoppingCartIcon').addProductsToCart(), 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
productsArray<AddToCartItem>Required

The list of products to add to the cart.

Did this help?