> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# Method name: addToCurrentCart(options: AddToCurrentCartOptions)

# Method package: wixEcomBackend

# Method menu location: wixEcomBackend --> currentCart --> addToCurrentCart

# Method Link: https://dev.wix.com/docs/velo/apis/wix-ecom-backend/current-cart/add-to-current-cart.md

# Method Description:

Adds catalog line items to the current site visitor's cart.

>**Notes:**
>+ When adding catalog line items, the `lineItems.catalogReference.appId` and `lineItems.catalogReference.catalogItemId` fields are required.
>+ This method requires [visitor or member authentication](https://dev.wix.com/docs/rest/articles/getting-started/access-types-and-permissions.md).
>+ After a cart is updated, call [Refresh Cart](https://dev.wix.com/docs/velo/apis/wix-ecom-frontend/refresh-cart.md) to update the cart's UI elements and trigger the Cart Updated event.



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Add a Wix Stores product to the current cart 

```javascript
/*****************************************
 * Backend code - my-backend-file.web.js *
 *****************************************/

import { Permissions, webMethod } from 'wix-web-module';
import { currentCart } from 'wix-ecom-backend';

export const myAddToCurrentCartFunction = webMethod(Permissions.Anyone, async (options) => {
  try {
    const updatedCurrentCart = await currentCart.addToCurrentCart(options);
    console.log('Success! Updated current cart:', updatedCurrentCart);
    return updatedCurrentCart;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
});

/*************
 * Page code *
 *************/

import wixEcomFrontend from 'wix-ecom-frontend';
import { myAddToCurrentCartFunction } from 'backend/my-backend-file.web';

// Sample options object:
const options = {
  "lineItems": [{
    "catalogReference": {
      // Wix Stores appId
      "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e",
      // Wix Stores productId
      "catalogItemId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09",
      "options": {
        // Wix Stores variantId
        "variantId": "132b84e8-aab8-47a1-a1f6-2c47557b64a4"
      }
    },
    "quantity": 1
  }]
};

const updatedCurrentCart = await myAddToCurrentCartFunction(options);

// Refresh the cart after adding item.
await wixEcomFrontend.refreshCart();

// Navigate to the cart page.
await wixEcomFrontend.navigateToCartPage();

/* Updated cart:
 *
 * {
 *   "_id": "e4156539-32b8-48dd-97f8-164b5a5b8740",
 *   "lineItems": [
 *     {
 *       "_id": "00000000-0000-0000-0000-000000000001",
 *       "quantity": 1,
 *       "catalogReference": {
 *         "catalogItemId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09",
 *         "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e",
 *         "options": {
 *           "variantId": "132b84e8-aab8-47a1-a1f6-2c47557b64a4"
 *         }
 *       },
 *       "productName": {
 *         "original": "Watch",
 *         "translated": "Watch"
 *       },
 *       "url": "https://example.wixsite.com",
 *       "price": {
 *         "amount": "30",
 *         "convertedAmount": "30",
 *         "formattedAmount": "€30.00",
 *         "formattedConvertedAmount": "€30.00"
 *       },
 *       "fullPrice": {
 *         "amount": "30",
 *         "convertedAmount": "30",
 *         "formattedAmount": "€30.00",
 *         "formattedConvertedAmount": "€30.00"
 *       },
 *       "priceBeforeDiscounts": {
 *         "amount": "30",
 *         "convertedAmount": "30",
 *         "formattedAmount": "€30.00",
 *         "formattedConvertedAmount": "€30.00"
 *       },
 *       "descriptionLines": [
 *         {
 *           "name": {
 *             "original": "Size",
 *             "translated": "Size"
 *           },
 *           "plainText": {
 *             "original": "Medium",
 *             "translated": "Medium"
 *           },
 *           "lineType": "UNRECOGNISED"
 *         },
 *         {
 *           "name": {
 *             "original": "Color",
 *             "translated": "Color"
 *           },
 *           "colorInfo": {
 *             "original": "Grey",
 *             "translated": "Grey",
 *             "code": "rgb(128, 128, 128)"
 *           },
 *           "lineType": "UNRECOGNISED"
 *         }
 *       ],
 *       "image": "wix:image://v1/3c76e2_8891bbe3372a428aac976ac59aa0ac74~mv2.jpg#originWidth=1000&originHeight=1000",
 *       "availability": {
 *         "status": "AVAILABLE"
 *       },
 *       "physicalProperties": {
 *         "sku": "217537123517253",
 *         "shippable": true
 *       },
 *       "couponScopes": [
 *         {
 *           "namespace": "stores",
 *           "group": {
 *             "name": "collection",
 *             "entityId": "00000000-000000-000000-000000000001"
 *           }
 *         },
 *         {
 *           "namespace": "stores",
 *           "group": {
 *             "name": "product",
 *             "entityId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09"
 *           }
 *         }
 *       ],
 *       "itemType": {
 *         "preset": "PHYSICAL"
 *       },
 *       "paymentOption": "FULL_PAYMENT_ONLINE"
 *     }
 *   ],
 *   "buyerInfo": {
 *     "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873"
 *   },
 *   "currency": "EUR",
 *   "conversionCurrency": "EUR",
 *   "buyerLanguage": "en",
 *   "siteLanguage": "en",
 *   "taxIncludedInPrices": false,
 *   "weightUnit": "KG",
 *   "subtotal": {
 *     "amount": "30",
 *     "convertedAmount": "30",
 *     "formattedAmount": "€30.00",
 *     "formattedConvertedAmount": "€30.00"
 *   },
 *   "appliedDiscounts": [],
 *   "inSync": false,
 *   "_createdDate": "2022-05-23T13:17:46.801Z",
 *   "_updatedDate": "2022-05-23T13:17:46.801Z"
 * }
 *
 */
```

---