Introduction

You can offer your customers discount coupons to promote loyalty and increase sales. Customers can then apply the coupon codes at checkout to take advantage of your offers. You can apply coupons to items in Wix Stores, Wix Bookings, Wix Events, and Wix Pricing Plans.

To use the Coupons API, import {coupons} from the wix-marketing-backend module:

Copy
import { coupons } from "wix-marketing-backend";
Did this help?

createCoupon( )


Creates a new coupon.

The createCoupon() function returns a Promise that resolves to an object containing the ID of the new coupon after it has been successfully created.

When creating a coupon, the specified couponInfo object must contain a value for exactly 1 of the following coupon properties. This defines the coupon type.

  • "moneyOffAmount"
  • "percentOffRate"
  • "fixedPriceAmount"
  • "buyXGetY"
  • "freeShipping"

When creating a new coupon, the specified couponInfo object must contain values for name, code, startTime, and either scope or minimumSubtotal. The exception is for a freeShipping coupon type, for which you cannot apply a scope and minimumSubtotal is optional.

The coupon scope defines the items a coupon applies to. You can apply a coupon to all items in a specific Wix application, a group within the application, or a single item within a group.

The following table lists the currently supported coupon scopes:

namespacegroupentityIdResult
stores----Applies to all store products
storesproductproduct IDApplies to the specific store product with the provided ID
storescollectioncollection IDApplies to the specific store collection with the provided ID
bookings----Applies to all bookings services
bookingsserviceservice IDApplies to the specific bookings service with the provided ID
eventseventevent IDApplies to the specific event with the provided ID
eventsticket--Applies to all event tickets
eventsticketticket IDApplies to the specific event ticket with the provided ID
pricingPlans----Applies to all pricing plans
pricingPlansplanplan IDApplies to the specific pricing plan with the provided ID
Method Declaration
Copy
function createCoupon(couponInfo: CouponInfo): Promise<CouponId>;
Method Parameters
couponInfoCouponInfoRequired

The information to use when creating the coupon.

Returns
Return Type:Promise<CouponId>
JavaScript
import { coupons } from "wix-marketing-backend"; export function createCoupon() { let couponInfo = { name: "My Coupon", code: "myCouponCode", startTime: new Date(), expirationTime: new Date(2020, 12, 31), usageLimit: 100, limitedToOneItem: true, limitPerCustomer: 1, active: true, scope: { namespace: "stores", }, moneyOffAmount: 10, }; return coupons.createCoupon(couponInfo); } // Returns promise that resolves to: // {"id": "058b0b56-e90d-4f4e-a8a3-8bf90b3fc4e6"}
Did this help?

deleteCoupon( )


Deletes an existing coupon.

The deleteCoupon() function returns a Promise that resolves when the coupon is successfully deleted.

Method Declaration
Copy
function deleteCoupon(couponId: string): Promise<void>;
Method Parameters
couponIdstringRequired

ID of the coupon to delete.

Delete a coupon
JavaScript
import { coupons } from "wix-marketing-backend"; export function deleteCoupon(couponId) { return coupons.deleteCoupon(couponId); } // Returns a promise that is resolved when // the coupon is deleted.
Did this help?