News:

Support the VirtueMart project and become a member

Main Menu

Initial Step & Min Qty

Started by tjrayner, March 01, 2016, 20:44:17 PM

Previous topic - Next topic

tjrayner

Hi, really hoping someone can help. I've amended my template to have the initial value on the products add to cart bar to be 0 this is due to a customisation I've got for adding multiple items at once. The problem I have now is that if you click the + icon it changes the value to 1 rather than the minimum amount (3). If you then add to cart it adds the minimum amount. Is there a way of getting the first step to jump to the minimum amount then the additional steps continue at 1

Hope I've explained it well enough

PRO

have you setup steps in the product?

tjrayner

Hi, yes the problem is I need the steps to be 1 as the minimum needs to be 3 but they can have 4, 5, 6 etc if I change step to 3 then they can only order 3, 6, 9 etc. I need the first step to be 3 for example and then revert to 1

tjrayner

OK I've managed to get the qty to change to the minimum value when clicking in the qty box by adding the following script:

<script>
function checkValue(sender, step)
{
                                   var value = parseInt(sender.value);
                                   
                                    if (value == '' || isNaN(value)) {
                                                  sender.value = step;
                                     } else if (value < step) { sender.value = step; }
                                      else if (value%step != 0 && value > step) {
                                            sender.value = (value - (value%step));
                                     } else {
                                             return sender.value;
                                       }
                      }
</script>


and then at the end of the qty input added the following onclick="<?php echo "checkValue(this, $product->min_order_level)"?>"

However I'm unsure how to continue this with the plus and minus buttons

PRO


tjrayner

But then as the initial value is 0 when you click the plus the value goes to 1 not 3

PRO

in the script you wrote,

increment by the minimum if its not met, then by the step after that