Search.../

activateLoyaltyProgram( )

Developer Preview

Activates a loyalty program.

Description

The activateLoyaltyProgram() function returns a Promise that resolves when the status of the loyalty program is successfully changed to "ACTIVE".

Before you begin, a Wix Loyalty Program must first be installed through your dashboard or through the Wix App Market. Initially when a loyalty program is installed, the status is set to "DRAFT". You can change the program's status to "ACTIVE" with this function or through your dashboard. A site's customers can only earn or redeem points while the program status is "ACTIVE".

This function updates only the status of a loyalty program, to make other updates to the program, use the updateLoyaltyProgram() function.

To temporarily pause your loyalty program you must follow three steps:

  1. Remove all earnPoints() functions and switch off all the "Earn Points" and "Rewards" toggles in the Loyalty Program dashboard.
  2. Hide the loyalty page from your site.
  3. Delete the My Rewards page from the Member pages.

See Pausing Your Loyalty Program for more information.

Note: Only visitors with Manage Loyalty permissions can activate a loyalty program. You can override the permissions with the wix-auth elevate() function.

Admin Method

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

Syntax

function activateLoyaltyProgram(): Promise<ActivateLoyaltyProgramResponse>

activateLoyaltyProgram Parameters

This function does not take any parameters.

Returns

Return Type:

Promise<
ActivateLoyaltyProgramResponse
>
NAME
TYPE
DESCRIPTION
loyaltyProgram
LoyaltyProgram

Activated loyalty program.

Was this helpful?

Activate loyalty program (dashboard page code)

Copy Code
1import { programs } from 'wix-loyalty.v2';
2
3export async function myActivateLoyaltyProgramFunction() {
4
5 const elevatedActivateProgram = wixAuth.elevate(programs.activateLoyaltyProgram)
6
7 try {
8 const myLoyaltyProgram = await elevatedActivateProgram();
9
10 const name = myLoyaltyProgram.loyaltyProgram.name;
11 const status = myLoyaltyProgram.loyaltyProgram.status;
12
13 console.log('Success! The status of your loyalty program is:', status);
14
15 return myLoyaltyProgram;
16 } catch (error) {
17 console.error(error);
18 }
19}
20
21/* Promise resolves to:
22 * {
23 * "loyaltyProgram": {
24 * "name": "Star Loyalty Program",
25 * "pointDefinition": {
26 * "customName": "Stars",
27 * "icon": "shapes/39dce0a5d1ce498f95526b1390eaf585.svg",
28 * },
29 * "status": "ACTIVE",
30 * "_createdDate": "2022-05-22T08:18:32.186Z",
31 * "_updatedDate": "2022-05-25T10:36:32.430Z"
32 * }
33 * }
34 */
35
Activate loyalty program (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { programs } from 'wix-loyalty.v2';
3import { elevate } from 'wix-auth';
4
5export const myActivateLoyaltyProgramFunction = webMethod(Permissions.Anyone, async () => {
6
7 const elevatedActivateProgram = elevate(programs.activateLoyaltyProgram)
8
9 try {
10 const myLoyaltyProgram = await elevatedActivateProgram();
11
12 const name = myLoyaltyProgram.loyaltyProgram.name;
13 const status = myLoyaltyProgram.loyaltyProgram.status;
14
15 console.log('Success! The status of your loyalty program is:', status);
16
17 return myLoyaltyProgram;
18 } catch (error) {
19 console.error(error);
20 }
21});
22
23/* Promise resolves to:
24 * {
25 * "loyaltyProgram": {
26 * "name": "Star Loyalty Program",
27 * "pointDefinition": {
28 * "customName": "Stars",
29 * "icon": "shapes/39dce0a5d1ce498f95526b1390eaf585.svg",
30 * },
31 * "status": "ACTIVE",
32 * "_createdDate": "2022-05-22T08:18:32.186Z",
33 * "_updatedDate": "2022-05-25T10:36:32.430Z"
34 * }
35 * }
36 */
37