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.
Authorization
Request
This endpoint does not take any parameters
Response Object
Fulfilled - When the browser is directed to the site visitor's cart page.
Returns an empty object.
Status/Error Codes
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});