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 (dashboard page code)
Copy Code
1import { programs } from 'wix-loyalty.v2';23/* Sample loyaltyProgram object:4 * {5 * name: 'Flower Power Program',6 * pointDefinition: {7 * customName: 'Petals'8 * }9 * }10 */1112export async function myUpdateLoyaltyProgramFunction(loyaltyProgram) {1314 const elevatedUpdateProgram = wixAuth.elevate(programs.updatedLoyaltyProgram)1516 try {17 const updatedLoyaltyProgram = await elevatedUpdateProgram(loyaltyProgram);1819 const newName = updatedLoyaltyProgram.loyaltyProgram.name;20 const newPointsName = updatedLoyaltyProgram.loyaltyProgram.pointDefinition.customName;2122 console.log('Success! The names of your loyalty program and its points are now: ', newName, newPointsName);2324 return updatedLoyaltyProgram;25 } catch (error) {26 console.error(error);27 }28}2930/* 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
Update the loyalty program name and the name of its points (export from backend code)
Copy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { programs } from 'wix-loyalty.v2';3import { elevate } from 'wix-auth';45/* Sample loyaltyProgram object:6 * {7 * name: 'Flower Power Program',8 * pointDefinition: {9 * customName: 'Petals'10 * }11 * }12 */1314export const myUpdateLoyaltyProgramFunction = webMethod(Permissions.Anyone, async (loyaltyProgram) => {1516 const elevatedUpdateProgram = elevate(programs.updatedLoyaltyProgram)1718 try {19 const updatedLoyaltyProgram = await elevatedUpdateProgram(loyaltyProgram);2021 const newName = updatedLoyaltyProgram.loyaltyProgram.name;22 const newPointsName = updatedLoyaltyProgram.loyaltyProgram.pointDefinition.customName;2324 console.log('Success! The names of your loyalty program and its points are now: ', newName, newPointsName);2526 return updatedLoyaltyProgram;27 } catch (error) {28 console.error(error);29 }30});3132/* Promise resolves to:33 * {34 * "loyaltyProgram": {35 * "name": "Flower Power Program",36 * "pointDefinition": {37 * "customName": "Petals",38 * "icon": "shapes/8de38e8fe76f4e9f937ae23e9ba1eb04.svg"39 * },40 * "status": "ACTIVE",41 * "_createdDate": "2022-11-07T15:26:12.798Z",42 * "_updatedDate": "2022-11-09T10:07:08.601Z"43 * }44 * }45 */46