Search.../

getCurrentCart( )

Gets the current site visitor's shopping cart.

Description

The getCurrentCart() function returns a Promise that resolves to the current site visitor's shopping cart.

Note: When editing a site as a collaborator, getCurrentCart() will only work when viewing the live site.

Syntax

function getCurrentCart(): Promise<Cart>

getCurrentCart Parameters

This function does not take any parameters.

Returns

Fulfilled - The retrieved cart.

Return Type:

Promise<Cart>
NAME
TYPE
DESCRIPTION
_id

string

Unique identifier of the shopping cart.

appliedCoupon

CartAppliedCoupon

Coupon applied in the shopping cart.

billingAddress

CartAddress

Cart billing address.

buyerInfo

CartBuyerInfo

The buyer's information.

status

string

Cart status. Either "INCOMPLETE" or "COMPLETE".

currency

Currency

Currency of the shopping cart.

shippingInfo

CartShippingInfo

The shopping cart's shipping information.

lineItems

Array<CartLineItem>

Items in the shopping cart.

totals

OrderTotals

The shopping cart's totals.

weightUnit

string

The order's units of weight. One of: "KG", "LB", or "UNSPECIFIED_WEIGHT_UNIT".

Was this helpful?

Get the current site visitor's cart

Code Example

Copy Code
1import wixStores from 'wix-stores';
2
3wixStores.getCurrentCart()
4 .then((cartData) => {
5 let cartId = cartData._id;
6 let cartLineItems = cartData.lineItems;
7 })
8 .catch((error) => {
9 console.log(error);
10 });
11
12/* Returned promise resolves to:
13*
14* {
15* "_id": "b36eb035-635a-450e-b74d-acf86ee4dfcc",
16* "appliedCoupon": {
17* "couponId": "e81e9c48-f954-4044-ba64-ccfe5c103c8f",
18* "name": "Summer Sale",
19* "code": "SummerSale",
20* "discountValue": "$10.00",
21* "couponType": "MoneyOff"
22* },
23* "billingAddress": {
24* "firstName": "John",
25* "lastName": "Doe",
26* "email":"john.doe@somedomain.com",
27* "phone":"5555555",
28* "address":"235 West 23rd Street\nNew York, New York 10011\nUnited States"
29* },
30* "buyerNote": "This is a note from the buyer.",
31* "buyerInfo":{
32* "firstName": "John",
33* "lastName": "Doe",
34* "email": "john.doe@somedomain.com",
35* "phone": "5555555555",
36* "identityType": "CONTACT"
37* },
38* "status": "INCOMPLETE",
39* "currency": {
40* "code": "USD",
41* "symbol": "$"
42* },
43* "shippingInfo": {
44* "deliveryOption": "Free Shipping",
45* "shippingAddress": {
46* "firstName": "John",
47* "lastName": "Doe",
48* "email":"john.doe@somedomain.com",
49* "phone":"5555555",
50* "address":"235 West 23rd Street\nNew York, New York 10011\nUnited States"
51* },
52* "pickupDetails":null
53* },
54* "lineItems":[
55* {
56* "quantity": 1,
57* "price": 120,
58* "name": "A product",
59* "productId": "a668ef33-f5b8-6569-d04c-1d123be68441",
60* "totalPrice": 120,
61* "lineItemType": "PHYSICAL",
62* "customTextFields": [
63* "title": "Custom Field",
64* "value": "Custom value"
65* ],
66* "mediaItem": {
67* "src": "wix:image://v1/a9ff3b_ed3b544c319b4fad9c222c791a997832.jpg/file.jpg#originWidth=1000&originHeight=1000",
68* "type": "IMAGE"
69* },
70* "sku": "21554345656",
71* "options": [ ],
72* "weight": 3,
73* "id": 1
74* },
75* {
76* "quantity": 1,
77* "price": 25,
78* "name": "Another product",
79* "productId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09",
80* "totalPrice": 25,
81* "lineItemType": "PHYSICAL",
82* "mediaItem": {
83* "src": "wix:image://v1/a9ff3b_c6158b4d41784ae8b08337a331e1de7f.jpg/file.jpg#originWidth=1000&originHeight=1000",
84* "type": "IMAGE"
85* },
86* "sku": "217537123517253",
87* "options": [
88* {
89* "option": "Size",
90* "selection": "Medium"
91* },
92* {
93* "option": "Color",
94* "selection": "Black"
95* }
96* ],
97* "weight": 2,
98* "id": 2
99* }
100* ],
101* "totals": {
102* "discount": 0,
103* "quantity": 2,
104* "shipping": 0,
105* "subtotal": 145,
106* "tax": 0,
107* "total": 145,
108* "weight": 5
109* },
110* "weightUnit": "LB"
111* }
112*/