Search.../

clearPrimary( )

Sets all pricing plans to no longer be primary.

Description

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.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function clearPrimary(): Promise<void>

clearPrimary Parameters

This function does not take any parameters.

Returns

Return Type:

Promise<
void
>

Was this helpful?

Clear the primary plan (dashboard page code)

Copy Code
1import { plans } from 'wix-pricing-plans.v2';
2
3export async function myClearPrimaryFunction() {
4 try {
5 const clearedPrimary = await plans.clearPrimary();
6
7 return;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12}
13
14/* Promise resolves to void */
Clear the primary plan (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { plans } from 'wix-pricing-plans.v2';
3import { elevate } from 'wix-auth';
4
5export const myClearPrimaryFunction = webMethod(Permissions.Anyone, async () => {
6 try {
7 const elevatedClearPrimary = elevate(plans.clearPrimary);
8 const clearedPrimary = await elevatedClearPrimary();
9
10 return;
11 } catch (error) {
12 console.error(error);
13 // Handle the error
14 }
15});
16
17/* Promise resolves to void */
18