Search.../

onAddToCart( )

Adds an event handler that runs when the Add To Cart button on the Product Page is clicked.

Description

This function is currently only available for Wix Studio sites.

The onAddToCart() function adds an event handler that runs when a site visitor clicks the Add To Cart 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.

Authorization

Request

This endpoint does not take any parameters

Response Object

Returns an empty object.

Status/Error Codes

Was this helpful?

Resume Wix Checkout process when Add To Cart button is clicked

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

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