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.jsw *
3 *************************************/
4
5import { currentCart } from 'wix-ecom-backend';
6
7export async function myDeleteCurrentCartFunction() {
8 try {
9 await currentCart.deleteCurrentCart();
10 console.log('Success! Deleted cart');
11 return;
12 } catch (error) {
13 console.error(error);
14 // Handle the error
15 }
16}
17
18/*************
19 * Page code *
20 ************/
21
22import { myDeleteCurrentCartFunction } from 'backend/my-backend-file';
23
24myDeleteCurrentCartFunction()
25 .then(() => {
26 console.log('Success! Deleted current cart');
27 return;
28 })
29 .catch((error) => {
30 console.error(error);
31 // Handle the error
32 });
33