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 *************************************/
4
5import { Permissions, webMethod } from 'wix-web-module';
6import { currentCart } from 'wix-ecom-backend';
7
8export 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 error
16 }
17});
18
19/*************
20 * Page code *
21 ************/
22
23import { myDeleteCurrentCartFunction } from 'backend/my-backend-file.web';
24
25myDeleteCurrentCartFunction()
26 .then(() => {
27 console.log('Success! Deleted current cart');
28 return;
29 })
30 .catch((error) => {
31 console.error(error);
32 // Handle the error
33 });