applyCoupon( )


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

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.updateCurrentCart().

To migrate to the new function:

  1. Add the new import statement:

    Copy
  2. Look for any code that uses cart.applyCoupon(), and replace it with currentCart.updateCurrentCart(). Update your code to work with the new currentCart.updateCurrentCart() call and response properties.

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

Adds and applies a coupon to the cart.

The applyCoupon() function returns a Promise that resolves to the current site visitor's cart when the specified coupon has been applied.

The cart can only hold one coupon. If a coupon is already applied to the cart, passing a different couponCode to applyCoupon() will replace the existing one.

Note: When editing a site as a contributor, applyCoupon() will only work when viewing the live site.

Method Declaration
Copy
Method Parameters
couponCodestringRequired

The code of the coupon to be applied to the cart.

Returns
Return Type:Promise<CartObj>
Did this help?