Using the eCommerce frontend API, you can interact with the native cart and checkout components on your site.
With the eCommerce frontend API, you can:
To use the eCommerce frontend API, import wixEcomFrontend
from the wix-ecom-frontend
module:
It's important to note the following points before starting to code:
You need to add eCommerce functionality to your site.
Upgrade your site to a premium business plan in order to accept payments.
Directs the browser to navigate to the site visitor's Cart Page.
The navigateToCartPage()
function returns a Promise that resolves when the browser successfully navigates to the Cart Page.
Directs the browser to navigate to the site visitor's Checkout Page.
The navigateToCheckoutPage()
function returns a Promise that resolves when the browser successfully navigates to the Checkout Page.
Note: The checkoutId
parameter is required. To get a checkoutId
, use one of the following wix-ecom-backend
functions:
ID of the checkout to navigate to.
Additional parameters for customizing the checkout flow.
Adds an event handler that runs when the cart changes.
The event handler set by the onCartChange()
function runs when the cart changes.
The onCartChange()
event handler is triggered when:
refreshCart()
function is called.Important: Actions performed by Velo functions other than the refreshCart()
function do not trigger the onCartChange()
event handler.
handler(): void
The name of the function or the function expression to run when the cart is changed.
Opens the Side Cart panel.
The openSideCart()
function opens the Side Cart panel on the current page.
Notes:
openSideCart()
will work on mobile.function openSideCart(): void;
import wixEcomFrontend from "wix-ecom-frontend";
$w("#myOpenSideCartButton").onClick(() => {
// on button click - open the side cart
wixEcomFrontend.openSideCart();
});