-
Notifications
You must be signed in to change notification settings - Fork 82
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 minimum qty input on products listing and product detail pages #609
Conversation
2747b27
to
c907227
Compare
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.
Hello @boherm ,
Tested with all types of products.
Works well for standard and virtual products ! ✅
On a product with combination, it doesn't work as expected.
In the FO, the quantity minimum is always 1. There's an alert to tell the customer that there's a minimum quantity. ❌
Screen.Recording.2024-03-19.at.10.23.08.mov
Doesn't work on Pack product. ❌
In the FO, the quantity is always the minimum quantity. After adding the product to my cart, the quantity is not updated.
Screen.Recording.2024-03-19.at.10.26.14.mov
When I deleted the products in the cart and go back to category page, the minimum quantity is not updated directly. I have to add the product through my quickview page or
refresh again the page. ❌
Screen.Recording.2024-03-19.at.10.32.07.mov
Could you check ? ^^
Thanks!
"value"=>"{if $product.cart_quantity && $product.cart_quantity >= $product.minimal_quantity}1{else}{$product.minimal_quantity}{/if}", | ||
"min"=>"{if $product.cart_quantity && $product.cart_quantity >= $product.minimal_quantity}1{else}{$product.minimal_quantity}{/if}" | ||
"id" => "quantity_wanted_{$product.id_product}", | ||
"value" => "1", |
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'm not sure why you fixed the value to 1 instead of using $product.minimal_quantity
. The same in other file.
Previous value was correct:
{if $product.cart_quantity && $product.cart_quantity >= $product.minimal_quantity}1{else}{$product.minimal_quantity}{/if}
The same conditions should be used to update min
attribute:
- Let's say
minimal_quantity
is 10. If none of this product is in the cart yet thenmin
should also be 10 - I add 10 to the cart, minimum requirements are met so the
min
should change to 1
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.
For this, it's an issue with the data in cache before template generation.
The cart_quantity
, that must be unique by users, is in cache too and for everybody! With your solution, if we do a cache:clear
at any time, it's working well.
So yeah, it's a core issue, but force to 1 and add some javascript can do the trick as long as we fix this cache issue in the core.
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.
In all cases, this isn't a fault to cache the product list 🤷♂️
But the cart_quantity
don't be cached in a global state.
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.
Could {nocache}
help here?
https://www.smarty.net/docs/en/language.function.nocache.tpl
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.
Unfortunately, it's seems not enough.
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 understand the cache problem, but then shouldn't the default value be {$product.minimal_quantity}
It doesn't seem logic to have a value always to 1 when the min attribute under can be higher no?
It would mean the default cached page would use the min quantity for everyone and then your JS update handles updating/reducing it when relevant no?
5fcb7e9
to
2ebe2a7
Compare
IMO it would be better to use a different approach. Keep |
Thanks for your comment @SharakPL, your approach with |
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.
Hello @boherm ,
Tested on branch develop on PS.
Tested on Product details page, Category related page, Homepage, Quickview and Search page.
Tested for standard product ✅ , combination ❌ , virtual ❌, pack ❌, product with custom 🤷 .
The minimal quantity is always the same on the Product Details page
for Combination, pack and virtual ❌
On other pages, it works as expected ✅
- Pack
Screen.Recording.2024-04-03.at.15.56.33.mov
- Combination
Screen.Recording.2024-04-03.at.15.59.29.mov
- Virtual
Screen.Recording.2024-04-03.at.16.07.59.mov
- For customized product, it doesn't work either, but I think that's a wanted behavior as the Customization might not be checked. So we can't know if if have 3 of the same product.
The issue is that I can't have 2 custom product with custom XX, and 1 other custom product with custom YY.
I guess that for @PrestaShop/product-council to decide ^^
Screen.Recording.2024-04-03.at.16.10.55.mov
Thanks !
Waiting for your feedback !
Thanks @florine2623 for your message! In fact, this is a problem with the core here and after a small talk with @jolelievre, this could be fix in another PR and directly on the core side. What do you think? 🤔 |
Hello @boherm and @jolelievre , Ok for me to get it fixed on the core directly ^^ Thanks! |
"value"=>"{if $product.cart_quantity && $product.cart_quantity >= $product.minimal_quantity}1{else}{$product.minimal_quantity}{/if}", | ||
"min"=>"{if $product.cart_quantity && $product.cart_quantity >= $product.minimal_quantity}1{else}{$product.minimal_quantity}{/if}" | ||
"id" => "quantity_wanted_{$product.id_product}", | ||
"value" => "1", |
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 understand the cache problem, but then shouldn't the default value be {$product.minimal_quantity}
It doesn't seem logic to have a value always to 1 when the min attribute under can be higher no?
It would mean the default cached page would use the min quantity for everyone and then your JS update handles updating/reducing it when relevant no?
"value"=>"{if $product.quantity_wanted}{$product.quantity_wanted}{else}1{/if}", | ||
"min"=>"{if $product.quantity_wanted}{$product.minimal_quantity}{else}1{/if}" | ||
"id" => "quantity_wanted", | ||
"value" => "1", |
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.
"value" => "1", | |
"value" => "{$product.minimal_quantity}", |
Same question why not use the min quantity for both min and value attributes?
2ebe2a7
to
a3eeccb
Compare
1. Set a minimal quantity for ordering a product in BO.
2. Then go to the FO and search your product in categories pages, and see the value displayed in the quantity input.
3. After added to the cart, you must have "1" in the quantity input instead of the minimal quantity required to put the product on your cart.