3

I need to add product in cart using magento 2 api.

I am using below api

"rest/V1/guest-carts/{cart_id}/items

I am passing parameters like below,

    {
    "cartItem": {
        "sku": "paneer_chilli-1",
        "qty": "1",
        "name": "Paneer Chilli",
        "price": 100,
        "product_type": "simple",
        "quote_id": "3a43e2fc1ed26db195a8ceee00929bcb",
        "product_option": {
            "extension_attributes": {
                "custom_options": [{
                    "option_id": 6,
                    "option_value": 2
                }]
            }
        }
    }
}

dosent work, it is giving error like below,

Property "CustomOptions" does not have corresponding setter in class "Magento\Quote\Api\Data\CartItemExtensionInterface".

What is option_id and option_value in my case when I have to pass custom option with multiple option with its price (checkbox)

It will be great if someone can help. Thanks

0

Go to http://devdocs.magento.com/swagger/ > quoteGuestCartItemRepositoryV1

In your case, should change to underscore format

{
    "cartItem": {
        "quote_id": {cart id},
        "sku": {sku},
        "qty": 1,
        "product_option":{
            "extension_attributes":{
                "custom_options":[
                    {
                        "option_id":"1",
                        "option_value":"2"
                    }
                    ]
            }
        }
    }
}
  • Hey, Thanks for you reply, but now it is giving, "Please specify product's required option(s)." i am updating my latest json object in question, it will be great of you can suggest something. – Anand Jan 21 '17 at 15:17
  • The values and option id should match exactly. Please check the options present to the product by using SKU than you can place exact values which makes move forward from above error – Sairam Sigirisetty Sep 16 '18 at 3:34

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.