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
New optional feature - display out of stock products last #12441
New optional feature - display out of stock products last #12441
Conversation
When user adjust quantity in cart summary and wanted quantity is more than 'in-stock', than error notification shown, but with this improvement user knows maximum product quantity he can buy.
…rop, category pages, more to come
…ducts,product-sales,prices-drop
Hello @gadnis! This is your first pull request on the PrestaShop project. Thank you, and welcome to this Open Source community! |
@colinegin This is a new feature, what do you think 😉 ? |
@@ -47,6 +47,11 @@ | |||
{{ form_errors(paginationForm.default_order_way) }} | |||
{{ form_widget(paginationForm.default_order_way) }} | |||
</div> | |||
<div class="form-group"> | |||
{{ ps.label_with_help(('Display out-of-stock products last'|trans), ('If enabled, products will be in this order: 1. in-stock, 2. available for order but quantity is 0, 3. out-of-stock. This does not apply when ordering by name & sales'|trans({}, 'Admin.Shopparameters.Help'))) }} |
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, can you explain the "ordering by name & sales" please? Also, I would write If enabled, products will be displayed in this order: 1. in-stock, 2. available for order but quantity is 0, 3. out-of-stock. Note that it does not apply when ordering by name or sales. instead, what do you think?
Hello @gadnis In BO > Shop parameters > Products settings, you can already choose to filter by quantity by default This way, when your customer arrives on a category page, "Relevance" is selected and your products are sorted by quantity. The problem is that this option only takes into account the quantity and not if out of stock products can be ordered or not. So, we would like to take this into account when quantity is selected as default order by. What dou think about that ? |
Hi @marionf ! It's kind of good idea but not really.. If people would choose to order by name, I understand that they want to see product in A-Z or Z-A order. But when day choose to order by price, they aspect to see lets say cheapest products first and hope that the seller has those products in stock, cause why else order by price.. unless to spy or investigate product prices, which is not that offen the case to order by price. I Would add a switch (ON, OFF option) to show out-of-stock products last. |
Thank you for your answer @gadnis I would like to test your PR and maybe suggest some improvements but there are some conflicting files and this generates errors |
Ok, @marionf, I will try to do that in the next week ;) |
Adding switch to enable or disable the feature
Adding SwitchType to a Form. To be able switch off|on this feature
Adding configuration field 'display_out_of_stock_last'. It will be used to either enable or disable the feature
This one is not related to the feature. I'm not sure why it is in this PR. But it is useful.
Adding two methods: orderByOOSP and sqlOrderByOOSP There is All "facets" where we allow to sort out-of-stock last in method sqlOrderByOOSP And method orderByOOSP helps to do that later
changes marked with comment: ORDER BY out-of-stock products last
Allowing order products as described in PR Changes marked with comment: ORDER BY out-of-stock products last
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.
Code is now compatible with PS 1.7.6.2
Hi, @marionf , finally I updated our shop to the latest, and now I had to put back my code there. So I change the code in this PR also. Please review and merge it 😁 Now I will go to find out how to do the same feature on ps_facetedsearch module, cause it was refactored and my code is no fit in there... |
@@ -55,7 +55,13 @@ | |||
{{ form_widget(paginationForm.default_order_way) }} | |||
</div> | |||
</div> | |||
|
|||
<div class="form-group row"> | |||
{{ ps.label_with_help(('Display out-of-stock products last'|trans), ('If enabled, products will be displayed in this order: 1. in-stock, 2. available for order but quantity is 0, 3. out-of-stock. Note that it apply only when ordering by quantity, price or dates'|trans({}, 'Admin.Shopparameters.Help'))) }} |
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 would not use the word 'reordering' here, it can be ambiguous. What about Note that it only applies when filtering by quantity, price or date. instead?
...sources/views/Admin/Configure/ShopParameters/Blocks/product_preferences_pagination.html.twig
Outdated
Show resolved
Hide resolved
…eters/Blocks/product_preferences_pagination.html.twig Co-Authored-By: LouiseBonnard <32565890+LouiseBonnard@users.noreply.github.com>
Hi @gadnis , Since we had no news from you for more than 30 days, I'll close this pull request. Feel free to reopen or open another one if you think it's still relevant. Thanks! |
Here is some pictures to help you understand what PR does:
BO: feature switch added:
FO: sort by Price examples:
In category pages:
In best-sales page:
In prices-drop page:
In new-product page:
Sort by Date added in new-product page:
This change is