To use the Programs API, install the @wix/loyalty
package using npm or Yarn:
npm install @wix/loyalty
or
yarn add @wix/loyalty
Then import { programs }
from @wix/loyalty
:
import { programs } from "@wix/loyalty";
Activates a loyalty program.
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:
earnPoints()
functions and switch off all the "Earn Points" and "Rewards" toggles in the Loyalty Program dashboard.Note: Only visitors with Manage Loyalty permissions can activate a loyalty program. You can override the permissions with the wix-auth
elevate()
function.
You can only call this method when authenticated as a Wix app or Wix user identity.
function activateLoyaltyProgram(): Promise<ActivateLoyaltyProgramResponse>;
import { programs } from "@wix/loyalty";
async function activateLoyaltyProgram() {
const response = await programs.activateLoyaltyProgram();
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Updates the pointsExpiration
status to DISABLED
.
You can only call this method when authenticated as a Wix app or Wix user identity.
function disablePointsExpiration(): Promise<DisablePointsExpirationResponse>;
import { programs } from "@wix/loyalty";
async function disablePointsExpiration() {
const response = await programs.disablePointsExpiration();
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Updates the pointsExpiration
status to ENABLED
.
You can only call this method when authenticated as a Wix app or Wix user identity.
function enablePointsExpiration(): Promise<EnablePointsExpirationResponse>;
import { programs } from "@wix/loyalty";
async function enablePointsExpiration() {
const response = await programs.enablePointsExpiration();
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Retrieves the site's loyalty program.
The getLoyaltyProgram()
function returns a Promise that resolves to the site's loyalty program.
function getLoyaltyProgram(): Promise<GetLoyaltyProgramResponse>;
import { programs } from "@wix/loyalty";
async function getLoyaltyProgram() {
const response = await programs.getLoyaltyProgram();
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves information about the available loyalty program premium features.
function getLoyaltyProgramPremiumFeatures(): Promise<GetLoyaltyProgramPremiumFeaturesResponse>;
import { programs } from "@wix/loyalty";
async function getLoyaltyProgramPremiumFeatures() {
const response = await programs.getLoyaltyProgramPremiumFeatures();
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Changes the program status to PAUSED
.
You can only call this method when authenticated as a Wix app or Wix user identity.
function pauseLoyaltyProgram(): Promise<PauseLoyaltyProgramResponse>;
import { programs } from "@wix/loyalty";
async function pauseLoyaltyProgram() {
const response = await programs.pauseLoyaltyProgram();
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Updates the site's loyalty program.
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.
You can only call this method when authenticated as a Wix app or Wix user identity.
function updateLoyaltyProgram(
loyaltyProgram: LoyaltyProgram,
): Promise<UpdateLoyaltyProgramResponse>;
Loyalty program fields to update.
import { programs } from "@wix/loyalty";
async function updateLoyaltyProgram(loyaltyProgram) {
const response = await programs.updateLoyaltyProgram(loyaltyProgram);
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Triggered when a loyalty program is updated.
function onProgramUpdated(handler: function): void;
handler(event: ProgramUpdatedEnvelope): void | Promise<void>
import { programs } from "@wix/loyalty";
programs.onProgramUpdated((event) => {
// handle your event here
});