SolucionesWeb Posted April 20, 2022 Share Posted April 20, 2022 (edited) Prestashop 1.7.8.3 and 1.7.8.5 Hi, I have encountered a problem that prestashop generates with products that have a minimum purchase quantity. If you enter a quantity above the minimum, prestashop rewrites the quantity to the minimum again. It seems as if it detects that the quantity you enter is lower and rewrites it. This does not happen with all quantities, I have tried putting different quantities. For example a product with minimum quantity for sale of 50 units I can put 650 and buy perfectly but if I put 150 it rewrites it and puts me back to 50. When you add it to the cart and rewrite there the quantity it generates two items. Continuing with the example of the previous product. If you modify the quantity from 50 to 250 it generates an article with 50 units and another with 200 units. It seems as if it counts some percentage and for a product that has a minimum quantity of 50 units does not let you put a quantity between 100 and 499. Can someone check this to see if the same thing happens to you? Thanks! Attached video, it's a little difficult to explain in words. 7a915ecb-e69b-4255-b5a5-b2b52293298c.webm Edited April 21, 2022 by SolucionesWeb (see edit history) 1 Link to comment Share on other sites More sharing options...
SolucionesWeb Posted April 27, 2022 Author Share Posted April 27, 2022 I've done some more research and I think the problem is with the input where you enter the quantity on the product page. I think javascript is doing some kind of check there and it is not working correctly. I have tried to create my own code changing the ID of the input and I get it to work but I am afraid that changing that ID will affect other sites on the web. I will upload a new video with the problem again. Link to comment Share on other sites More sharing options...
Heiji Posted June 21, 2022 Share Posted June 21, 2022 (edited) Hi SolucionesWeb, encountered the same problem on Prestashop versions 1.7.3 and 1.7.8.6 where I did some testing. The problem only seems to occur on the product page when changing the quantity, in the "quick view" of the article it seems to work correctly. On the product page when changing the quantity the following javascript function is executed: t.focusout(function(){(""===t.val()||t.val()<t.attr("min"))&&(t.val(t.attr("min")),t.trigger("change"))}) I think 't.val()' and 't.attr("min")' are compared as strings and not integers. I tried modifying the function (/themes/classic/assets/js/theme.js) as follows and it seems to work. t.focusout(function(){(""===t.val()||parseInt(t.val())<parseInt(t.attr("min")))&&(t.val(t.attr("min")),t.trigger("change"))}) It's a fix that I made quickly, I cannot guarantee that it will work without problems. Edited June 21, 2022 by Heiji Forget to enter file path to be edited. (see edit history) 1 Link to comment Share on other sites More sharing options...
JBW Posted June 22, 2022 Share Posted June 22, 2022 I assume this code is part of a 3rd party theme!? Can't find it in classic theme so you should inform the theme developer to fix it Link to comment Share on other sites More sharing options...
forchester Posted May 20, 2023 Share Posted May 20, 2023 Hi, i have sam problem with prestshop 8.0.4, have you any solution? 1 Link to comment Share on other sites More sharing options...
Birze Posted May 28 Share Posted May 28 On 6/21/2022 at 4:31 PM, Heiji said: Hi SolucionesWeb, encountered the same problem on Prestashop versions 1.7.3 and 1.7.8.6 where I did some testing. The problem only seems to occur on the product page when changing the quantity, in the "quick view" of the article it seems to work correctly. On the product page when changing the quantity the following javascript function is executed: t.focusout(function(){(""===t.val()||t.val()<t.attr("min"))&&(t.val(t.attr("min")),t.trigger("change"))}) I think 't.val()' and 't.attr("min")' are compared as strings and not integers. I tried modifying the function (/themes/classic/assets/js/theme.js) as follows and it seems to work. t.focusout(function(){(""===t.val()||parseInt(t.val())<parseInt(t.attr("min")))&&(t.val(t.attr("min")),t.trigger("change"))}) It's a fix that I made quickly, I cannot guarantee that it will work without problems. Tried this. Looks like it works. 1 Link to comment Share on other sites More sharing options...
DavidFortune Posted September 23 Share Posted September 23 On 5/28/2024 at 1:49 PM, Birze said: Tried this. Looks like it works. Yeah, same issue with product minimum qty, solved replacing this code on current child theme. So much thanks to all. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now