Search.../

onBuyNow( )

Adds an event handler that runs when the Buy Now button on the Product Page is clicked.

Description

This function is currently only available for Wix Studio sites.

The onBuyNow() function adds an event handler that runs when a site visitor clicks the Buy Now button on the Product Page.

The event handler has 2 functions:

  • The cancel() function stops a site visitor from proceeding with the Wix Checkout process.
  • The resume() function allows a site visitor to proceed with the Wix Checkout process.

Syntax

function onBuyNow(buyNowEventHandler: buyNowEventHandler): Promise<void>
buyNowEventHandler: function buyNowEventHandler(resume: Function, cancel: Function): void

onBuyNow Parameters

NAME
TYPE
DESCRIPTION
buyNowEventHandler

The function to run when the Buy Now button on the Product Page is clicked.

Returns

Return Type:

Promise<void>

buyNowEventHandler Parameters

NAME
TYPE
DESCRIPTION
resume
Function

A function that resumes the Wix Checkout process. This function doesn't take any parameters.

cancel
Function

A function that cancels the Wix Checkout process. This function doesn't take any parameters.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

Resume Wix Checkout process when Buy Now button is clicked

Copy Code
1$w('#myProductPage').onBuyNow((resume, cancel) => {
2 console.log('Resume the Wix Checkout process.');
3 // custom code
4 resume();
5});
Cancel Wix Checkout process when Buy Now button is clicked

Copy Code
1$w('#myProductPage').onBuyNow((resume, cancel) => {
2 console.log('Cancel the Wix Checkout process.');
3 // custom code
4 cancel();
5});