Skip to content

How to add Product to Cart with Mutiple custom options using GraphQl?

I have Two custom Options for Downloadable Product

here is my query response for getting product

{
    "data": {
        "products": {
            "items": [
                {
                    "id": 145,
                    "name": "Product Attachments",
                    "sku": "FME_135_M2",
                    "__typename": "DownloadableProduct",
                    "options": [
                        {
                            "title": "Include:",
                            "required": false,
                            "sort_order": 0,
                            "option_id": 127,
                            "checkbox_option": [
                                {
                                    "option_type_id": 272,
                                    "sku": null,
                                    "price": 200,
                                    "price_type": "FIXED",
                                    "title": "3 Months Support",
                                    "sort_order": 1
                                },
                                {
                                    "option_type_id": 273,
                                    "sku": null,
                                    "price": 45,
                                    "price_type": "FIXED",
                                    "title": "Premium Installation",
                                    "sort_order": 2
                                }
                            ]
                        },
                        {
                            "title": "Edition:",
                            "required": true,
                            "sort_order": 1,
                            "option_id": 259,
                            "radio_option": [
                                {
                                    "option_type_id": 263,
                                    "sku": null,
                                    "price": 0,
                                    "price_type": "FIXED",
                                    "title": "Community",
                                    "sort_order": 1
                                },
                                {
                                    "option_type_id": 264,
                                    "sku": null,
                                    "price": 200,
                                    "price_type": "FIXED",
                                    "title": "Enterprise",
                                    "sort_order": 2
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    }
}

For adding into cart i query

mutation {
  addDownloadableProductsToCart(
    input: {
      cart_id: "JTjda91utKM3gzQBkOUTtCZB2EHm8qWU"
      cart_items: {
        data: {
          sku: "FME_135_M2"
          quantity: 1
        }
        downloadable_product_links: [
          {
            link_id: 2091
          }
        ]
        customizable_options: [
        { id: 127
          value_string: "273"
         }
          { id: 127
          value_string: "272"
         }
          { id: 259
          value_string: "263"
         }]   
      }
    }
  ) {
    cart {
      items {
        product {
          id
          sku
          name
        }
        quantity
        ... on DownloadableCartItem {
          links {
            title
            price
          }
          samples {
            title
            sample_url
          }
        }
      }
    }
  }
}

But in the cart it only adds the required options not others ( Check boxes )

enter image description here