Search...
deleteCart( )
Deletes a cart.
Description
The deleteCart()
function returns a Promise that resolves when the specified cart is deleted.
Syntax
function deleteCart(_id: string): Promise<void>
deleteCart Parameters
NAME
TYPE
DESCRIPTION
_id
string
ID of the cart to delete.
Returns
Fulfilled - When the cart is deleted. Rejected - Error message.
Return Type:
Promise<
void
>Was this helpful?
Delete a cart
Copy Code
1/**************************************2 * Backend code - my-backend-file.web.js *3 *************************************/45import { Permissions, webMethod } from 'wix-web-module';6import { cart } from 'wix-ecom-backend';78export const myDeleteCartFunction = webMethod(Permissions.Anyone, async (cartId) => {9 try {10 await cart.deleteCart(cartId);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 { myDeleteCartFunction } from 'backend/my-backend-file.web';2425// Sample cartId:26const cartId = '96a61a4b-6b61-47d1-a039-0213a8230ccd';2728myDeleteCartFunction(cartId)29 .then(() => {30 console.log('Success! Deleted cart');31 return;32 })33 .catch((error) => {34 console.error(error);35 // Handle the error36 });