Jump to content

Issue with minimum quantity


SolucionesWeb

Recommended Posts

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.

Edited by SolucionesWeb (see edit history)
  • Like 1
Link to comment
Share on other sites

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

  • 1 month later...

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 by Heiji
Forget to enter file path to be edited. (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 10 months later...
  • 1 year later...
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.

  • Like 1
Link to comment
Share on other sites

  • 3 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...