> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # DeleteCart # Package: purchaseFlow # Namespace: CartService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/purchase-flow/cart/delete-cart.md ## Permission Scopes: Manage eCommerce - all permissions: SCOPE.DC-ECOM-MEGA.MANAGE-ECOM ## Introduction Deletes a cart. --- ## REST API ### Schema ``` Method: deleteCart Description: Deletes a cart. URL: https://www.wixapis.com/ecom/v1/carts/{id} Method: DELETE # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: id Method parameters: param name: id | type: none | required: true Return type: DeleteCartResponse EMPTY-OBJECT {} ``` ### Examples ### Delete a Cart ```curl curl -X DELETE \ 'https://www.wixapis.com/ecom/v1/carts/f97a2939-b1f3-41f2-9fc5-7ecea2060991' \ -H 'Authorization: ' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.purchaseFlow.CartService.deleteCart(_id) Description: Deletes a cart. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: _id Method parameters: param name: _id | type: string | description: GUID of the cart to delete. | required: true Return type: PROMISE EMPTY-OBJECT {} ``` ### Examples ### Delete a cart ```javascript /************************************** * Backend code - my-backend-file.web.js/ts * *************************************/ import { Permissions, webMethod } from '@wix/web-methods'; import { cart } from '@wix/ecom'; 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 }); ``` ### deleteCart (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { cart } from '@wix/ecom'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { cart }, // Include the auth strategy and host as relevant }); async function deleteCart(_id) { const response = await myWixClient.cart.deleteCart(_id); }; ``` ---