Setup

@wix/loyalty
Version 1.0.292
Published 3 days ago

To use the Programs API, install the @wix/loyalty package using npm or Yarn:

Copy
npm install @wix/loyalty

or

Copy
yarn add @wix/loyalty

Then import { programs } from @wix/loyalty:

Copy
import { programs } from "@wix/loyalty";
Did this help?

activateLoyaltyProgram( )


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:

  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.

Authentication

You can only call this method when authenticated as a Wix app or Wix user identity.

Permissions
Manage Loyalty
Learn more about app permissions.
Method Declaration
Copy
function activateLoyaltyProgram(): Promise<ActivateLoyaltyProgramResponse>;
Request
This method does not take any parameters
Returns
Return Type:Promise<ActivateLoyaltyProgramResponse>
JavaScript
import { programs } from "@wix/loyalty"; async function activateLoyaltyProgram() { const response = await programs.activateLoyaltyProgram(); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

disablePointsExpiration( )


Updates the pointsExpiration status to DISABLED.

Authentication

You can only call this method when authenticated as a Wix app or Wix user identity.

Permissions
Manage Loyalty
Learn more about app permissions.
Method Declaration
Copy
function disablePointsExpiration(): Promise<DisablePointsExpirationResponse>;
Request
This method does not take any parameters
Returns
Return Type:Promise<DisablePointsExpirationResponse>
JavaScript
import { programs } from "@wix/loyalty"; async function disablePointsExpiration() { const response = await programs.disablePointsExpiration(); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

enablePointsExpiration( )


Updates the pointsExpiration status to ENABLED.

Authentication

You can only call this method when authenticated as a Wix app or Wix user identity.

Permissions
Manage Loyalty
Learn more about app permissions.
Method Declaration
Copy
function enablePointsExpiration(): Promise<EnablePointsExpirationResponse>;
Request
This method does not take any parameters
Returns
Return Type:Promise<EnablePointsExpirationResponse>
JavaScript
import { programs } from "@wix/loyalty"; async function enablePointsExpiration() { const response = await programs.enablePointsExpiration(); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

getLoyaltyProgram( )


Retrieves the site's loyalty program.

The getLoyaltyProgram() function returns a Promise that resolves to the site's loyalty program.

Permissions
Manage Loyalty
Read Loyalty
Learn more about app permissions.
Method Declaration
Copy
function getLoyaltyProgram(): Promise<GetLoyaltyProgramResponse>;
Request
This method does not take any parameters
Returns
Return Type:Promise<GetLoyaltyProgramResponse>
JavaScript
import { programs } from "@wix/loyalty"; async function getLoyaltyProgram() { const response = await programs.getLoyaltyProgram(); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

getLoyaltyProgramPremiumFeatures( )


Developer Preview

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.

Permissions
Manage Loyalty
Read Loyalty
Learn more about app permissions.
Method Declaration
Copy
function getLoyaltyProgramPremiumFeatures(): Promise<GetLoyaltyProgramPremiumFeaturesResponse>;
Request
This method does not take any parameters
Returns
Return Type:Promise<GetLoyaltyProgramPremiumFeaturesResponse>
JavaScript
import { programs } from "@wix/loyalty"; async function getLoyaltyProgramPremiumFeatures() { const response = await programs.getLoyaltyProgramPremiumFeatures(); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

pauseLoyaltyProgram( )


Changes the program status to PAUSED.

Authentication

You can only call this method when authenticated as a Wix app or Wix user identity.

Permissions
Manage Loyalty
Learn more about app permissions.
Method Declaration
Copy
function pauseLoyaltyProgram(): Promise<PauseLoyaltyProgramResponse>;
Request
This method does not take any parameters
Returns
Return Type:Promise<PauseLoyaltyProgramResponse>
JavaScript
import { programs } from "@wix/loyalty"; async function pauseLoyaltyProgram() { const response = await programs.pauseLoyaltyProgram(); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

updateLoyaltyProgram( )


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.

Authentication

You can only call this method when authenticated as a Wix app or Wix user identity.

Permissions
Manage Loyalty
Learn more about app permissions.
Method Declaration
Copy
function updateLoyaltyProgram(
  loyaltyProgram: LoyaltyProgram,
): Promise<UpdateLoyaltyProgramResponse>;
Method Parameters
loyaltyProgramLoyaltyProgramRequired

Loyalty program fields to update.

Returns
Return Type:Promise<UpdateLoyaltyProgramResponse>
JavaScript
import { programs } from "@wix/loyalty"; async function updateLoyaltyProgram(loyaltyProgram) { const response = await programs.updateLoyaltyProgram(loyaltyProgram); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onProgramUpdated( )


Note: This method registers a callback function as an event handler. Subscribe your app to the relevant event via the Webhooks page in the Wix Dev Center to enable it. For more information, see Handle Events With Webhooks.

Triggered when a loyalty program is updated.

Permissions
Manage Loyalty
Read Loyalty
Learn more about app permissions.
Method Declaration
Copy
function onProgramUpdated(handler: function): void;
Method Parameters
handlerfunction

handler(event: ProgramUpdatedEnvelope): void | Promise<void>

JavaScript
import { programs } from "@wix/loyalty"; programs.onProgramUpdated((event) => { // handle your event here });
Did this help?