1

I have problems with adding products to the cart by REST Api, if the product has custom options and the option is of the "checkbox" type. I tried as below, but then only one "checkbox" is added, not two.

{
    "item_id": 111
    "sku": "sku",
    "qty": 1,
    "name": "name",
    "price": 159,
    "product_type": "simple",
    "quote_id": "1111",
    "product_option": {
        "extension_attributes": {
            "custom_options": [
                {
                    "option_id": 1,
                    "option_value": 1
                },
                {
                    "option_id": 1,
                    "option_value": 2
                }
            ]
        }
    }
}

I also tried:

{
    "item_id": 111
    "sku": "sku",
    "qty": 1,
    "name": "name",
    "price": 159,
    "product_type": "simple",
    "quote_id": "1111",
    "product_option": {
        "extension_attributes": {
            "custom_options": [
                {
                    "option_id": 1,
                    "option_value": [1,2]
                }
            ]
        }
    }
}

But the above produces validation errors.

1 Answer 1

0

I use cartId. Before adding a product to the cart, I create it using API route POST /V1/guest-carts. After that, I get cartId from the response and use it for all requests to cart endpoints. So it's not a solution.

Also when I try to add a product with a customizable option radio everything works

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.