The Pricing Plans Plans API allows you to manage your pricing plans.
With the Pricing Plans Plans API, you can:
To use the Pricing Plans Plans API, import { plans }
from the wix-pricing-plans.v2
module.
Archives a single plan.
The archivePlan()
function returns a Promise that resolves to the newly-archived plan.
When a plan is archived, the plan
public
property is automatically set to false
.Plan archiving does not impact existing purchases made for the plan. All purchases for the plan are still active and keep their payment options and terms.
Site owners can see archived plans in the Dashboard under Pricing Plans -> Archived Plans.
Note: An attempt to archive an already-archived plan throws an error.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
ID of the active plan to archive.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Sets all pricing plans to no longer be primary.
The clearPrimary()
function returns a Promise that is resolved when there are no pricing plans marked as primary
.
After clearing the primary plan, when viewing pricing plans on the site, no plan is highlighted with a customizable ribbon.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Creates a pricing plan.
The createPlan()
function returns a Promise that resolves to a newly-created pricing plan after is has successfully been created.
The passed plan
object must contain a pricing model. A pricing model can be one of the following:
Pricing plans created by this function are available to the site owner in the Pricing Plans section in the Dashboard.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
Information for the plan being created.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Retrieves a pricing plan by the specified ID.
The getPlan()
function returns a Promise that resolves to a plan whose ID matched the specified ID.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
Plan ID.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Retrieves statistics about the pricing plans.
The getPlanStats()
function returns a Promise that resolves to statistics about the plan on the site.
Currently this function provides only the total number of pricing plans, including archived plans.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
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 a list of pricing plans.
The listPlans()
function returns a Promise that resolves to a list of up to 100 pricing plans. This includes public, hidden, and archived plans.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
Options for filtering and paging the list of plans.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Retrieves a list of public pricing plans.
The listPublicPlans()
function returns a Promise that resolves to a list of up to 100 public pricing plans. Public plans are visible plans that site visitors can see on the site and purchase.
Options for filtering and paging the list of public plans.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Marks a pricing plan as the primary pricing plan.
The makePlanPrimary()
function returns a Promise that resolves to the now primary pricing plan.
Only a single plan can be marked as a primary plan at any given time. If there is an existing plan marked as primary, calling makePlanPrimary()
causes the existing primary plan to lose its primary status.
When viewing pricing plans on the site, the primary plan is highlighted with a customizable ribbon.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
ID of the pricing plan to set as the primary plan.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Creates a query to retrieve a list of public pricing plans.
The queryPublicPlans()
function builds a query to retrieve a list of up to 1,000 public plans and returns a PublicPlansQueryBuilder
object.
The returned object contains the query definition which is typically used to run the query using the find()
function.
You can refine the query by chaining PublicPlansQueryBuilder
functions onto the query. PublicPlansQueryBuilder
functions enable you to sort, filter, and control the results that queryPublicPlans()
returns.
queryPublicPlans()
runs with the following PublicPlansQueryBuilder
defaults that you can override:
The functions that are chained to queryPublicPlans()
are applied in the order they are called. For example, if you sort on the _createdDate
property in ascending order and then on the _id
property in ascending order, the results are sorted first by the created date of the items and then, if there are multiple results with the same date, the items are sorted by _id
in ascending order, per created date value.
The following PublicPlansQueryBuilder
functions are supported for the queryPublicPlans()
function. For a full description of the Plans object, see the object returned for the items
property in PublicPlansQueryResult
.
PROPERTY | SUPPORTED FILTERS & SORTING |
---|---|
_id | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() ,ascending() ,descending() |
primary | eq() ,ne() ,exists() ,in() ,hasSome() ,ascending() ,descending() |
_createdDate | eq() ,ne() ,exists() ,in() ,hasSome() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
_updatedDate | eq() ,ne() ,exists() ,in() ,hasSome() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
slug | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() ,ascending() ,descending() |
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Sets visibility for non-archived pricing plans.
The setPlanVisibility()
functions returns a Promise that resolves to a pricing plan when its visibility has successfully been set.
By default, pricing plans are public, meaning they are visible. Plans can be hidden so that site members and visitors cannot see or choose them.
As opposed to archiving, setting visibility can be reversed. This means that a public plan can be hidden, and a hidden plan can be made public (visible).
Note: An archived plan always remains archived and cannot be made active again. When archiving a plan, its public
property is automatically set to false
so that it is hidden.
Changing a plan's visibility does not impact existing orders for the plan. All orders for hidden plans are still active and keep their terms and payment options.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
The ID of the plan to either display or hide on the site page.
Whether to set the plan as visible.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Updates a pricing plan.
The updatePlan()
function returns a Promise that resolves to an updated plan.
Updating a plan does not impact existing purchases made for the plan. All purchases keep the details of the original plan that was active at the time of the purchase.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
ID of the plan to update.
Options for updating the plan.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.