magento2: Unable to update cart item's custom option values with REST API

Preconditions and environment

  • Magento CE version 2.4.4
  • Component: REST API

Steps to reproduce

  1. Create a simple product in the catalog with a customizable option

Using the Magento REST API:

  1. Create a cart for checkout (POST /rest/default/V1/guest-carts/) and add a cart item of the product created in step 1
POST /rest/default/V1/guest-carts/{cartId}/items request body:
{
    "cartItem": {
        "sku": "24-MB01",
        "qty": 1,
        "product_option": {
            "extension_attributes": {
                "custom_options": [
                    {
                        "option_id": 1, 
                        "option_value": "1"
                    }
                ]
            }
        }
    }
}
  1. Specify a new option_value in the payload and perform PUT /rest/default/V1/guest-carts/{cartId}/items/{itemId} with the following request body:
{
    "cartItem": {
        "sku": "24-MB01",
        "qty": 1,
        "product_option": {
            "extension_attributes": {
                "custom_options": [
                    {
                        "option_id": 1,
                        "option_value": 999
                    }
                ]
            }
        }
    }
}
  1. Retrieve the cart items by doing a GET on rest/default/V1/guest-carts/{cartId}/items/

Expected result

The custom option_value for the option_id should be updated after step 3.

Actual result

Only the custom option_value of the first-added cart item does not get updated after the PUT request.

Additional information

I’ve reproduced this behavior on the 2.4-develop branch using the instance provided by magento-deployment-service

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (4 by maintainers)

Most upvoted comments

Hello

As I can see this issue got fixed in the scope of the internal Jira ticket AC-5986 by the internal team. Related commits: https://github.com/magento/magento2/search?q=AC-5986&type=commits

Based on the Jira ticket, the target version is 2.4.6.

Thanks