redeemCurrentMemberPointsForCoupon( )


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

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.

Method Declaration
Copy
function redeemCurrentMemberPointsForCoupon(
  rewardId: string,
): Promise<RedeemCurrentMemberPointsForCouponResponse>;
Method Parameters
rewardIdstringRequired

ID of the loyalty reward to redeem.

Returns
Return Type:Promise<RedeemCurrentMemberPointsForCouponResponse>
JavaScript
import { coupons } from "wix-loyalty.v2"; import { webMethod, Permissions } from "wix-web-module"; /* Sample rewardId value: * * { * "rewardId": "00000000-0000-0000-0003-000000000000" * } */ export const redeemCurrentMemberPointsForCoupon = webMethod( Permissions.Anyone, async (rewardId) => { try { const result = await coupons.redeemCurrentMemberPointsForCoupon(rewardId); return result; } catch (error) { console.error(error); // Handle the error } }, ); /* Promise resolves to: * * { * "coupon": { * "_createdDate": "2024-06-12T08:26:33.148Z", * "_id": "87c95680-55ea-4baa-936c-c4bab711fbf3", * "_updatedDate": "2024-06-12T08:26:33.148Z", * "accountId": "d0dc5ba3-4a10-4cfc-b304-c976d8ac7303", * "couponReference": { * "code": "6QLGPJTXXR58", * "couponId": "638950a0-ed55-4d47-8bc4-7145d56fe568", * "name": "10% off all events", * "specification": { * "type": "PERCENT_OFF_RATE", * "percentOffRate": 10, * "scope": { * "name": "ticket", * "namespace": "events" * }, * "limitedToOneItem": false * } * }, * "memberId": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32", * "memberIdDeprecated": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32", * "revision": "1", * "rewardName": "10% off all events", * "status": "PENDING" * }, * "transactionId": "2d558a56-0794-420a-81c4-49a96f1d5d9f" * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?