Search...
toCart( )
Directs the browser to navigate to the site visitor's cart page.
Description
The toCart()
function navigates the browser to the site visitor's cart page.
Syntax
function toCart(): Promise<void>
toCart Parameters
This function does not take any parameters.
Returns
Fulfilled - When the browser is directed to the site visitor's cart page.
Return Type:
Promise<void>
Was this helpful?
Navigate to the site's cart page
Copy Code
1import { navigate } from 'wix-stores-frontend';23// ...45$w('#myButton').onclick(() => {6 navigate.toCart();7});
Navigate to the site's cart page - error handling
Copy Code
1import { navigate } from 'wix-stores-frontend';23// ...45$w('#myButton').onclick(() => {6 navigate.toCart()7 .then(() => {8 console.log('Navigating to cart...');9 })10 .catch((error) => {11 console.error(error);12 // Handle the error13 });14});