Search.../

redeemPointsForCoupon( )

Developer Preview

Redeems a customer's loyalty points for a loyalty reward and creates a loyalty coupon.

Description

Creating a loyalty coupon also creates a corresponding "reference" coupon with the Coupons API. The customer receives the reference coupon, which they can apply to their order. The loyalty coupon and its corresponding reference coupon are linked and the loyalty coupon's status reflects the current state of the reference coupon.

Check which loyalty rewards a site has available with List Rewards.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function redeemPointsForCoupon(rewardId: string, options: RedeemPointsForCouponOptions): Promise<RedeemPointsForCouponResponse>

redeemPointsForCoupon Parameters

NAME
TYPE
DESCRIPTION
rewardId
string

ID of the loyalty reward to redeem.

options
RedeemPointsForCouponOptions

Returns

Return Type:

Promise<
RedeemPointsForCouponResponse
>
NAME
TYPE
DESCRIPTION
coupon
LoyaltyCoupon

Created loyalty coupon.

Was this helpful?

redeemPointsForCoupon example

Copy Code
1import { coupons } from 'wix-loyalty.v2';
2
3 async function redeemPointsForCoupon(rewardId, options) {
4 try {
5 const result = await coupons.redeemPointsForCoupon(rewardId, options);
6
7 return result;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12 }
13