VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: jccompagnon on December 16, 2014, 07:30:46 AM

Title: Purchase Quantity Steps
Post by: jccompagnon on December 16, 2014, 07:30:46 AM
VM 3.0.2
Joomla 3.3

Hi,

I created a product with a "Purchase Quantity Steps" of 50 but in the product page the buyer is able to click the + and - and select for example 42 then that does add a weird 72 items to cart.

Something is wrong

you can replicate here:
http://www.sourcing-heaven.com/index.php/online-store/toys/foam-toys/8-bit-pixelated-blue-diamond-foam-gun-toy-10-34-detail

The template does not use any overides
Title: Re: Purchase Quantity Steps
Post by: rickkh on December 17, 2014, 04:11:51 AM
I have the same issue... The steps are not being inforced when you use the arrows (should be +50, -50) in your case but it doesn't work.
Title: Re: Purchase Quantity Steps
Post by: rickkh on December 19, 2014, 02:12:36 AM
FIXED in VM3.0.2:
1- Open /components/com_virtuemart/assets/js/vmprices.js
2- Locate Virtuemart.product = function(carts) {
3- Replace:
                step=cart.find('input[name="quantity"]'),
WITH:

                step=cart.find('input[name="quantity[]"]'),

*******
MILBO
*******
Please take notice of the missing brackets for the next build.

Thanks!

Title: Re: Purchase Quantity Steps
Post by: jccompagnon on December 19, 2014, 07:51:15 AM
thanks.
I however have VM 3.0.2 and it is not fixed in that version.
I made your changes and it fixed it but is not fixed in 3.0.2

thanks for the fix
Title: Re: Purchase Quantity Steps
Post by: Milbo on December 19, 2014, 10:47:09 AM
I meant, fix for vm3.0.2.

Thanks for the fix, I will directly add it. I will upload soon a vm3.0.3 for further testing.
Title: Re: Purchase Quantity Steps
Post by: rickkh on December 19, 2014, 13:22:30 PM
Sure. I want to add that despite this fixing the quantity step order level for +/- quantity, users can still use the keyboard to enter quantities that are different from the step order level.
This is not being enforced in VM3.

What I did is have a small javascript function that fires onblur and onchange to automatically change the value back depending on what the user entered. Please reply to this thread so that I can see it as new replies and I'll post the function later tonight.

-Rick
Title: Re: Purchase Quantity Steps
Post by: rickkh on December 20, 2014, 02:55:51 AM
For those who need to prevent users from entering an amount that is different from the step level /minimum level using the keyboard, please do this:

1- Locate the following code in your category's default.php. If you are using a template, this should be under template/TEMPLATE_NAME/html/category/default.php

<span class="quantity-box">
        <input id="test" type="text" class="quantity-input js-recalculate" name="quantity[]" value="<?php if (isset($product->min_order_level) && $product->min_order_level 0.0) {
            echo 
$product->min_order_level;
        } else {
            echo 
'1';
        } 
?>
"
        />
        </span>


Add the following at the end of the above, BEFORE </span>


onblur="<?php echo "checkValue(this, $product->min_order_level)" 
        
?>
"
        onchange="<?php echo "checkValue(this, $product->min_order_level)"
        
?>
"


2- Add the following javascript function somewhere where it will only be loaded one in the same file (outside any foreach loop)

function checkValue(sender, step)
{
                                   var value = parseInt(sender.value);
                                    if (step == '') { step=1; } //if min_order quantity is not specified, make it one
                                    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;
                                       }
                      }
Title: Re: Purchase Quantity Steps
Post by: jccompagnon on December 20, 2014, 03:52:44 AM
It is also not being enforced on the modules like "latest product", .....
Title: Re: Purchase Quantity Steps
Post by: cimran on February 12, 2015, 15:10:24 PM
Quote from: rickkh on December 19, 2014, 02:12:36 AM
FIXED in VM3.0.2:
1- Open /components/com_virtuemart/assets/js/vmprices.js
2- Locate Virtuemart.product = function(carts) {
3- Replace:
                step=cart.find('input[name="quantity"]'),
WITH:

                step=cart.find('input[name="quantity[]"]'),

*******
MILBO
*******
Please take notice of the missing brackets for the next build.

Thanks!
I'm unable to locate this file; can you please guide
Title: Re: Purchase Quantity Steps
Post by: jenkinhill on February 12, 2015, 15:20:37 PM
Just use VM3.0.4
Title: Re: Purchase Quantity Steps
Post by: Marttyn on April 10, 2015, 19:06:55 PM
Im using VM 2.6.14, and im having similar issue:
Everytime i hit + or - que quantity increase/decrease by 2.
This happens only with products that has stockable variant childs.
You can check here: http://ideaalab.com/shop/radiofrecuencia/mandos
Almost all products in that page has stockable variant childs.

Im guessing that is a conflict of javascript?
Title: Re: Purchase Quantity Steps
Post by: Studio 42 on April 11, 2015, 01:30:52 AM
Quote from: Marttyn on April 10, 2015, 19:06:55 PM
Im using VM 2.6.14, and im having similar issue:
Everytime i hit + or - que quantity increase/decrease by 2.
This happens only with products that has stockable variant childs.
You can check here: http://ideaalab.com/shop/radiofrecuencia/mandos
Almost all products in that page has stockable variant childs.

Im guessing that is a conflict of javascript?

YOu have a module or something addding the
QuoteVirtuemart.product($("form.product"));
in the html body.

But virtuemart have already this function
QuoteVirtuemart.product($("form.product"));
in the virtuemart javascript file :
components/com_virtuemart/assets/js/vmprices.js?vmver=8609
This mean you have 2 clicks,events ...  for all your form and button in form.

the bad function in your code is this
Quotefunction recalculate_7913(stockableBlockIndex, Opt){
Title: Re: Purchase Quantity Steps
Post by: Marttyn on April 11, 2015, 13:34:45 PM
I tried to check with firebug, but im not sure how to use the script functionality of it :(
How did you found out that?
I will try to disable my template override, and every module secuencially until i find the problem
Title: Re: Purchase Quantity Steps
Post by: Studio 42 on April 11, 2015, 14:27:11 PM
It's not a overide problem,
This come from the child variant customfield product plugin.
You have to search for function recalculate_
& remove Virtuemart.product($("form.product")); from here
Title: Re: Purchase Quantity Steps
Post by: Marttyn on April 11, 2015, 15:11:16 PM
Thanks for your reply!
Are you saying its a VM problem? Or some customization ive made that cause the problem?
Title: Re: Purchase Quantity Steps
Post by: Studio 42 on April 11, 2015, 15:39:50 PM
search in your stockable variant childs plugin

you can find it in YOURSITE/plugins/vmcustom/name of the plugin
But i don't remember the name of the plugin
In one of the file you have
QuoteVirtuemart.product($("form.product"));
simply remove this and all must work correctly.
Title: Re: Purchase Quantity Steps
Post by: Marttyn on April 11, 2015, 15:47:16 PM
Thank you very much! I will check tonight when i get home.
Is this a problem of VM? Or just me and something ive installed?
Regards and thank you for your help!
Title: Re: Purchase Quantity Steps
Post by: Studio 42 on April 12, 2015, 15:48:33 PM
It's not a VM problem, but the plugin i speak since 3 messages.
Title: Re: Purchase Quantity Steps
Post by: Frans D on April 12, 2015, 17:16:10 PM
I've found the code in com_virtuemart.aio.2.6.12.2\admin\plugins\vmcustom\stockable\stockable.php

QuoteLine 393:    Virtuemart.product($("form.product"));
Title: Re: Purchase Quantity Steps
Post by: Studio 42 on April 13, 2015, 00:37:44 AM
YOu have to remove it in this file
QuoteYOURSITE\plugins\vmcustom\stockable\stockable.php
not in  com_virtuemart.aio.2.6.12.2\admin\plugins\vmcustom\stockable\stockable.php
Title: Re: Purchase Quantity Steps
Post by: Frans D on April 13, 2015, 08:50:06 AM
I am aware of that.
It was just mend as some help, were to find it.

I am running VM3.
The aio path was because I was seeking within a VM2 folder on my pc. ;) 
Title: Re: Purchase Quantity Steps
Post by: Marttyn on April 13, 2015, 13:07:18 PM
Thanks both for the help! Now it works perfectly!

Quote from: Studio 42 on April 12, 2015, 15:48:33 PM
It's not a VM problem, but the plugin i speak since 3 messages.

Stockable variants is a Virtuemart plugin, developed by VM team, delivered with VM core, right? So its a Vm problem. Not a problem because i installed something wrong, or i changed something, not even because a 3rd party plugin... Its a problem that should be fixed by VM team. right?
Title: Re: Purchase Quantity Steps
Post by: Milbo on April 13, 2015, 13:15:18 PM
One of the reasons that the stockable is not anylonger supported. If someone provides a solution, we add it to vm2.6
Title: Re: Purchase Quantity Steps
Post by: Marttyn on April 13, 2015, 13:18:06 PM
Quote from: Milbo on April 13, 2015, 13:15:18 PM
One of the reasons that the stockable is not anylonger supported. If someone provides a solution, we add it to vm2.6

Yeah, we have to admit that is not a very good plugin  ;D
Hope you can add this fix to 2.6 so and future updates we dont have to manually change it again.
Regards!
Title: Re: Purchase Quantity Steps
Post by: lindapowers on February 01, 2016, 05:41:52 AM
As a side note would be nice that you change the name of this feature from purchase quantity steps to multiples cause that is the correct name and I had not even notice this nice feature due to the incorrect use of words. Is not correct in english and therefore not well translated to other languages.

About the feature itself is working nice for us, and is very good but please name it correctly, something like "buy in multiples" and not quantity steps.