queryLoyaltyCoupons( )


Authentication

This function requires elevated permissions and runs only on the backend and on dashboard pages.

Permissions
Read Loyalty
Manage Loyalty
Learn more about app permissions.
Method Declaration
Copy
function queryLoyaltyCoupons(): LoyaltyCouponsQueryBuilder;
Request
This method does not take any parameters
Returns
JavaScript
import { coupons } from "wix-loyalty.v2"; import { webMethod, Permissions } from "wix-web-module"; import { elevate } from "wix-auth"; /* Sample query value: * * { * "query": { * "fieldsets": [], * "fields": [], * "sort": [], * "filter": { * "couponReference.name": { * "$eq": "10% off all events" * }, * "rewardName": { * "$startsWith": "10%" * } * } * } * } */ const elevatedQueryLoyaltyCoupons = elevate(coupons.queryLoyaltyCoupons); export const queryLoyaltyCoupons = webMethod( Permissions.Anyone, async (query) => { try { const result = await elevatedQueryLoyaltyCoupons(query); return result; } catch (error) { console.error(error); // Handle the error } }, ); /* Promise resolves to: * * { * "loyaltyCoupons": [ * { * "_id": "56826083-0c4a-4e62-88e3-c6978482bde9", * "accountId": "d0dc5ba3-4a10-4cfc-b304-c976d8ac7303", * "memberIdDeprecated": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32", * "transactionId": "33490644-0f84-44e4-aa55-738b203fa4bd", * "couponReference": { * "couponId": "a6df2aeb-50fc-4b15-b18d-765be38a6513", * "code": "6QLGQ9RNNR9R", * "name": "10% off all events", * "specification": { * "name": null, * "type": "PERCENT_OFF_RATE", * "limitedToOneItem": false, * "appliesToSubscriptions": null, * "discountedCycleCount": null, * "percentOffRate": 10, * "scope": {"name": "ticket", "entityId": null, "namespace": "events"} * }, * "deleted": null * }, * "status": "ACTIVE", * "rewardName": "10% off all events", * "revision": "2", * "_createdDate": "2024-06-12T08:29:56.594Z", * "_updatedDate": "2024-06-12T08:29:56.851Z", * "memberId": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32" * }, * { * "_id": "6fb2cdc0-863f-4b4b-b76d-a73608654aee", * "accountId": "d0dc5ba3-4a10-4cfc-b304-c976d8ac7303", * "memberIdDeprecated": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32", * "transactionId": "0b24afeb-2964-4bb2-a5ab-b32e04128c20", * "couponReference": { * "couponId": "27d5d44d-eb61-4533-8f72-01177097e470", * "code": "6QLGLVTGVH8A", * "name": "10% off all events", * "specification": { * "name": null, * "type": "PERCENT_OFF_RATE", * "limitedToOneItem": false, * "appliesToSubscriptions": null, * "discountedCycleCount": null, * "percentOffRate": 10, * "scope": {"name": "ticket", "entityId": null, "namespace": "events"} * }, * "deleted": null * }, * "status": "ACTIVE", * "rewardName": "10% off all events", * "revision": "2", * "_createdDate": "2024-06-12T08:14:16.884Z", * "_updatedDate": "2024-06-12T08:14:17.403Z", * "memberId": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32" * } * ] * } */
Errors

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

Did this help?