Retrieves the current site visitor's cart.
The getCurrentCart()
function returns a Promise that resolves when the current cart is retrieved.
function getCurrentCart(): Promise<Cart>;
import { currentCart } from "@wix/ecom";
currentCart
.getCurrentCart()
.then((myCurrentCart) => {
const cartId = myCurrentCart._id;
const cartLineItems = myCurrentCart.lineItems;
console.log("Success! Retrieved myCurrentCart:", myCurrentCart);
return myCurrentCart;
})
.catch((error) => {
console.error(error);
// Handle the error
});
/* Promise resolves to:
* {
* "_id": "295f60d4-6b04-4d53-a48c-24f51953cdc0",
* "_createdDate": "2024-03-07T12:23:18.083Z",
* "_updatedDate": "2024-03-07T12:23:18.083Z",
* "lineItems": [
* {
* "quantity": 1,
* "catalogReference": {
* "catalogItemId": "df19c1f7-07d8-a265-42f8-e8dfa824cc6e",
* "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e",
* "options": {
* "options": {
* "Size": "Medium",
* "Color": "Pink"
* },
* "variantId": "00000000-0000-0000-0000-000000000000"
* }
* },
* "productName": {
* "original": "SWEATSHIRT",
* "translated": "SWEATSHIRT"
* },
* "url": "https://example.wixstudio.io/product-page/sweatshirt",
* "price": {
* "amount": "85",
* "convertedAmount": "85",
* "formattedAmount": "€85.00",
* "formattedConvertedAmount": "€85.00"
* },
* "fullPrice": {
* "amount": "85",
* "convertedAmount": "85",
* "formattedAmount": "€85.00",
* "formattedConvertedAmount": "€85.00"
* },
* "priceBeforeDiscounts": {
* "amount": "85",
* "convertedAmount": "85",
* "formattedAmount": "€85.00",
* "formattedConvertedAmount": "€85.00"
* },
* "descriptionLines": [
* {
* "name": {
* "original": "Color",
* "translated": "Color"
* },
* "colorInfo": {
* "original": "Pink",
* "translated": "Pink",
* "code": "#D50075"
* },
* "lineType": "UNRECOGNISED"
* },
* {
* "name": {
* "original": "Size",
* "translated": "Size"
* },
* "plainText": {
* "original": "Medium",
* "translated": "Medium"
* },
* "lineType": "UNRECOGNISED"
* }
* ],
* "image": "wix:image://v1/c837a6_92b21b13a9534ad9a3874f5d980c0448~mv2.jpg/c837a6_92b21b13a9534ad9a3874f5d980c0448~mv2.jpg#originWidth=2763&originHeight=2772",
* "availability": {
* "status": "AVAILABLE"
* },
* "physicalProperties": {
* "sku": "0001",
* "shippable": true
* },
* "couponScopes": [
* {
* "namespace": "stores",
* "group": {
* "name": "collection",
* "entityId": "00000000-000000-000000-000000000001"
* }
* },
* {
* "namespace": "stores",
* "group": {
* "name": "product",
* "entityId": "df19c1f7-07d8-a265-42f8-e8dfa824cc6e"
* }
* }
* ],
* "itemType": {
* "preset": "PHYSICAL"
* },
* "paymentOption": "FULL_PAYMENT_ONLINE",
* "customLineItem": false,
* "_id": "00000000-0000-0000-0000-000000000001"
* }
* ],
* "buyerInfo": {
* "visitorId": "66886a50-cdec-4774-8568-45d4a3c1f60c"
* },
* "currency": "EUR",
* "conversionCurrency": "EUR",
* "buyerLanguage": "en",
* "siteLanguage": "en",
* "taxIncludedInPrices": false,
* "weightUnit": "KG",
* "subtotal": {
* "amount": "85",
* "convertedAmount": "85",
* "formattedAmount": "€85.00",
* "formattedConvertedAmount": "€85.00"
* },
* "appliedDiscounts": [],
* "contactInfo": {
* "address": {
* "subdivision": "IE-L",
* "country": "IE",
* "postalCode": "D02"
* }
* },
* "purchaseFlowId": "ff848d1d-bc92-4de6-9acc-ad098d866f28"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.