News:

Support the VirtueMart project and become a member

Main Menu

Purchase Quantity Steps

Started by jccompagnon, December 16, 2014, 07:30:46 AM

Previous topic - Next topic

jccompagnon

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

rickkh

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.

rickkh

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!


jccompagnon

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

Milbo

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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

rickkh

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

rickkh

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;
                                       }
                      }

jccompagnon

It is also not being enforced on the modules like "latest product", .....

cimran

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

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Marttyn

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?

Studio 42

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){

Marttyn

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

Studio 42

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

Marttyn

Thanks for your reply!
Are you saying its a VM problem? Or some customization ive made that cause the problem?