cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 - Cannot add product with customizable options into cart with soap API

SOLVED

Magento 2 - Cannot add product with customizable options into cart with soap API

I created a customizable option of type field in the product and now I can not add this product in the cart by api


api endpoint:  /carts/{{quote_id}}/items

{
  "cartItem": {
    "sku": "830406000000",
    "qty": 1,
    "quote_id": "3",
    "options": [
    	{
	        "key": "1",
    		"value": "test"
    	}
    ]
  }
}

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: Magento 2 - Cannot add product with customizable options into cart with soap API

Hello @kimvieira 

 

parameters: {
    "cart_item": {
        "quote_id": "9",
        "sku": "24-MB01",
        "qty": 1,
        "productOption":{
            "extensionAttributes":{
                "customOptions":[
                    {
                        "optionId":"1",
                        "optionValue":"2"
                    }
                    ]
            }
        }
    }
}

please check with above input.

If works then mark as solution.

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

View solution in original post

Re: Magento 2 - Cannot add product with customizable options into cart with soap API

Hello @kimvieira 

 

get /V1/products/{sku}/options 


by using above api you will get all options for that sku.

 

More info:

https://magento.stackexchange.com/questions/146095/can-i-retrieve-product-custom-options-with-magent...

if help you then mark as solution.


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

View solution in original post

6 REPLIES 6

Re: Magento 2 - Cannot add product with customizable options into cart with soap API

Hello @kimvieira 

 

parameters: {
    "cart_item": {
        "quote_id": "9",
        "sku": "24-MB01",
        "qty": 1,
        "productOption":{
            "extensionAttributes":{
                "customOptions":[
                    {
                        "optionId":"1",
                        "optionValue":"2"
                    }
                    ]
            }
        }
    }
}

please check with above input.

If works then mark as solution.

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Magento 2 - Cannot add product with customizable options into cart with soap API

can i use optionLabel or optionTitle instead of optionId?
I need to create the same option on other products. each product will have a different id, right?

Re: Magento 2 - Cannot add product with customizable options into cart with soap API

Hello @kimvieira 

 

you can not use same option title. you must need to create custom option each product, you need to first retrieve it using api and then you need to pass option id.

 

Hope it will help you.

 

if help you then mark as a solution, so it will helpful to others.

 

cheers Smiley Happy 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Magento 2 - Cannot add product with customizable options into cart with soap API

in case I would have, for example, 3 products with the same customizable option ("custom_text" for example). who to call the api does not know the id of the attribute, but would know the name. understood. is it possible for api to get the id of the attribute using the label?

Re: Magento 2 - Cannot add product with customizable options into cart with soap API

Hello @kimvieira 

 

get /V1/products/{sku}/options 


by using above api you will get all options for that sku.

 

More info:

https://magento.stackexchange.com/questions/146095/can-i-retrieve-product-custom-options-with-magent...

if help you then mark as solution.


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Magento 2 - Cannot add product with customizable options into cart with soap API

tks