Search.../

updateLoyaltyProgram( )

Developer Preview

Updates the site's loyalty program.

Description

The updateLoyaltyProgram() function returns a Promise that resolves when the loyalty program is updated.

With the updateLoyaltyProgram() function you can update the name of the loyalty program and the details of the collectible points unit. To activate the loyalty program use the activateLoyaltyProgram() function.

Note: Only visitors with Manage Loyalty permissions can update 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 updateLoyaltyProgram(loyaltyProgram: LoyaltyProgram): Promise<UpdateLoyaltyProgramResponse>

updateLoyaltyProgram Parameters

NAME
TYPE
DESCRIPTION
loyaltyProgram
LoyaltyProgram

Loyalty program fields to update.

Returns

Return Type:

Promise<
UpdateLoyaltyProgramResponse
>
NAME
TYPE
DESCRIPTION
loyaltyProgram
LoyaltyProgram

Updated loyalty program.

Was this helpful?

Update the loyalty program name and the name of its points

Copy Code
1import { programs } from 'wix-loyalty.v2';
2
3/* Sample loyaltyProgram object:
4 * {
5 * name: 'Flower Power Program',
6 * pointDefinition: {
7 * customName: 'Petals'
8 * }
9 * }
10 */
11
12export async function myUpdateLoyaltyProgramFunction(loyaltyProgram) {
13
14 const elevatedUpdateProgram = wixAuth.elevate(programs.updatedLoyaltyProgram)
15
16 try {
17 const updatedLoyaltyProgram = await elevatedUpdateProgram(loyaltyProgram);
18
19 const newName = updatedLoyaltyProgram.loyaltyProgram.name;
20 const newPointsName = updatedLoyaltyProgram.loyaltyProgram.pointDefinition.customName;
21
22 console.log('Success! The names of your loyalty program and its points are now: ', newName, newPointsName);
23
24 return updatedLoyaltyProgram;
25 } catch (error) {
26 console.error(error);
27 }
28}
29
30/* Promise resolves to:
31 * {
32 * "loyaltyProgram": {
33 * "name": "Flower Power Program",
34 * "pointDefinition": {
35 * "customName": "Petals",
36 * "icon": "shapes/8de38e8fe76f4e9f937ae23e9ba1eb04.svg"
37 * },
38 * "status": "ACTIVE",
39 * "_createdDate": "2022-11-07T15:26:12.798Z",
40 * "_updatedDate": "2022-11-09T10:07:08.601Z"
41 * }
42 * }
43 */
44