Search...
deleteCurrentCart( )
Deletes the current site visitor's cart.
Description
The deleteCurrentCart()
function returns a Promise that resolves when the current cart is deleted.
Syntax
function deleteCurrentCart(): Promise<void>
deleteCurrentCart Parameters
This function does not take any parameters.
Returns
Fulfilled - When the current cart is deleted. Rejected - Error message.
Return Type:
Promise<
void
>Was this helpful?
Delete the current site visitor's cart
Copy Code
1/**************************************2 * Backend code - my-backend-file.web.js *3 *************************************/45import { Permissions, webMethod } from 'wix-web-module';6import { currentCart } from 'wix-ecom-backend';78export const myDeleteCurrentCartFunction = webMethod(Permissions.Anyone, async () => {9 try {10 await currentCart.deleteCurrentCart();11 console.log('Success! Deleted cart');12 return;13 } catch (error) {14 console.error(error);15 // Handle the error16 }17});1819/*************20 * Page code *21 ************/2223import { myDeleteCurrentCartFunction } from 'backend/my-backend-file.web';2425myDeleteCurrentCartFunction()26 .then(() => {27 console.log('Success! Deleted current cart');28 return;29 })30 .catch((error) => {31 console.error(error);32 // Handle the error33 });