> 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

> **Deprecated.** This method is deprecated. Planned removal date: 2025-01-01.

# Method name: addProducts(products: Array<AddToCartItem>)

# Method package: wixStoresFrontend

# Method menu location: wixStoresFrontend --> Cart --> addProducts

# Method Link: https://dev.wix.com/docs/velo/apis/wix-stores-frontend/cart/add-products.md

# Method Description:

**Deprecated.**
This function will continue to work, but a newer version is available at
[`wix-ecom-backend.currentCart.addToCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/add-to-current-cart.md).

> #### Migration Instructions
>
> If this function is already in your code, it will continue to work.
> To stay compatible with future changes, migrate to
> [`wix-ecom-backend.currentCart.addToCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/add-to-current-cart.md).
>
> To migrate to the new function:
>
> 1. Add the new import statement:
>
>    ```javascript
>    import { currentCart } from "wix-ecom-backend";
>    ```
>
> 2. Look for any code that uses `cart.addProducts()`,
>    and replace it with `currentCart.addToCurrentCart()`.
>    Update your code to work with the new `currentCart.addToCurrentCart()` call and response properties.
>
>    To help with updating your code to work with the new `currentCart.addToCurrentCart()` properties, learn more about [integrating Wix Stores with the Wix eCommerce](https://dev.wix.com/docs/velo/api-reference/wix-stores-backend/e-commerce-integration.md).
>
> 3. Test your changes to make sure your code behaves as expected.

 Adds one or more products to the cart.

 The `addProducts()` function returns a Promise that is resolved when the
 specified products are added to the cart.

 Use the `quantity` property of each `AddToCartItem` object that is
 passed to the products parameter to add one or more products to the cart at one time.

 Use the `options` property of each `AddToCartItem` object that is
 passed to the products parameter to specify the product options to choose when adding
 the product to the cart. For example, if a product comes in different sizes, you can
 specify the size that should be added to the cart. If the product you are adding to the
 cart has options, you must specify which options should be chosen.

 You can see a product's option information in the `productOptions` field in the **Stores/Products** collection.

 You can use [`product.getOptionsAvailability()`](https://www.wix.com/velo/reference/wix-stores-frontend/product/getoptionsavailability)
 to determine if an item with specific options is available for purchase.

> **Note:** If you use [`wix-stores-backend.createProduct()`](https://www.wix.com/velo/reference/wix-stores-backend/createproduct) immediately before adding that product to the cart, we suggest [setting a timeout](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout) for `"1000"` milliseconds (1 second) before calling `cart.addProducts()`. While this slows down the operation slightly, it also ensures proper retrieval of the newly created product before adding it to the cart.



# Method Code Examples:

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

## Add products to the cart

```javascript
import { cart } from 'wix-stores-frontend';

const products = [
  {
    "productId": "0873ed58-f88d-77d1-4566-afd4c50d253e",
    "quantity": 3
  },
  {
    "productId": "91f7ac8b-2baa-289c-aa50-6d64764f35d3",
    "quantity": 1,
    "options": {
      "choices": {
        "Weight": "250g",
        "Ground for": "Filter"
      }
    }
  },
  {
    "productId": "5376f9ec-b92e-efa9-e4a1-f4f480aa0d3a",
    "quantity": 1,
    "options": {
      "choices": {
        "Weight": "500g",
        "Ground for": "Stovetop"
      },
      "customTextFields": [{
        "title": "Custom package sticker",
        "value": "Enjoy your coffee!"
      }]
    }
  }
]

cart.addProducts(products)
  .then((updatedCart) => {
    // Products added to cart
    const cartId = updatedCart._id;
    const cartLineItems = updatedCart.lineItems;
  })
  .catch((error) => {
    // Products not added to cart
    console.error(error);
  });


/* Example of returned updatedCart object:
 *
 *  {
 *    "_id": "5d54aa6f-f653-4bed-8c34-7f1373f88c89",
 *    "status": "INCOMPLETE",
 *    "billingAddress": {
 *      "firstName": "Jane",
 *      "lastName": "Doe",
 *      "email": "",
 *      "phone": "+1234567890",
 *      "company": "undefined",
 *      "vatId": "undefined",
 *      "address": "235 West 23rd Street\nNew York, New York 10011\nUnited States"
 *    },
 *    "appliedCoupon": "null",
 *    "buyerInfo": {
 *      "email": "",
 *      "firstName": "Jane",
 *      "identityType": "ADMIN",
 *      "lastName": "Doe",
 *      "phone": "+1234567890"
 *    },
 *    "buyerNote": "undefined",
 *    "currency": {
 *      "symbol": "$",
 *      "code": "USD"
 *    },
 *    "lineItems": [
 *      {
 *        "id": 16,
 *        "productId": "0873ed58-f88d-77d1-4566-afd4c50d253e",
 *        "name": "Digital product",
 *        "quantity": 3,
 *        "lineItemType": "DIGITAL",
 *        "customTextFields": [],
 *        "options": [],
 *        "price": 20,
 *        "totalPrice": 60,
 *        "mediaItem": "null",
 *        "weight": 0
 *      },
 *      {
 *        "id": 17,
 *        "productId": "91f7ac8b-2baa-289c-aa50-6d64764f35d3",
 *        "name": "Colombian Arabica",
 *        "quantity": 1,
 *        "weight": 0.25,
 *        "sku": "10003",
 *        "lineItemType": "PHYSICAL",
 *        "customTextFields": [],
 *        "mediaItem": {
 *          "src": "wix:image://v1/nsplsh_5033504669385448625573~mv2_d_6000_3376_s_4_2.jpg/file.jpg#originWidth=6000&originHeight=3376",
 *          "type": "IMAGE"
 *        },
 *        "options": [
 *          {
 *            "option": "Weight",
 *            "selection": "250g"
 *          },
 *          {
 *            "option": "Ground for",
 *            "selection": "Filter"
 *          }
 *        ],
 *        "price": 35,
 *        "totalPrice": 35
 *      },
 *      {
 *        "id": 18,
 *        "productId": "5376f9ec-b92e-efa9-e4a1-f4f480aa0d3a",
 *        "name": "Indonesian Blend",
 *        "quantity": 1,
 *        "lineItemType": "PHYSICAL",
 *        "customTextFields": [
 *          {
 *            "title": "Custom package sticker",
 *            "value": "Enjoy your coffee!"
 *          }
 *        ],
 *        "mediaItem": {
 *          "src": "wix:image://v1/nsplsh_316b6449475f3235386255~mv2_d_2977_3951_s_4_2.jpg/file.jpg#originWidth=2977&originHeight=3951",
 *          "type": "IMAGE"
 *        },
 *        "options": [
 *          {
 *            "option": "Weight",
 *            "selection": "500g"
 *          },
 *          {
 *            "option": "Ground for",
 *            "selection": "Stovetop"
 *          }
 *        ],
 *        "price": 35,
 *        "totalPrice": 35,
 *        "weight": 0
 *      }
 *    ],
 *    "shippingInfo": {
 *      "shippingAddress": {
 *        "firstName": "Jane",
 *        "lastName": "Doe",
 *        "email": "",
 *        "phone": "+1234567890",
 *        "company": "undefined",
 *        "vatId": "undefined",
 *        "address": "235 West 23rd Street\nNew York, New York 10011\nUnited States"
 *      }
 *    },
 *    "totals": {
 *      "discount": 0,
 *      "quantity": 5,
 *      "shipping": 0,
 *      "subtotal": 160,
 *      "tax": 0,
 *      "total": 160,
 *      "weight": 0.75
 *    },
 *    "weightUnit": "KG"
 *  }
 *
 */
```

---