magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

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

Open seungwooc-23 opened this issue 3 years ago • 14 comments

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.
  • [X] 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”.

seungwooc-23 avatar Jul 14 '22 00:07 seungwooc-23

Hi @seungwooc-23. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

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

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

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

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

m2-assistant[bot] avatar Jul 14 '22 00:07 m2-assistant[bot]

Hi @engcom-Dash. 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.
    1. 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.
    1. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
    1. Verify that the issue is reproducible on 2.4-develop branch
      Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
      - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
      - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

m2-assistant[bot] avatar Jul 14 '22 05:07 m2-assistant[bot]

Hi @engcom-Lima. 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.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.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. Add label Issue: Confirmed once verification is complete.

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

m2-assistant[bot] avatar Jul 15 '22 13:07 m2-assistant[bot]

@magento give me 2.4-develop instance

seungwooc-23 avatar Jul 15 '22 17:07 seungwooc-23

Hi @seungwooc-23. Thank you for your request. I'm working on Magento instance for you.

Hi @seungwooc-23, here is your Magento Instance: https://7f9f88ea28e9b8b7a2a492289744a5e4.instances.magento-community.engineering Admin access: https://7f9f88ea28e9b8b7a2a492289744a5e4.instances.magento-community.engineering/admin_64d0 Login: ea61718b Password: a50033b6d9c9

Hi @seungwooc-23

Kindly elaborate more about your steps to reproduce for ex-What option type you have choosed to create customizable options of simple product , your post method request body and also provide screeshots of the response that you are getting.

Thank you!!

engcom-Lima avatar Jul 18 '22 10:07 engcom-Lima

@magento give me 2.4-develop instance

seungwooc-23 avatar Jul 18 '22 15:07 seungwooc-23

Hi @seungwooc-23. Thank you for your request. I'm working on Magento instance for you.

Hi @seungwooc-23, here is your Magento Instance: https://7f9f88ea28e9b8b7a2a492289744a5e4.instances.magento-community.engineering Admin access: https://7f9f88ea28e9b8b7a2a492289744a5e4.instances.magento-community.engineering/admin_f945 Login: faef9ce6 Password: 62989efa6452

Hi @engcom-Lima,

  • The option type chosen is the Text Field type The options for SKU 24-MB01 are:
GET https://7f9f88ea28e9b8b7a2a492289744a5e4.instances.magento-community.engineering/rest/default/V1/products/24-MB01/options

[
    {
        "product_sku": "24-MB01",
        "option_id": 1,
        "title": "Option1",
        "type": "field",
        "sort_order": 1,
        "is_require": false,
        "price": 0,
        "price_type": "fixed",
        "max_characters": 0,
        "image_size_x": 0,
        "image_size_y": 0
    }
]
  • The cart item addition is
POST https://7f9f88ea28e9b8b7a2a492289744a5e4.instances.magento-community.engineering/rest/default/V1/guest-carts/g2QC7We6LJGkomp9XI2Tj8ZTjo3Edgtq/items

Request body:
{
    "cartItem": {
        "sku": "24-MB01",
        "qty": 1,
        "product_option": {
            "extension_attributes": {
                "custom_options": [
                    {
                        "option_id": 1, 
                        "option_value": 1
                    }
                ]
            }
        }
    }
}
  • Cart update call is:
PUT https://7f9f88ea28e9b8b7a2a492289744a5e4.instances.magento-community.engineering/rest/default/V1/guest-carts/g2QC7We6LJGkomp9XI2Tj8ZTjo3Edgtq/items/5

Request body:
{
    "cartItem": {
        "sku": "24-MB01",
        "qty": 1,
        "product_option": {
            "extension_attributes": {
                "custom_options": [
                    {
                        "option_id": 1, 
                        "option_value": "9999"
                    }
                ]
            }
        }
    }
}
  • List the items on the cart to verify its items:
GET https://7f9f88ea28e9b8b7a2a492289744a5e4.instances.magento-community.engineering/rest/default/V1/guest-carts/g2QC7We6LJGkomp9XI2Tj8ZTjo3Edgtq/items/

Response:
{
    "item_id": 5,
    "sku": "24-MB01",
    "qty": 1,
    "name": "Joust Duffle Bag",
    "price": 34,
    "product_type": "simple",
    "quote_id": "3",
    "product_option": {
        "extension_attributes": {
            "custom_options": [
                {
                    "option_id": "1",
                    "option_value": "1"
                }
            ]
        }
    }
}

seungwooc-23 avatar Jul 18 '22 16:07 seungwooc-23

:heavy_check_mark: Issue confirmed

Issue got reproduced in 2.4-develop branch.

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

Pre-requisite: Clean magento should be installed 2.4-develop

Steps to reproduce:

  1. Create simple product using customizable option (text as option type).
  2. Add product to the cart using guest.
  3. Go to db capture quote id masked.
  4. Using post request >> add product to the cart /rest/default/V1/guest-carts/[quoteid_masked]/items Request body:
`{
    "cartItem": {
        "sku": "24-MB01",
        "qty": 1,
        "product_option": {
            "extension_attributes": {
                "custom_options": [
                    {
                        "option_id": 1, 
                        "option_value": 1
                    }
                ]
            }
        }
    }
}`
  1. Update the cart using put method: /rest/default/V1/guest-carts/[quoteid_masked]/items/[itemid] Request body:
{
    "cartItem": {
        "sku": "24-MB01",
        "qty": 1,
        "product_option": {
            "extension_attributes": {
                "custom_options": [
                    {
                        "option_id": 1, 
                        "option_value": "9999"
                    }
                ]
            }
        }
    }
}

Expected result: Option value should be updated. Actual result: Option value was not updated. Screenshot Screenshot from 2022-07-19 13-32-47

Hence, confirming the issue.

engcom-Lima avatar Jul 19 '22 08:07 engcom-Lima

:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-5986 is successfully created for this GitHub issue.

github-jira-sync-bot avatar Jul 19 '22 08:07 github-jira-sync-bot

:white_check_mark: Confirmed by @engcom-Lima. Thank you for verifying the issue.
Issue Available: @engcom-Lima, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

m2-assistant[bot] avatar Jul 19 '22 08:07 m2-assistant[bot]

Closed without a comment? But I see a bunch of commits mentioning AC-5986, here's the merge commit: https://github.com/magento/magento2/commit/70b864f4b103800784397f14b2887b25e619fad3, so that's probably the fix

hostep avatar Aug 30 '22 19:08 hostep

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

engcom-Hotel avatar Sep 01 '22 12:09 engcom-Hotel