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
Fix a bug where changing quantity on product quickview adds products tags on every product #16852
Conversation
Co-Authored-By: GoT <PierreRambaud@users.noreply.github.com>
I should rebuild assets, don't approve yet |
Hi @NeOMakinG, It is ok in the Categories page but if you follow these steps, the issue is reproduced:
https://drive.google.com/file/d/1XSu23m1bZeDPLysiMoMqpP1T7AvOt2h1/view Thanks! |
$('.quickview .product-discounts, .page-product:not(.modal-open) .row .product-discounts').replaceWith(data.product_discounts); | ||
$('.quickview .product-additional-info, .page-product:not(.modal-open) .row .product-additional-info').replaceWith(data.product_additional_info); | ||
$('.quickview #product-details, #product-details').replaceWith(data.product_details); | ||
$('.quickview .product-flags, .page-product:not(.modal-open) .row .product-flags').replaceWith(data.product_flags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't find any element with class .product-flags
inside the quickview. Consequently, I think this line should only be: $('.page-product .product-flags').replaceWith(data.product_flags)
.
Same thing apply to #product-details
, .product-discounts
and .product-additionnal-info
, because quickview doesn't contain them.
BUT this will not fully resolve the problem. One case is: when quantity is changed from a quickview inside a product page (when product miniatures exist in product page e.g similar products).
Let's take an example in detail:
- user is in product X page and there are other similar products Y and Z as miniatures in sidebar.
- user clicks in quickview of Y and changes quantity.
In this DOM, there are :
- 2 elements with class
product-variants
, one in quickview of Y and the other in product page X. - 2 with
.product-prices
- 1 element with
.product-customization
but for product X - 1 element with
#product-details
but for product X - 1 element with
.product-discounts
but for product X - 1 element with
.product-additionnal-info
but for product X.
IMHO, the whole problem could be solved by re-naming classes (or adding discriminator ones) depending on the source (quickview or product page) and keeping javascript as it is for all classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree for the class not contained in quickview, gonna add a commit for it, but for the rest, did you see that I select elements on product X page only if there are no modals opened? It means that product infos will change only if there are no quickview opened
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the time you gave to my comment, and I am sorry for wrongly expressing the second point.
I should have been only focusing on .product-flags
when giving my example, so let's see an example with this class:
1- Install featured products module and hook it inside product page (footer for example).
2. From product page of product X, click on quickview of product Y( anyone from featured products and not necessarly one with special flags), change quantity...etc
3. Look at product flags of featured products and product X, they change to flags of product Y.
Now, let's keep modal closed and only change quantity for productX => all featured products have their flags changed.
I agree with you that :not(.open-modal)
is the solution for the majority of classes, but not all of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, ok this time it looks like you didn't see the .row selector, featured products and product in the same category are not in a .row. I agree with you, thats not really solid, but atleast it avoid breaking changes, we are not able to change JS selectors for a new class because if we would do that, theme which herit these templates or rewrited these but didn't modify the JS would break with a new class, we're able to do it in a major version probably.
Thank you for your feedback and the time you take on this PR :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You pointed me to subject I am not always aware of. Thank you very much for such an invaluable info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, you'r welcome, thanks a lot for your feedback there, it was a pleasure !
Hi @NeOMakinG ! The fix is OK for #16633, but I still have the bug for #9919 (comment) |
The error is now displayed in the right place, but the error is related to something else, submit an issue if this error should be fixed by a backend dev |
I don't know why PrettyCi is failing when there are only js files edited 😅 |
Yep, that's weird.. @NeOMakinG maybe you can try to squash all the commits (this will make the PR cleaner) and re-push to relaunch the PrettyCi build |
Hi @NeOMakinG ! So, could you confirm me that the fact this error is still displayed (when changing combination of a "related product") should not be fixed by your PR ? If so, I would suggest to close the issue #16633 , which is totally fixed by your PR, but to keep #9919 (comment) open, since it's not totally fixed... WDYT ? |
We can keep #9919 as it's related to the url called using ajax and not misplacement of ajax calls as this issue should fix, but 16633 is fixed, the error is even displayed on the product it should be displayed now |
Ok ! So since the error of #9919 is now OK (only displayed on the good product), it's QA approved :) |
Thanks @NeOMakinG |
This change is