updateCouponFields( )
Updates the specified fields of an existing coupon.
Description
The updateCouponFields()
function returns a Promise that resolves when the
coupon is successfully updated.
Only the properties passed in the CouponInfo
object will
be updated. All other properties will remain the same.
To remove a value from the coupon, pass its corresponding property with a value
of null
.
When updating a coupon, you cannot change the coupon's type. For example,
if the coupon's type is moneyOffAmount
, you cannot change it to fixedPriceAmount
.
You can update the coupon type's value. For example, you can change the
value of moneyOffAmount
from 5
to 10
.
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:
namespace | group | entityId | Result |
---|---|---|---|
stores | -- | -- | Applies to all store products |
stores | product | product ID | Applies to the specific store product with the provided ID |
stores | collection | collection ID | Applies to the specific store collection with the provided ID |
bookings | -- | -- | Applies to all bookings services |
bookings | service | service ID | Applies to the specific bookings service with the provided ID |
events | event | event ID | Applies to the specific event with the provided ID |
events | ticket | -- | Applies to all event tickets |
events | ticket | ticket ID | Applies to the specific event ticket with the provided ID |
pricingPlans | -- | -- | Applies to all pricing plans |
pricingPlans | plan | plan ID | Applies to the specific pricing plan with the provided ID |
Syntax
function updateCouponFields(couponId: string, couponInfo: CouponInfo): Promise<void>
updateCouponFields Parameters
NAME
TYPE
DESCRIPTION
ID of the coupon to update.
The information to update the coupon with.
Returns
Fulfilled - When the coupon is updated.
Return Type:
Was this helpful?
1import { coupons } from 'wix-marketing-backend';23export function updateCouponFields(couponId, couponInfo) {4 return coupons.updateCouponFields(couponId, couponInfo);5}67// Returns a promise that is resolved when8// the coupon is updated.
1import { coupons } from 'wix-marketing-backend';23export function updateCouponFields() {4 let couponId = "bff1f257-5e7e-437d-9f86-098de337cae6";56 let newExpirationDate = new Date();7 newExpirationDate.setMonth(newExpirationDate.getMonth() + 1);89 let couponInfo = {10 "expirationTime": newExpirationDate // Coupon ends in 1 month11 };1213 return coupons.updateCouponFields(couponId, couponInfo);14}1516// Returns a promise that is resolved when17// the coupon is updated.