You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{ "summary": "The `wix-ecom-frontend` module contains functionality for working with eCommerce elements from client-side code.",
10
+
"description":
11
+
[ "Using the eCommerce frontend API, you can interact with the native cart and checkout components on your site.",
12
+
"",
13
+
" With the eCommerce frontend API, you can:",
14
+
" + Refresh the cart to display its latest state.",
15
+
" + Listen to changes in the native cart components.",
16
+
" + Open the Side Cart panel.",
17
+
" + Navigate to the [Cart Page](https://support.wix.com/en/article/customizing-the-cart-page).",
18
+
" + Navigate to the [Checkout Page](https://support.wix.com/en/article/customizing-the-checkout-page).",
19
+
"",
20
+
" To use the eCommerce frontend API, import `wixEcomFrontend` from the `wix-ecom-frontend` module:",
21
+
"",
22
+
" ```javascript",
23
+
" import wixEcomFrontend from 'wix-ecom-frontend';",
24
+
" ```",
25
+
"",
26
+
" ## Before you begin",
27
+
"",
28
+
" It's important to note the following points before starting to code:",
29
+
"",
30
+
" + You need to [add eCommerce functionality to your site](https://dev.wix.com/docs/rest/business-solutions/e-commerce/wix-e-commerce-platform-handbook/get-started/wix-site-creators-velo-developers-add-e-commerce-functionality-to-a-site).",
31
+
"",
32
+
" + Upgrade your site to a premium business plan in order to [accept payments](https://support.wix.com/en/article/accepting-payments-an-overview).",
33
+
"",
34
+
" ## Terminology",
35
+
"",
36
+
" + **Cart**: Holds information about a potential transaction, including details about selected items, prices, and discounts, as well as the potential buyer.",
37
+
" + **Side Cart**: A preview of the cart page, which opens as a panel on the side of a page.",
38
+
" + **Cart Page**: A page where a buyer can view and manage the items in their cart.",
39
+
" + **Checkout Page**: A page where a buyer finalizes a purchase. Each checkout holds information about the items to be purchased, price and tax summaries, shipping and billing information, any applied discounts, and more." ],
40
+
"links": [],
41
+
"examples": [],
42
+
"extra":
43
+
{ } },
44
+
"properties": [],
45
+
"operations":
46
+
[ { "name": "navigateToCartPage",
47
+
"labels": [],
48
+
"nameParams": [],
49
+
"params": [],
50
+
"ret":
51
+
{ "type":
52
+
{ "name": "Promise",
53
+
"typeParams":
54
+
[ "void" ] },
55
+
"doc": "Fulfilled - When the navigation is complete." },
56
+
"locations":
57
+
[ { "lineno": 70,
58
+
"filename": "wixEcomFrontend.js" } ],
59
+
"docs":
60
+
{ "summary": "Directs the browser to navigate to the site visitor's Cart Page.",
61
+
"description":
62
+
[ "The `navigateToCartPage()` function returns a Promise that resolves when the browser successfully navigates to the [Cart Page](https://support.wix.com/en/article/customizing-the-cart-page)." ],
63
+
"links": [],
64
+
"examples":
65
+
[ { "title": "Navigate to the cart page",
66
+
"body":
67
+
[ "import wixEcomFrontend from 'wix-ecom-frontend';",
"doc": "Additional parameters for customizing the checkout flow.",
113
+
"optional": true } ],
114
+
"ret":
115
+
{ "type":
116
+
{ "name": "Promise",
117
+
"typeParams":
118
+
[ "void" ] },
119
+
"doc": "Fulfilled - When the navigation is complete." },
120
+
"locations":
121
+
[ { "lineno": 82,
122
+
"filename": "wixEcomFrontend.js" } ],
123
+
"docs":
124
+
{ "summary": "Directs the browser to navigate to the site visitor's Checkout Page.",
125
+
"description":
126
+
[ "The `navigateToCheckoutPage()` function returns a Promise that resolves when the browser successfully navigates to the [Checkout Page](https://support.wix.com/en/article/customizing-the-checkout-page).",
127
+
"",
128
+
"> **Note:** The `checkoutId` parameter is **required**. To get a `checkoutId`, use one of the following `wix-ecom-backend` functions:",
"doc": "The name of the function or the function expression to run when the cart is changed." } ],
172
+
"ret":
173
+
{ "type": "void" },
174
+
"locations":
175
+
[ { "lineno": 120,
176
+
"filename": "wixEcomFrontend.js" } ],
177
+
"docs":
178
+
{ "summary": "Adds an event handler that runs when the cart changes.",
179
+
"description":
180
+
[ "The event handler set by the `onCartChange()` function runs when the cart changes.",
181
+
"",
182
+
"The `onCartChange()` event handler is triggered when:",
183
+
"+ The cart is modified by native UI elements such as the 'Add to Cart' button, increase (+) and decrease (-) item quantity buttons, remove line item button (x), etc.",
184
+
"+ The [`refreshCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-frontend/refresh-cart) function is called.",
185
+
"",
186
+
"<blockquote class=\"important\">",
187
+
"",
188
+
"**Important:** Actions performed by Velo functions other than the `refreshCart()` function do not trigger the `onCartChange()` event handler.",
189
+
"",
190
+
"</blockquote>" ],
191
+
"links": [],
192
+
"examples":
193
+
[ { "title": "Add an event handler for cart changes",
194
+
"body":
195
+
[ "import wixEcomFrontend from 'wix-ecom-frontend';",
196
+
"import wixEcomBackend from 'wix-ecom-backend';",
197
+
"",
198
+
"$w.onReady(function () {",
199
+
"",
200
+
" // handler function that gets the current cart on cart change",
201
+
" const handler = () => {",
202
+
" wixEcomBackend.currentCart.getCurrentCart()",
203
+
" .then(cart => {",
204
+
" let cartId = cart._id;",
205
+
" console.log('cart ID: ', cartId);",
206
+
" })",
207
+
" .catch(error => {",
208
+
" console.error(error);",
209
+
" // Handle the error",
210
+
" });",
211
+
" };",
212
+
"",
213
+
" wixEcomFrontend.onCartChange(handler);",
214
+
"});" ],
215
+
"extra":
216
+
{ } } ],
217
+
"extra":
218
+
{ } },
219
+
"extra":
220
+
{ } },
221
+
{ "name": "openSideCart",
222
+
"labels": [],
223
+
"nameParams": [],
224
+
"params": [],
225
+
"ret":
226
+
{ "type": "void" },
227
+
"locations":
228
+
[ { "lineno": 54,
229
+
"filename": "wixEcomFrontend.js" } ],
230
+
"docs":
231
+
{ "summary": "Opens the Side Cart panel.",
232
+
"description":
233
+
[ "The `openSideCart()` function opens the Side Cart panel on the current page.",
234
+
"",
235
+
"> **Notes:**",
236
+
"> + We are gradually replacing the existing [Mini Cart](https://support.wix.com/en/article/customizing-the-mini-cart) with the new Side Cart panel.",
237
+
"> + This function will fail when viewing the site on mobile because there is no Mini Cart on the mobile site.",
238
+
"> + The new Side Cart works on mobile sites. When Side Cart functionality becomes available for your site, `openSideCart()` will work on mobile." ],
239
+
"links": [],
240
+
"examples":
241
+
[ { "title": "Open the Side Cart",
242
+
"body":
243
+
[ "import wixEcomFrontend from 'wix-ecom-frontend';",
244
+
"",
245
+
"$w('#myOpenSideCartButton').onClick(() => {",
246
+
" // on button click - open the side cart",
247
+
" wixEcomFrontend.openSideCart();",
248
+
"});" ],
249
+
"extra":
250
+
{ } } ],
251
+
"extra":
252
+
{ } },
253
+
"extra":
254
+
{ } },
255
+
{ "name": "refreshCart",
256
+
"labels": [],
257
+
"nameParams": [],
258
+
"params": [],
259
+
"ret":
260
+
{ "type":
261
+
{ "name": "Promise",
262
+
"typeParams":
263
+
[ "void" ] },
264
+
"doc": "Fulfilled - When the cart refresh is complete." },
265
+
"locations":
266
+
[ { "lineno": 40,
267
+
"filename": "wixEcomFrontend.js" } ],
268
+
"docs":
269
+
{ "summary": "Updates cart UI elements, like the [Cart Icon](https://support.wix.com/en/article/customizing-the-cart-icon) and Side Cart with the most recent cart data.",
270
+
"description":
271
+
[ "The `refreshCart()` function returns a Promise that resolves when the latest cart data is retrieved, and the cart UI elements are refreshed.",
272
+
"",
273
+
"> **Note:** Calling the `refreshCart()` function will trigger the [`onCartChange()`](/wix-ecom-frontend/on-cart-change) event handler." ],
274
+
"links": [],
275
+
"examples":
276
+
[ { "title": "Refresh the cart",
277
+
"body":
278
+
[ "import wixEcomFrontend from 'wix-ecom-frontend';",
"doc": "Whether to skip the delivery details step in checkout. For example, if the product is for pick-up only.\n\nDefault: `false`" },
372
+
{ "name": "hideContinueBrowsingButton",
373
+
"type": "boolean",
374
+
"doc": "Whether to hide the [\"Continue Browsing\"](https://support.wix.com/en/article/customizing-links-on-your-cart-page#customizing-the-continue-browsing-links) button from top-right-hand corner of the Checkout Page.\n\nDefault: `false`" },
375
+
{ "name": "overrideContinueBrowsingUrl",
376
+
"type": "string",
377
+
"doc": "URL to replace the default \"Continue Browsing\" URL. For example, if you'd like to redirect the customer to your own custom page." },
378
+
{ "name": "overrideThankYouPageUrl",
379
+
"type": "string",
380
+
"doc": "URL to replace the default [Thank You Page](https://support.wix.com/en/article/customizing-the-thank-you-page) URL.\n\nPass `{orderId}` (not the order ID itself) as a parameter to the URL to dynamically insert the order ID. See the example on the right for more information." } ],
0 commit comments