You can now use the `applyCoupon()` function to apply a coupon code to a draft order before it is purchased. To learn more about coupons, see the createCoupon() function and this article.
top of page
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
bottom of page
Can you give me a suggestion how I can make a coupon only for one billing circle not lifetime circle? what I should adding to the code? thanks a lot
exportfunctionmyCreateCoupon(discount,code){
//let couponecode = Math.trunc(Math.random() * 1000).toString() +"E"+Math.trunc(Math.random() * 1000000).toString()
let couponInfo = {
"name": "MyCoupon",
"code": code,
"startTime": new Date(),
"expirationTime": new Date(new Date().getTime() + 24 * 60 * 60 * 1000 * 90),
"usageLimit": 1,
"limitedToOneItem": true,
"limitPerCustomer": 1,
"active": true,
"scope": { // Coupon applies to all pricing plans
"namespace": "pricingPlans"
},
"percentOffRate": discount,
}
// return {"id":coupons.createCoupon(couponInfo),"code":couponInfo.code};
return coupons.createCoupon(couponInfo);
}