Magento2: Can't add product to cart with customizable options (type checkbox) through REST API

Created on 24 Jul 2019  路  12Comments  路  Source: magento/magento2

Preconditions (*)

  1. Magento version: 2.3.1
  2. PHP version: 7.2.12

Steps to reproduce (*)

  1. Try to add product to guest cart using API endpoint: POST /V1/guest-carts/{cartId}/items
    Body:
{
    "cartItem": {
        "sku": "sku",
        "qty": 1,
        "quote_id": "quoteId",
        "product_option": {
            "extension_attributes": {
                "custom_options": [
                    {
                        "option_id": "12",
                        "option_value": "20,21,22"
                    }
                ]
            }
        }
    }
}

Expected result (*)

  1. Product added to cart

Actual result (*)

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

Error thrown from:
https://github.com/magento/magento2/blob/2.3.1/app/code/Magento/Catalog/Model/Product/Option/Type/Select.php#L77

Potentially this commit 64ee8e9 broke functionality, because if change 0 to 1 as it was before this fix, everything works. Product added to the cart

Catalog Fixed in 2.3.x Confirmed Format is valid PR Created Reproduced on 2.3.x

Most helpful comment

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

Also when I try to add product with customizable option radio everything works. So, please, check again

All 12 comments

Hi @gekamikh. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@gekamikh do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

Hi @Den4ik. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • [ ] 6. Add label Issue: Confirmed once verification is complete.

  • [ ] 7. Make sure that automatic system confirms that report has been added to the backlog.

@gekamikh I have checked and it seems you were use wrong params in query.
You should to use cartId instead of quoteId in request body "quote_id": "cartId"

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

Also when I try to add product with customizable option radio everything works. So, please, check again

@magento give me 2.3-develop instance

Hi @Den4ik. Thank you for your request. I'm working on Magento 2.3-develop instance for you

Hi @Den4ik, here is your Magento instance.
Admin access: https://i-23863-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@Den4ik Thank you for verifying the issue.

Unfortunately, not enough information was provided to acknowledge ticket. Please consider adding the following:

  • [ ] Add "Reproduced on " label(s) to this ticket based on verification result

Once all required information is added, please add label "Issue: Confirmed" again.
Thanks!

@gekamikh Yep, issue reproduced for multiselect custom option

:white_check_mark: Confirmed by @Den4ik
Thank you for verifying the issue. Based on the provided information internal tickets MC-18563 were created

Issue Available: @Den4ik, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._

Hi @gekamikh. Thank you for your report.
The issue has been fixed in magento/magento2#23871 by @Den4ik in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.3 release.

Hi @gekamikh. Thank you for your report.
The issue has been fixed in #23871 by @Den4ik in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.3 release.

It is NOT fixed in 2.3.3
Took me hours to find out since I believed you and looked for the error elsewhere.
The 1acde36b19b177b58af916557a3d41dfe0612cc0 solves the issue but it's not in 2.3.3 so this issue is still open

Was this page helpful?
0 / 5 - 0 ratings