1

I'm having a problem adding a product with custom options in the Magento cart 2.3.1.

After defining a custom option as multiple selection, I tried to add the product to the cart with the following request:

POST /V1/carts/mine/items

JSON:
{"cartItem": 
    {
    "sku": "Big Lanche-1", 
    "qty": 1,
    "product_type":"simple",
    "quote_id": "631",
        "product_option": {
            "extension_attributes": {
                "custom_options": [
                    {
                        "option_id": "23",
                        "option_value": "106,107"
                    }
                ]
            }
        }
    }
}

However, the error is returned when sending a request:

{
    "message": "The product's required option(s) weren't entered. Make sure the options are entered and try again."
}

So I tried to make the following request:

POST /V1/carts/mine/items

JSON:
{"cartItem": 
    {
    "sku": "Big Lanche-1", 
    "qty": 1,
    "product_type":"simple",
    "quote_id": "631",
        "product_option": {
            "extension_attributes": {
                "custom_options": [
                    {
                        "option_id": "23",
                        "option_value": "[106,107]"
                    }
                ]
            }
        }
    }
}

Where I added brackets and the request was accepted. However, the sum of the values ​​of the custom options in the quote does not occur, that is, it remains as if they were not applied.

Can anyone tell me what is the correct way to do this request?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.