Use the Custom Purchase Flow API to customize the pages in the plan purchase flow on your site. This API provides functionality for directing users to the Plans & Pricing and Checkout pages outside of the default flow. It also allows you to customize the content displayed on the Plan & Pricing, Checkout, and Thank You pages.
To use APIs to customize the plan purchase flow, first set up pricing plans on your site:
Accept payments as described in About Accepting Payments.
Offer membership plans as described in About Pricing Plans. When setting up your site to accept pricing plans, define the plans you want to offer using the Dashboard or using the Pricing Plan APIs.
The Custom Purchase Flow API lets you direct customers to either of two pages in the plan purchase flow:
You can use the navigateToPricingPage()
and navigateToCheckout()
functions to customize
pages in the plan purchase flow:
navigateToPricingPage()
. In the same function you can also pass options to customize the content
on the Checkout and Thank You pages.navigateToCheckout()
function, you can pass options to customize the
content displayed on the Checkout and Thank You pages.getPricingPageOptions()
on the Plans & Pricing page to
retrieve the Pricing page options you set in navigateToPricingPage()
.You can now add custom pages to the pricing plan flow, as well as build a custom Plans & Pricing page.
If you add pages between Plans & Pricing and Checkout, you will need to store the options set in navigateToPricingPage()
globally, for example using the Wix Storage API,
and access them before you call navigateToCheckout()
.
If you are navigating directly from the Plans & Pricing page to Checkout, you can
call getPricingPageOptions()
and pass the retrieved options directly to navigateToCheckout()
.
To use the CustomPurchaseFlow API, import customPurchaseFlow
from the wix-pricing-plans-frontend
module.
Returns the options set for the current Plans & Pricing page.
The getPricingPageOptions()
function retrieves the options set for the Plans & Pricing Page in navigateToPricingPage()
.
The returned PricingPageOptions
object also includes any options set for the Checkout and Thank You pages.
Call this function in the page code of a default or custom Plans & Pricing page. If you need to pass the returned pricing page
options to navigateToCheckout()
at a later point, store the options object globally so you can access it later.
Note:
Directs site visitor to the Checkout page in the plan purchase flow.
The navigateToCheckout()
function redirects the site visitor to the Checkout page from any other page on your site. It also provides
options to customize the Checkout and Thank You pages that come later in the plan purchase flow.
Note that the use of navigateToCheckout()
will differ slightly depending on whether you use the default Plans & Pricing page or a custom one:
navigateToCheckout()
from there, but
you may still call it from any other page in your site.navigateToCheckout()
on the plans page as well as anywhere else on your
site.Notes:
minStartDate
and maxStartDate
parameters will have no effect unless you've allowed customers
to set the plan start date.
Options to customize the Checkout page and subsequent flow.
Directs site visitor to the Pricing & Plans page in the plan purchase flow.
The navigateToPricingPage()
function directs the site visitor to the active Plans & Pricing page from any other page on your site.
It also provides options to customize the Checkout and Thank You pages that come later in the plan purchase flow. This allows you to
customize each of the pages in the flow with a single function call.
Notes:
minStartDate
and maxStartDate
parameters will have no effect unless you've allowed customers
to set the plan start date.function navigateToPricingPage(options: PricingPageOptions): void;
Options to customize the Plans & Pricing page and subsequent flow.
import { customPurchaseFlow } from "wix-pricing-plans-frontend";
/* Sample pricingPageOpts value:
{
planIds: ['fedb93e3-623a-487b-a47d-499f48ee3c7d', '4c68d55d-e8fa-4008-af40-35cca6d39741'],
checkout: {
thankYouPage: {
content: 'Thank you for your purchase!',
},
},
}*/
$w.onReady(() => {
$w("#button").onClick(() => {
customPurchaseFlow.navigateToPricingPage(pricingPageOpts);
});
});