deleteCart( )


Deletes a cart.

The deleteCart() function returns a Promise that resolves when the specified cart is deleted.

Permissions
Manage eCommerce - all permissions
Manage Stores - all permissions
Manage Restaurants - all permissions
Learn more about app permissions.
Method Declaration
Copy
function deleteCart(_id: string): Promise<void>;
Method Parameters
_idstringRequired

ID of the cart to delete.

Delete a cart
JavaScript
/************************************** * Backend code - my-backend-file.web.js * *************************************/ import { Permissions, webMethod } from "wix-web-module"; import { cart } from "wix-ecom-backend"; export const myDeleteCartFunction = webMethod( Permissions.Anyone, async (cartId) => { try { await cart.deleteCart(cartId); console.log("Success! Deleted cart"); return; } catch (error) { console.error(error); // Handle the error } }, ); /************* * Page code * ************/ import { myDeleteCartFunction } from "backend/my-backend-file.web"; // Sample cartId: const cartId = "96a61a4b-6b61-47d1-a039-0213a8230ccd"; myDeleteCartFunction(cartId) .then(() => { console.log("Success! Deleted cart"); return; }) .catch((error) => { console.error(error); // Handle the error });
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?