Search.../

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:

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

Syntax

function updateCouponFields(couponId: string, couponInfo: CouponInfo): Promise<void>

updateCouponFields Parameters

NAME
TYPE
DESCRIPTION
couponId
string

ID of the coupon to update.

couponInfo
CouponInfo

The information to update the coupon with.

Returns

Fulfilled - When the coupon is updated.

Return Type:

Promise<void>

Was this helpful?

Update an existing coupon

Copy Code
1import { coupons } from 'wix-marketing-backend';
2
3export function updateCouponFields(couponId, couponInfo) {
4 return coupons.updateCouponFields(couponId, couponInfo);
5}
6
7// Returns a promise that is resolved when
8// the coupon is updated.
Update a coupon's expiration date

Copy Code
1import { coupons } from 'wix-marketing-backend';
2
3export function updateCouponFields() {
4 let couponId = "bff1f257-5e7e-437d-9f86-098de337cae6";
5
6 let newExpirationDate = new Date();
7 newExpirationDate.setMonth(newExpirationDate.getMonth() + 1);
8
9 let couponInfo = {
10 "expirationTime": newExpirationDate // Coupon ends in 1 month
11 };
12
13 return coupons.updateCouponFields(couponId, couponInfo);
14}
15
16// Returns a promise that is resolved when
17// the coupon is updated.