Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #18812 #22849

Closed
Closed

Conversation

shikhamis11
Copy link
Member

Fixed #18812 Unable to update simple product custom option in cart when quantity is 1

Preconditions (*)

  1. Magento CE 2.2.5
  2. Although reproduced in 2.2.2-2.2.4
  3. Backorders disabled, minimum order qty is 1.
  4. A simple product with at least one custom option, e.g. size - 1,2,3; price type fixed.

Steps to reproduce (*)

  1. Go to product page and select options and click add to cart.
  2. Go to cart and select "Edit/Update Item"
  3. Select different option from original and click update.

Expected result (*)

  1. Redirected back to cart
  2. Product custom option updated.

Actual result (*)

  1. Error message on product page.
    image

Notes

It manifests as well if you have configurable product, where associated product has 1 stock, and configurable has custom option. Once selected and added to cart. If you try to update only custom option, the result is the same.

It appears that the code in Magento/Quote/Model/Quote.php#updateItem updates product item or adds new one if product item with matching custom/configurable options does not exist and later removes old item.
Problem is inside updateItem(), call to to addProduct() throws, because actual product qty is 1.

@m2-assistant
Copy link

m2-assistant bot commented May 12, 2019

Hi @shikhamis11. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

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

Copy link
Contributor

@dmytro-ch dmytro-ch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @shikhamis11,
could you please check and fix the automated tests failures?

@dmytro-ch
Copy link
Contributor

@shikhamis11, please note, the static need to be also fixed.
Once the changes are applied, please squash all commits into a single one in order to clean up history.
Thank you!

@Nazar65 Nazar65 self-assigned this Jun 6, 2019
@Nazar65
Copy link
Member

Nazar65 commented Jun 6, 2019

Hi @dmytro-ch please review.

@magento-engcom-team
Copy link
Contributor

Hi @dmytro-ch, thank you for the review.
ENGCOM-5270 has been created to process this Pull Request

@makkoff
Copy link

makkoff commented Jun 13, 2019

✔️ QA Passed

@ghost
Copy link

ghost commented Jun 24, 2019

@shikhamis11 unfortunately, only members of the maintainers team are allowed to unassign developers from the pull request

Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @shikhamis11 thanks for the pull request, I have several questions regarding this pull request, can you please take a look at my review comments

/**
* we are using 0 because original qty was processed
*/
$qtyForCheck = $this->quoteItemQtyList
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @shikhamis11 @dmytro-ch can you please provide an explanation on how this change is fixing the issue. Also, can you please explain the comment "we are using 0 because original qty was processed" - where the qty was processed?

As far as I remember \Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\QuoteItemQtyList::getQty was working incorrectly becouse of null is passed as $quoteItemId in certain cases

@sidolov
Copy link
Contributor

sidolov commented Jul 29, 2019

@shikhamis11 , I am closing this PR now due to inactivity.
Please reopen and update if you wish to continue.
Thank you for the collaboration!

@sidolov sidolov closed this Jul 29, 2019
@m2-assistant
Copy link

m2-assistant bot commented Jul 29, 2019

Hi @shikhamis11, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment