Skip to content

Adding bundle product to cart using rest API facing issue

Below is my rest API,

if the last child item option qty is greater than 1, for example 2 then the bundle quantity added to cart is 2. Below is my API request

{
    "cartItem": {
        "qty": 1,
        "quoteId": "99264",
        "sku": "testbund2",
        "product_option": {
            "extension_attributes": {
                "bundle_options": [
                    {
                        "option_id": 9,
                        "option_qty": 1,
                        "option_selections": [
                            17
                        ]
                    },
                    {
                        "option_id": 10,
                        "option_qty": 1,
                        "option_selections": [
                            18
                        ]
                    },
                    {
                        "option_id": 11,
                        "option_qty": 2,
                        "option_selections": [
                            19
                        ]
                    }
                ]
            }
        }
    }
}

The response I get is below:

{
    "item_id": 86590,
    "sku": "testbund2",
    "qty": 2,
    "name": "Bundle product 2",
    "price": 4705,
    "product_type": "bundle",
    "quote_id": "99264",
    "product_option": {
        "extension_attributes": {
            "bundle_options": [
                {
                    "option_id": 9,
                    "option_qty": 1,
                    "option_selections": [
                        17
                    ]
                },
                {
                    "option_id": 10,
                    "option_qty": 1,
                    "option_selections": [
                        18
                    ]
                },
                {
                    "option_id": 11,
                    "option_qty": 2,
                    "option_selections": [
                        19
                    ]
                }
            ]
        }
    }
}

But If I set default child qty to 1 for last child,
The response looks ok.

Request with last child qty as 1 is:

{
    "cartItem": {
        "qty": 1,
        "quoteId": "99264",
        "sku": "testbund2",
        "product_option": {
            "extension_attributes": {
                "bundle_options": [
                    {
                        "option_id": 9,
                        "option_qty": 1,
                        "option_selections": [
                            17
                        ]
                    },
                    {
                        "option_id": 12,
                        "option_qty": 1,
                        "option_selections": [
                            23
                        ]
                    }
                ]
            }
        }
    }
}

Response is

{
    "item_id": 86669,
    "sku": "testbund2",
    "qty": 1,
    "name": "Bundle product 2",
    "price": 2100,
    "product_type": "bundle",
    "quote_id": "99264",
    "product_option": {
        "extension_attributes": {
            "bundle_options": [
                {
                    "option_id": 9,
                    "option_qty": 1,
                    "option_selections": [
                        17
                    ]
                },
                {
                    "option_id": 12,
                    "option_qty": 1,
                    "option_selections": [
                        23
                    ]
                }
            ]
        }
    }
}

Can anyone help me what is the issue. I checked and disabled all the custom plugins and observer related to this. But still issue exists. I a trying to fix this for last 2-3 days.