Search...
getLoyaltyProgram( )
Developer Preview
Retrieves the site's loyalty program.
Description
The getLoyaltyProgram()
function returns a Promise that resolves to the site's loyalty program.
Syntax
function getLoyaltyProgram(): Promise<GetLoyaltyProgramResponse>
getLoyaltyProgram Parameters
This function does not take any parameters.
Returns
Return Type:
Promise<
GetLoyaltyProgramResponse
>NAME
TYPE
DESCRIPTION
loyaltyProgram
LoyaltyProgram
Retrieved loyalty program.
Was this helpful?
Get loyalty program
Copy Code
1import { programs } from 'wix-loyalty.v2';23export async function myGetLoyaltyProgramFunction() {4 try {5 const myLoyaltyProgram = await programs.getLoyaltyProgram();67 const name = myLoyaltyProgram.loyaltyProgram.name;8 const status = myLoyaltyProgram.loyaltyProgram.status;910 console.log('Success! The status of your loyalty program is:', status);11 return myLoyaltyProgram;12 } catch (error) {13 console.error(error);14 }15}1617/* Promise resolves to:18 * {19 * "loyaltyProgram": {20 * "name": "Frequent Flower Program",21 * "pointDefinition": {22 * "customName": "Petals",23 * "icon": "shapes/8de38e8fe76f4e9f937ae23e9ba1eb04.svg"24 * },25 * "status": "ACTIVE",26 * "_createdDate": "2022-11-07T15:26:12.798Z",27 * "_updatedDate": "2022-11-09T10:00:42.018Z"28 * }29 * }30 */31
Get loyalty program (export from backend code)
Copy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { programs } from 'wix-loyalty.v2';34export const myGetLoyaltyProgramFunction = webMethod(Permissions.Anyone, async () => {5 try {6 const myLoyaltyProgram = await programs.getLoyaltyProgram();78 const name = myLoyaltyProgram.loyaltyProgram.name;9 const status = myLoyaltyProgram.loyaltyProgram.status;1011 console.log('Success! The status of your loyalty program is:', status);12 return myLoyaltyProgram;13 } catch (error) {14 console.error(error);15 }16});1718/* Promise resolves to:19 * {20 * "loyaltyProgram": {21 * "name": "Frequent Flower Program",22 * "pointDefinition": {23 * "customName": "Petals",24 * "icon": "shapes/8de38e8fe76f4e9f937ae23e9ba1eb04.svg"25 * },26 * "status": "ACTIVE",27 * "_createdDate": "2022-11-07T15:26:12.798Z",28 * "_updatedDate": "2022-11-09T10:00:42.018Z"29 * }30 * }31 */32