VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: team on April 26, 2012, 16:27:40 PM

Title: Multiple Quantity Question
Post by: team on April 26, 2012, 16:27:40 PM
Hi Staff, hello people, first time writting here, of course I searched solution before post here, but no result found.
Thanks in advance to help me.
My question is multiple quantity orderable.
My product can be purchased and shipped only on multiple of 10.
I did set Minimum Purchase Quantity to 10 in Product Status tab.
Now the add cart button shows 10, and that's OK.
If customers click on +/- button the quantity goes up/down of 1 unit instead of 10, that's not acceptable.
I absolutely cannot sell 11, 12, 13 pcs, but just 10 or 20 or 30 and so on.
Where am I wrong?
How to solve it?
Thanks
Piero / Italy
Title: Re: Multiple Quantity Question
Post by: webiedesign on May 06, 2012, 03:22:31 AM
I have not tried this, but this may work for your situation.
http://www.tips4developer.com/joomla/virtuemart-special-quantity-option-selected-shopper-group/
Title: Re: Multiple Quantity Question
Post by: John2400 on May 06, 2012, 09:15:01 AM
Hi team
two options....
http://extensions.virtuemart.net/extensions-virtuemart-2/quantity-related-calculation-detail

or simply state - that all quantities are sold in lots - eg
we sell arrows in dozens so we simply have - one dozen first at one price and all the drop down tabs are sold in 2 dozen, three dozen and so on.

Customers seem to have little issue with that.
Title: Re: Multiple Quantity Question
Post by: Lockerbie on May 26, 2012, 09:56:29 AM
My client sells wine and he wants to show the price per single bottle, but sell most products per box of 6 bottles (no discount). Only some wines are sold per bottle.

The option webiedesign mentioned seems good, but unfortunate, not alle wines are sold in quantities of 6.
The quantity-related-plugin looks like an option (bought it already), but my client doesn't want to work with discount for boxes of 6 bottles of wine.

How can I adjust things so that some wines are sold in quantities of 6 bottles and others are sold per single bottle?

(J! 2.5.4 - VM 2.0.6)
Title: Re: Multiple Quantity Question
Post by: John2400 on May 26, 2012, 10:27:51 AM
You can add the image of the product as normal and have

* the price as normal - next to the product  and have an attribute as a drop down that says price per one - price per 1/2 dozen, price prer dozen etc.

If you sets your weight correctly then the shipping cost of one will be expensive , compared to the cost of 1/2 dozen and so on.

* all options you have mentioned here should be ok in the setting of attributes- but always explain clearly on your site that items are sold in volumes are cheaper to ship than single items.   " have a best offer"" best to buy in Bulk.
Title: Re: Multiple Quantity Question
Post by: Lockerbie on May 26, 2012, 11:10:34 AM
Hello John2400,

Thanks for your answer. To do it that way is a possibility, I guess. Just a lot of work to attach a lot of attributes to all products. With (the most of) 125 products, this would mean something like 500-750 attributes or more! And with manually calculated prices, in stead of automatic.
You should think there should be an easier way to achieve this... Is there?
Title: Re: Multiple Quantity Question
Post by: John2400 on May 26, 2012, 11:57:00 AM
Just for the moment _ A quick answer is that you could get one product just the way you like - then just clone the product - . Then all you have to do is add an image and change the price.

I understand what you mean - let me think on a option for a while - I have heard of stores with 2000 plus items.  There is an extension that you can change prices in bulk. I have used this it is called 'VM bulk editor' - have a look at the free options and maybe see what you can do with that.
http://www.virtuemart-bulk-editor.anthonyglover.com/
Title: Re: Multiple Quantity Question
Post by: Lockerbie on May 26, 2012, 12:40:54 PM
Wouldn't it be possible to create a calculation rule with someting like 'multiply by 6' in it?
The only option I'll see in there are +, -, +% and -%. If possible to add a multiplier, how can I do this?
Title: Re: Multiple Quantity Question
Post by: John2400 on May 26, 2012, 13:05:12 PM
mmm?

Have an idea - not something I use but - if you use stock variants, (plug ins)--, VM custome , stock variants)- see image number 1 , & number.



Then add this to a product and you can add prices here. in groups. -

have a look at this option



[attachment cleanup by admin]
Title: Re: Multiple Quantity Question
Post by: Lockerbie on May 26, 2012, 13:26:54 PM
I found the VM custom-stock variants -plugin, activated it and played with it.
But I can't get someting like in your other image; I don't see anything like 'parent variant or the other fields. What am I missing here?
Title: Re: Multiple Quantity Question
Post by: Lockerbie on May 26, 2012, 13:36:07 PM
Nevermind: I've got the same fields now. I missed the 'child products'.
I'll try this out and let you know!
Title: Re: Multiple Quantity Question
Post by: Lockerbie on May 26, 2012, 14:18:59 PM
Oké, I think this could work!
Off course there are a few things to take care of:
- you'll have to fill in the right price per quantity (in this case: before tax),
- you'll have to manually calculate the 'additonal charge'. (*5, that is! Or *11, and so on.)

Besides that, the product price is displayed per 1 bottle. If you change the number to 12, the price changes accordingly. So far, so good. But if after that you change the quantity to 6, the price doesn't change anymore. Minor problem, but still. See: this example (http://www.debibliotheek.com/index.php/witte-wijn/buitenverwachting-chardonnay-detail).

Below the quantity-dropdown it says 'price: free'. I'll have to look where to change or remove this.
And the 'normal' quantitynumbers (and +/-) have to be removed also.

I'll have to go know, I will look into this later on. Thank you very much for now!
Title: Re: Multiple Quantity Question
Post by: Lockerbie on May 27, 2012, 13:18:57 PM
I'm afraid it's not as perfect as we thought. It's workable, but also complicated. You'll have to manual calculate the (before tax-) prices for the additional charges, so you get *5, *11, *17, *23 and so on. So for every 10 choices (=10 boxes, =60 bottles of wine), you'll have to add 10 childproducts with all manually calculated prices.
For me it's not a very big problem (although much work), but I forsee problems when my client wants to add new products himself...

I still wonder if it isn't possible to make a new calculation rule with a possibility to multiply, so all prices are calculated automaticly. This would be great, both for me and my clients!  8)

(A few days ago I bought the 'quantity-related-price-calculation'-plugin, but this seems to work only when given discount with a given quantity, wich is something my client doens't want to use. So if someone would know how to achieve what we want with this plugin, this would be another great option!
The developer suggested to set up the products as bundles, but since there are some products that aren't sold in a bundle, and the shopowner wants the prices to be shown for single bottles, this is not an ideal option, I guess.)
Title: Re: Multiple Quantity Question
Post by: Lockerbie on May 28, 2012, 15:21:06 PM
Another thing not wishable: all child products are in the dropdown, off course. But besides that, when searching on product name, you'll find all child products as single products displayed.

You should think there should be an easier solution for selling some products per 6, and others per single product...

Just an idea... isn't it possible to combine the special-quantity-option (http://www.tips4developer.com/joomla/virtuemart-special-quantity-option-selected-shopper-group/) and the normal cart layout? I mean: the special-quantity-option is written for VM1, but isn't it possible to use something like this in a page-override, so you can choose per product what 'quantity-cart' you want to use?

Off course I've emailed the developer, but I've gotten no answer yet.
So since I'm no scripter, could someone point me in the right direction on how to adjust things... ?
Title: Re: Multiple Quantity Question
Post by: Lockerbie on May 29, 2012, 23:35:28 PM
So here I am again. But now I know for certain that it's possible to have a template with a cart that adds/subtracts single products, and a template with a cart that adds/subtracts 6 products each time!
I can't seem to get it working right together at the same time though, but perhaps someone could help me with this?
This is what I did so far:

in components/com_virtuemar/assets/js/vmprices.js, about line 86 I added:
plus6  = cart.find('.quantity-plus6'),
    minus6 = cart.find('.quantity-minus6'),

and changed:
plus.click(function() {
var Qtt = parseInt(quantity.val());
if (Qtt != NaN) {
quantity.val(Qtt + 1);
Virtuemart.setproducttype(cart,virtuemart_product_id);
}

});
minus.click(function() {
var Qtt = parseInt(quantity.val());
if (Qtt != NaN && Qtt>1) {
quantity.val(Qtt - 1);
} else quantity.val(1);
Virtuemart.setproducttype(cart,virtuemart_product_id);
});
select.change(function() {
Virtuemart.setproducttype(cart,virtuemart_product_id);
});
radio.change(function() {
Virtuemart.setproducttype(cart,virtuemart_product_id);
});
quantity.keyup(function() {
Virtuemart.setproducttype(cart,virtuemart_product_id);
});

to:
plus6.click(function() {
var Qtt = parseInt(quantity.val());
if (Qtt != NaN) {
quantity.val(Qtt + 6);
Virtuemart.setproducttype(cart,virtuemart_product_id);
}

});
minus6.click(function() {
var Qtt = parseInt(quantity.val());
if (Qtt != NaN && Qtt>6) {
quantity.val(Qtt - 6);
} else quantity.val(6);
Virtuemart.setproducttype(cart,virtuemart_product_id);
});
select.change(function() {
Virtuemart.setproducttype(cart,virtuemart_product_id);
});
radio.change(function() {
Virtuemart.setproducttype(cart,virtuemart_product_id);
});
quantity.keyup(function() {
Virtuemart.setproducttype(cart,virtuemart_product_id);
});

and saved it as vmprices6.js

in components/com_virtuemart/views/productdetails/tmpl/default_addtocart.php, I changed:
    <span class="quantity-controls js-recalculate">
<input type="button" class="quantity-controls quantity-plus" />
<input type="button" class="quantity-controls quantity-minus" />
    </span>

to:
    <span class="quantity-controls js-recalculate">
<input type="button" class="quantity-controls quantity-plus6" />
<input type="button" class="quantity-controls quantity-minus6" />
    </span>

and saved this file as default_addtocart6.php

in components/com_virtuemart/views/productdetails/tmpl/default.php, I changed:
<?php
// Add To Cart Button
//  if (!empty($this->product->prices) and !empty($this->product->images[0]) and $this->product->images[0]->file_is_downloadable==0 ) {
if (!VmConfig::get('use_as_catalog'0) and !empty($this->product->prices)) {
    echo $this->loadTemplate('addtocart');
}  // Add To Cart Button END
?>

to:
<?php
// Add To Cart Button
//  if (!empty($this->product->prices) and !empty($this->product->images[0]) and $this->product->images[0]->file_is_downloadable==0 ) {
if (!VmConfig::get('use_as_catalog'0) and !empty($this->product->prices)) {
    echo $this->loadTemplate('addtocart6');
}  // Add To Cart Button END
?>

and saved this as default-per-6-flessen.php

Next, in VM-backend, I opened one article, set the article template to default-per-6-flessen and the minimum order to 6, and it worked!
But when I combine the code for the normal cart with this above, it isn't working anymore.

The file components/com_virtuemart/assets/js/vmprices6.js so far:
if(typeof Virtuemart==="undefined")

var Virtuemart = {
setproducttype : function(form,id){
var $ = jQuery ;
form.view = null ;
var datas = form.serialize(),
prices = $("#productPrice"+id);
datas = datas.replace("&view=cart", "");
prices.fadeTo("fast", 0.75);
$.getJSON(window.vmSiteurl+'index.php?option=com_virtuemart&nosef=1&view=productdetails&task=recalculate&format=json'+window.vmLang,encodeURIComponent(datas),
function(datas, textStatus) {
prices.fadeTo("fast", 1);
// refresh price
for(key in datas) {
var value = datas[key];
if (value!=0) prices.find("span.Price"+key).show().html(value);
else prices.find(".Price"+key).html(0).hide();
}
});
return false; // prevent reload
},
productUpdate : function(mod) {
var $ = jQuery ;
$.ajaxSetup({ cache: false })
$.getJSON(window.vmSiteurl+"index.php?option=com_virtuemart&nosef=1&view=cart&task=viewJS&format=json"+window.vmLang,
function(datas, textStatus) {
if (datas.totalProduct >0) {
mod.find(".vm_cart_products").html("");
$.each(datas.products, function(key, val) {
$("#hiddencontainer .container").clone().appendTo(".vmCartModule .vm_cart_products");
$.each(val, function(key, val) {
if ($("#hiddencontainer .container ."+key)) mod.find(".vm_cart_products ."+key+":last").html(val) ;
});
});
mod.find(".total").html(datas.billTotal);
mod.find(".show_cart").html(datas.cart_show);
}
mod.find(".total_products").html(datas.totalProductTxt);
}
);
},
sendtocart : function (form){
var $ = jQuery ;
if (Virtuemart.addtocart_popup ==1) {
$.ajaxSetup({ cache: false })
var datas = form.serialize();
$.getJSON(vmSiteurl+'index.php?option=com_virtuemart&nosef=1&view=cart&task=addJS&format=json'+vmLang,encodeURIComponent(datas),
function(datas, textStatus) {
if(datas.stat ==1){
//var value = form.find('.quantity-input').val() ;
var txt = form.find(".pname").val()+' '+vmCartText;
$.facebox.settings.closeImage = closeImage;
$.facebox.settings.loadingImage = loadingImage;
$.facebox.settings.faceboxHtml = faceboxHtml;
$.facebox({ text: datas.msg +"<H4>"+txt+"</H4>" }, 'my-groovy-style');
} else if(datas.stat ==2){
var value = form.find('.quantity-input').val() ;
var txt = form.find(".pname").val();
$.facebox.settings.closeImage = closeImage;
$.facebox.settings.loadingImage = loadingImage;
$.facebox.settings.faceboxHtml = faceboxHtml;
$.facebox({ text: datas.msg +"<H4>"+txt+"</H4>" }, 'my-groovy-style');
} else {
$.facebox.settings.closeImage = closeImage;
$.facebox.settings.loadingImage = loadingImage;
$.facebox.settings.faceboxHtml = faceboxHtml;
$.facebox({ text: "<H4>"+vmCartError+"</H4>"+datas.msg }, 'my-groovy-style');
}
if ($(".vmCartModule")[0]) {
Virtuemart.productUpdate($(".vmCartModule"));
}
});
$.ajaxSetup({ cache: true });
} else {
form.append('<input type="hidden" name="task" value="add" />');
form.submit();
}
},
product : function(carts) {
carts.each(function(){
var cart = jQuery(this),
addtocart = cart.find('input.addtocart-button'),
plus   = cart.find('.quantity-plus'),
minus  = cart.find('.quantity-minus'),
plus6  = cart.find('.quantity-plus6'),
    minus6 = cart.find('.quantity-minus6'),
select = cart.find('select'),
radio = cart.find('input:radio'),
virtuemart_product_id = cart.find('input[name="virtuemart_product_id[]"]').val(),
quantity = cart.find('.quantity-input');

addtocart.click(function(e) {
Virtuemart.sendtocart(cart);
return false;
});
plus.click(function() {
var Qtt = parseInt(quantity.val());
if (Qtt != NaN) {
quantity.val(Qtt + 1);
Virtuemart.setproducttype(cart,virtuemart_product_id);
}

});
minus.click(function() {
var Qtt = parseInt(quantity.val());
if (Qtt != NaN && Qtt>1) {
quantity.val(Qtt - 1);
} else quantity.val(1);
Virtuemart.setproducttype(cart,virtuemart_product_id);
});
select.change(function() {
Virtuemart.setproducttype(cart,virtuemart_product_id);
});
radio.change(function() {
Virtuemart.setproducttype(cart,virtuemart_product_id);
});
quantity.keyup(function() {
Virtuemart.setproducttype(cart,virtuemart_product_id);
});

plus6.click(function() {
var Qtt = parseInt(quantity.val());
if (Qtt != NaN) {
quantity.val(Qtt + 6);
Virtuemart.setproducttype(cart,virtuemart_product_id);
}

});
minus6.click(function() {
var Qtt = parseInt(quantity.val());
if (Qtt != NaN && Qtt>6) {
quantity.val(Qtt - 6);
} else quantity.val(6);
Virtuemart.setproducttype(cart,virtuemart_product_id);
});
select.change(function() {
Virtuemart.setproducttype(cart,virtuemart_product_id);
});
radio.change(function() {
Virtuemart.setproducttype(cart,virtuemart_product_id);
});
quantity.keyup(function() {
Virtuemart.setproducttype(cart,virtuemart_product_id);
});
});

}
};
jQuery.noConflict();
jQuery(document).ready(function($) {

Virtuemart.product($(".product"));

$("form.js-recalculate").each(function(){
if ($(this).find(".product-fields").length) {
var id= $(this).find('input[name="virtuemart_product_id[]"]').val();
Virtuemart.setproducttype($(this),id);

}
});
});



Since I'm no scripter, can someone please tell me where I went wrong?
Title: Re: Multiple Quantity Question
Post by: Lockerbie on May 30, 2012, 21:34:19 PM
I'm sorry this is beginning to become some sort of monologue, but this does work!  :D

Yesterday it didn't work at first, but after changing the name of 'default-per-6-flessen.php' to 'per6flessen.php', it did exactly what I wanted!
One thing I forgot, is editting vmsite-ltr.css, in about line 43:
span.quantity-controls input.quantity-plus{background:url(../images/vmgeneral/quantity-controls.png) repeat-x;margin-bottom:2px;}
span.quantity-controls input.quantity-minus{background:url(../images/vmgeneral/quantity-controls.png) repeat-x;background-position:15px 0;}

add the new stylenames like this:
span.quantity-controls input.quantity-plus,
span.quantity-controls input.quantity-plus6{background:url(../images/vmgeneral/quantity-controls.png) repeat-x;margin-bottom:2px;}
span.quantity-controls input.quantity-minus,
span.quantity-controls input.quantity-minus6{background:url(../images/vmgeneral/quantity-controls.png) repeat-x;background-position:15px 0;}


The only thing now I can't figure out is how to adjust things so, that in the cartpage, the visitor can only add/subtract quantities of 6 products when buying wine in boxes, and he can add/subtract quantities of 1 when buying 'single-bottles-wines'.
Please, is there someone who can help me a bit further with this?
Title: Re: Multiple Quantity Question
Post by: sander_v_bergen on May 31, 2012, 09:58:50 AM
Hi there,

I'm having the exact same issue. Good to hear that you found (or are on the way of finding) a solution that works for you.

Personaly I don't think that this will work for my webshop. It's a lot of extra work (creating child products, calculating prices, etc.) and a dropdown list 'restricts' you to a max. number (yes you can set the max to 500, but that would be ugly).
Another thing is that you can't change/update the quantity in the cart.

If I find another way I will let you know.

-------------

Regarding the quantity box and plus/minus still being visible:
You can either change this in the default_addtocart.php (components/com_virtuemart/views/productdetails/tmpl/)
or
by adding display:none; in your css (.quantity-controls, .quantity-box{display:none;})

-Sander
Title: Re: Multiple Quantity Question
Post by: Lockerbie on May 31, 2012, 10:11:29 AM
Hello Sander,

I think you misunderstood:
- the quantity box and plus/minus were gone after my editting, but I wanted them to be visible and I solved that by putting the new classnames in vmsite-ltr.css,
- I removed all child products, because I also think it's ugly having all those childproducts (visible when searching on names), and a lot of work! Not to mention al the manual calculation that could easily go wrong when the client wants to add new products and have to do this himself.

All this is why I try to find another solution. I simply can't believe there isn't, but I'm not sure how to solve the latest problem:

QuoteThe only thing now I can't figure out is how to adjust things so, that in the cartpage (checkout), the visitor can only add/subtract quantities of 6 products when buying wine in boxes, and he can add/subtract quantities of 1 when buying 'single-bottles-wines'.
Please, is there someone who can help me a bit further with this?
Title: Re: Multiple Quantity Question
Post by: sander_v_bergen on May 31, 2012, 10:33:48 AM
Hi Lockerbie,

Ok, I see. I did misunderstood you on that ;).

But having multiple product quantity fields seems a bit odd to me (you have the dropdown (6,12,18,etc. and the normal quantity box (1,2,3,4,5,etc.).
Selecting 6 in the dropdown and 2,3,4 in the quantity box also makes 12,18,24. So why display both?

I can't help you with your last question, but I'm still trying to figure something out myself. So if I have a solution I will let you know.

But the first post of this thread by 'team' isn't that hard to fix, since he needs a fix number for all products (10).
Just edit the vmprices.js:


plus.click(function() {
var Qtt = parseInt(quantity.val());
if (Qtt != NaN) {
quantity.val(Qtt + 10);
Virtuemart.setproducttype(cart,virtuemart_product_id);
}

});
minus.click(function() {
var Qtt = parseInt(quantity.val());
if (Qtt != NaN && Qtt>10) {
quantity.val(Qtt - 10);
} else quantity.val(10);
Virtuemart.setproducttype(cart,virtuemart_product_id);
});


and then change default_addtocart.php:


<?php // Display the quantity box 

    
$stockhandle VmConfig::get('stockhandle''none');
    if ((
$stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($this->product->product_in_stock $this->product->product_ordered) < 10) {
 
?>

<a href="<?php echo JRoute::_('index.php?option=com_virtuemart&view=productdetails&layout=notify&virtuemart_product_id='.$this->product->virtuemart_product_id); ?>"><?php echo JText::_('COM_VIRTUEMART_CART_NOTIFY'?></a>

<?php } else { ?>
<!-- <label for="quantity<?php echo $this->product->virtuemart_product_id?>" class="quantity_box"><?php echo JText::_('COM_VIRTUEMART_CART_QUANTITY'); ?>: </label> -->
    <span class="quantity-box">
<input type="text" class="quantity-input js-recalculate" name="quantity[]" value="<?php if (isset($this->product->min_order_level) && (int) $this->product->min_order_level 0) {
    echo 
$this->product->min_order_level;
} else {
    echo 
'10';
?>
" />


So basically change all 1 to 10.

EDIT: And you should change the input fields to 'readonly'
Title: Re: Multiple Quantity Question
Post by: Lockerbie on May 31, 2012, 10:43:48 AM
Yep!
But I'm not displaying both options. The dropdown is gone with the child products.
I'm just using 2 different templates for the productdetails-page: 1 for selling single bottles of wine, and 1 for selling wine in boxes of 6 bottles. This last one is used as a page-override.
Title: Re: Multiple Quantity Question
Post by: sander_v_bergen on May 31, 2012, 14:06:18 PM
I'm at the exact point as you atm. Everything is working except for the cart page.

I'm considering to completely disable changing quantity in cart, although that wouldn't be user-friendly..
Let me know if you find a solution for this :).
Title: Re: Multiple Quantity Question
Post by: Lockerbie on June 01, 2012, 17:15:45 PM
So far I've found out things probably have to be adjusted in components/com_virtuemart/views/cart/tmpl/default_pricelist.php
At least, this is where the layout of the cart is build.

I'm looking for a way to solve the quantity-question and/or attach the quantity/updatebuttons from the productdetailspage to the checkoutpage.
This probably means that you'll somehow have to put a clue about some products being sold as single and others as a sixpack (seperate templates again? or something in the default_pricelist.php?), or is this being passed through with all productdetails already? When visiting the checkoutpage after putting a product in the cart, the quantities are right, but the visitor can change them in any chosen number and that's not what we want.

Please, can anyone help me/us a bit further?
Title: Re: Multiple Quantity Question
Post by: Lockerbie on June 02, 2012, 00:49:50 AM
Psst Sander: you can get the minimum quantity active in the cartpage/checkout, simply by changing a class.
In components/com_virtuemart/views/cart/tmpl/default_pricelist.php, about line 152, change:

<input type="text" title="<?php echo  JText::_('COM_VIRTUEMART_CART_UPDATE'?>" class="inputbox" size="3" maxlength="4" name="quantity" value="<?php echo $prow->quantity ?>" />

to:

<input type="text" title="<?php echo  JText::_('COM_VIRTUEMART_CART_UPDATE'?>" class="quantity-input js-recalculate" size="3" maxlength="4" name="quantity" value="<?php echo $prow->quantity ?>" />

This is working both for quantities of 1 and 6 bottles.

The thing about the arrows, or ordering in sixpacks I still don't get, and I'm afraid I won't find it.
I really hope someone out there could help with this! Please?
Title: Re: Multiple Quantity Question
Post by: Lockerbie on June 03, 2012, 12:25:55 PM
Okay, same question, different approach...
In VM1 it was possible to use 'Drop down box values': a start, end and a 'step value', see the image I found on the net:

(http://www.joomlalms.com/images/lms_help_new/virtue7.png)

In VM2 there is a 'start value' and an 'end value'. Only thing missing is this 'step value'.
Wouldn't it be possible to add this to the parameters on the product details? And if so: how to do this?
Title: Re: Multiple Quantity Question
Post by: Lockerbie on June 13, 2012, 10:34:45 AM
Still trying to find a solution for this. We really need this, especially since the client has indicated he wants the shipping costs for orders above 24 bottles to be free.
So we do need to 'count' the bottles, not the boxes.

I know what we need, but not how to script this. We need something like:

- if buying single bottles-->number of bottles in cart can be added/subtracted by 1 (already by default),
- if buying wine in boxes of 6 bottles-->number in cart can only be multiplied/divided by 6.

Please, can somebody give me a clue on how to do this?

*********************************************
Edit:
It's been done before: http://www.codingforums.com/showthread.php?t=182466,
Even with VM1, see:   http://forum.virtuemart.net/index.php?topic=51454.0

Now we need just to figure out how to put something like these codes in which files...
Title: Re: Multiple Quantity Question
Post by: yayo76 on June 21, 2012, 10:14:16 AM
Quote from: sander_v_bergen on May 31, 2012, 10:33:48 AM
Hi Lockerbie,

Ok, I see. I did misunderstood you on that ;).

But having multiple product quantity fields seems a bit odd to me (you have the dropdown (6,12,18,etc. and the normal quantity box (1,2,3,4,5,etc.).
Selecting 6 in the dropdown and 2,3,4 in the quantity box also makes 12,18,24. So why display both?

I can't help you with your last question, but I'm still trying to figure something out myself. So if I have a solution I will let you know.

But the first post of this thread by 'team' isn't that hard to fix, since he needs a fix number for all products (10).
Just edit the vmprices.js:


plus.click(function() {
var Qtt = parseInt(quantity.val());
if (Qtt != NaN) {
quantity.val(Qtt + 10);
Virtuemart.setproducttype(cart,virtuemart_product_id);
}

});
minus.click(function() {
var Qtt = parseInt(quantity.val());
if (Qtt != NaN && Qtt>10) {
quantity.val(Qtt - 10);
} else quantity.val(10);
Virtuemart.setproducttype(cart,virtuemart_product_id);
});


and then change default_addtocart.php:


<?php // Display the quantity box 

    
$stockhandle VmConfig::get('stockhandle''none');
    if ((
$stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($this->product->product_in_stock $this->product->product_ordered) < 10) {
 
?>

<a href="<?php echo JRoute::_('index.php?option=com_virtuemart&view=productdetails&layout=notify&virtuemart_product_id='.$this->product->virtuemart_product_id); ?>"><?php echo JText::_('COM_VIRTUEMART_CART_NOTIFY'?></a>

<?php } else { ?>
<!-- <label for="quantity<?php echo $this->product->virtuemart_product_id?>" class="quantity_box"><?php echo JText::_('COM_VIRTUEMART_CART_QUANTITY'); ?>: </label> -->
    <span class="quantity-box">
<input type="text" class="quantity-input js-recalculate" name="quantity[]" value="<?php if (isset($this->product->min_order_level) && (int) $this->product->min_order_level 0) {
    echo 
$this->product->min_order_level;
} else {
    echo 
'10';
?>
" />


So basically change all 1 to 10.

EDIT: And you should change the input fields to 'readonly'

Hi,how I can to set the input field to read only?
thank you.
Title: Re: Multiple Quantity Question
Post by: yayo76 on June 22, 2012, 10:01:25 AM
I solved it:
in the file /components/com_virtuemart/views/productdetails/tmpl/default_addtocart.php line 74 add readonly="readonly" so the field is not editable.

Instead for the cart modify the file in /components/com_virtuemart/views/cart/tmpl/default_pricelist.php line 303 add readonly="readonly" so the field is not editable.
Title: Re: Multiple Quantity Question
Post by: Lockerbie on June 22, 2012, 12:21:33 PM
Hello Yayo76,

Yes, it could be a solution to set the input field to 'readonly', but I don't think it's very customer friendly... Each time they decide they want another number of products, they have to go back to the shop to add some. Or they have to delete the products from the cart, if they want a number less than they first put in the cart.

***

Perhaps there's another way?
This morning, I got a reply to my question in the VM-LinkedIn-group:

QuoteAbid Hussain • salaam,

This is not a readymade solution for virtuemart, but if you can find out the cart page Qty update form : you put in the following javascript and it will do. Insha Allah
<html>
<head>
<title></title>
<script type="text/javascript">
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;

return true;
}

function check6(obj) {
// use the modulus operator '%' to see if there is a remainder
if (obj.value % 6 != 0) {
alert('The number you entered is not divisible by 6');
obj.value = 6;
return false;
}
return true;
}
</script>
<meta name="" content="">
</head>
<body>
<form id="frmQty" action="" method="post">
<input type="text" onblur="check6(this);" onkeypress="return isNumberKey(event);"/>
</form>
</body>
</html>

Not sure which file this should be put into yet, or in which part, but it looks like we're almost getting there!
I have to go now, will try later. But off course if you'll find it first, please let us know.
Title: Re: Multiple Quantity Question
Post by: Lockerbie on June 25, 2012, 11:30:07 AM
Allright, so far Abid's code seems to work:
I've put his code in default_pricelist.php, and now the number in cart can't be changed to something not divisable by 6 anymore!

Unfortunately, this also counts for the other wines that are sold as singles bottles... Help! How to go further with this?
Title: Re: Multiple Quantity Question
Post by: Lockerbie on June 25, 2012, 17:55:25 PM
Yep, It's me again... Strange things happen:

1. When using the code above in components/com_virtuemart/views/cart/tmpl/default_pricelist.php (templates/TEMPLATENAME/html/com_virtuemart/cart/default_pricelist.php) this does work, but only when you click the updatebuttons after changing the number. When you click 'enter' instead, the number just changes without any errormessage showing up!
This is the case in FireFox 13.0.1. In IE 9.0.8 the error shows up both when clicking the updatebuttons and 'enter', but after that, the number still does change!
(Perhaps this 'alert'-thing has to be changed into something else?)

2. When using the code above, ALL wines are being sold as 6-packs, which is not the case here. There are some wines that are being sold as single bottles.

As for #2., I tried to solve this by expanding the template (so to say). Instead of default_pricelist.php, I changed this name to 'default_pricelist6.php' and figured out where this file is being called. So I had to change cart/tmpl/default.php and cart/view_html.php too, but got stuck again.

I know (hope) I'm very close, but don't know how it get it all right in the end. And the strange problem with #1. that's a whole other issue.

Please, is there anyone who can help me/us with this?
Title: Re: Multiple Quantity Question
Post by: Milbo on June 30, 2012, 12:35:14 PM
Hmmm, sorry I do not read your code now.

But to add quantity steps is a nice idea. The idea of john is also good.
Title: Re: Multiple Quantity Question
Post by: Ramesh0544 on July 07, 2012, 13:29:02 PM
Hi all,
         Is there any option to variate the prices based on the quantity and type of the product in the virtue mart 2.0.8 version.

Thanks you.
Title: Re: Multiple Quantity Question
Post by: Rtaxerxes on July 09, 2012, 13:24:36 PM
I would also like something like this, and almost moved to Hikashop because of it. Hika can do it, perhaps if we had a look at their code?
Title: Re: Multiple Quantity Question
Post by: clabis71 on July 16, 2012, 10:09:34 AM
but the function is described below in "Drop Down Box Value", as VM2, someone knows you give us any clear answer?

Quote from: Lockerbie on June 03, 2012, 12:25:55 PM
(http://www.joomlalms.com/images/lms_help_new/virtue7.png)

Title: Re: Multiple Quantity Question
Post by: webgobe on August 21, 2012, 13:52:44 PM
Guys and girls, here is the (possible) solution for you!
After struggling myself with this problem, and after I developed some code (and was supported in this financially by Lockerbie and Sander - kudos are going to them!) I developed an easy to use and to maintain solution for this problem.
All you need is to go here: http://www.webgobe.ro/download/category/11-component-hacks.html and download the package, and use the information contained in it.
Here's how works, and how can be used:
In total 5 VirtueMart files are modifyed, only one of them is a core file - the VM language file - the rest are VM template files.
In the download package you will find 3 things: a readme file, a file named en-GB.com_virtuemart.ini WICH CONTAINS ONLY THE LINE TO BE ADDED TO THE ORIGINAL file! (Again, don't just overwrite the original, edit it and add the line in this file to the original) and a package containing the 4 template files modified, arranges in correct folders, so you can simply unpack it and overwrite with them the ones on your server. You can find more details in the readme.
How it works?
All your products are working as prior applying this hack. If you want some of your products to be sold in sixpacks - as Lockerbie wanted - them in the admin interface you need to set the minimum porchase amount for that product to 6.
And that's all! From this very moment this product can be added to the cart (or the amounts in cart can be modifyed) only using multiples of this amount - in our example multiples of 6.
Currently the hack supports quantities up to 14, but can be easily amended to support ANY number.
It's the first release, I will try to make it much more flexible (to support easily ANY number) but is the easiest way to accomplish the goal up to date, I guess.
Title: Re: Multiple Quantity Question
Post by: bladerz on September 03, 2012, 22:47:04 PM
Thank you for this hack, webgobe!
I just implemented it on the new VM 2.0.10 and implemented the change in my template's css file. It works when updating the quantity in the cart - the message "You can buy this product only in multiples of X pieces!!" is displayed. Unfortunately it doesn't seem to do anything in the product details page. I can still add whatever quantity I select there.
Any ideas?

Update: Since I'm not using the default VM template I had to modify the following file - /templates/my_template_name/html/com_virtuemart/productdetails/default.php
In the beginning I added:
if (isset($this->product->min_order_level))
        $step=$this->product->min_order_level;
else
        $step=1;
if($step==0)
        $step=1;


and further in the file changed:
<span class="quantity-controls js-recalculate">
                <input type="button" class="quantity-controls quantity-plus<?php echo $step?>" />
                <input type="button" class="quantity-controls quantity-minus<?php echo $step?>" />
(just to add "<?php echo $step?>" )

Thanks again to webgobe for the hack!
Title: Re: Multiple Quantity Question
Post by: webgobe on September 11, 2012, 09:06:27 AM
Be welcome! - And remember - sharing is caring ;)
Title: Re: Multiple Quantity Question
Post by: goldenprizm on October 23, 2012, 09:19:01 AM
I would like to use your hack....

The current version only supports amounts from 1 to 14.  Some of my order multiples are higher than 14.
Could you assist me on this or lead me in the right direction
Title: Re: Multiple Quantity Question
Post by: webgobe on October 23, 2012, 09:31:31 AM
You need to modify the VM template's .js file (it is in the download package). There are some lines added to support the quantitis up to 14 - one line for each quantity step. You need to add similar lines as you need. That's all.
Title: Re: Multiple Quantity Question
Post by: clabis71 on November 19, 2012, 23:37:35 PM
For the developers, but this solution "drop down box value", which was scheduled at version 1.1.9, you can also have it in version 2?
It seems like a trivial thing but it is a very useful function, which many ask


[attachment cleanup by admin]
Title: Re: Multiple Quantity Question
Post by: Lockerbie on November 20, 2012, 10:44:31 AM
Hello Clabis71,

See WebGobe's reply at #34. That's the solution that worked for me! And yep: we've put this in a VM2-setting.
Good luck!
Title: Re: Multiple Quantity Question
Post by: webgobe on November 20, 2012, 11:14:38 AM
An update - I have somewhere an enhanced version, wich has no limitation of 14 max number to be set, and there are less files to modify. I will add that to upload package ASAP.
Title: Re: Multiple Quantity Question
Post by: clabis71 on November 21, 2012, 15:06:58 PM
My problem is related to the speech that needs to be set only for some products so easy to use for anyone in the administration side.
In practice there are all products of the same, for some this must be true for others should use the VM in the standard configuration.
If I am confirmed I can do this, then try this solution.
Title: Re: Multiple Quantity Question
Post by: webgobe on November 21, 2012, 16:45:20 PM
This is set up for each products individually.
Title: Re: Multiple Quantity Question
Post by: Milbo on November 27, 2012, 09:45:23 AM
Quote from: webgobe on August 21, 2012, 13:52:44 PM
Guys and girls, here is the (possible) solution for you!
After struggling myself with this problem, and after I developed some code (and was supported in this financially by Lockerbie and Sander - kudos are going to them!) I developed an easy to use and to maintain solution for this problem.
All you need is to go here: http://www.webgobe.ro/download/category/11-component-hacks.html and download the package, and use the information contained in it.
Here's how works, and how can be used:
In total 5 VirtueMart files are modifyed, only one of them is a core file - the VM language file - the rest are VM template files.
In the download package you will find 3 things: a readme file, a file named en-GB.com_virtuemart.ini WICH CONTAINS ONLY THE LINE TO BE ADDED TO THE ORIGINAL file! (Again, don't just overwrite the original, edit it and add the line in this file to the original) and a package containing the 4 template files modified, arranges in correct folders, so you can simply unpack it and overwrite with them the ones on your server. You can find more details in the readme.


Interested to add it to the core?
Title: Re: Multiple Quantity Question
Post by: webgobe on November 27, 2012, 11:31:28 AM
Why not ;)
Title: Re: Multiple Quantity Question
Post by: Lockerbie on November 27, 2012, 12:17:38 PM
Way to go Webgobe!
It should have been in the code a long time ago, I guess. That could have saved us all much time and frustrations.
I'm glad I've found a part of this adjustment, but I'm even more glad you helped me and completed this so it could work as wanted!  ;)
Title: Re: Multiple Quantity Question
Post by: turkish74 on January 31, 2013, 12:27:22 PM
Hi all

Milbo said (Reply #44) that will may be implemented in VM. Is that on the way or should i use the "hack" from webgobe ?
I prefer that this implemented in the VM.

Cheers
Title: Re: Multiple Quantity Question
Post by: Milbo on January 31, 2013, 14:52:48 PM
Thanks turkish74 for your bump. I will contact webgobe. Thank you.
Title: Re: Multiple Quantity Question
Post by: webgobe on January 31, 2013, 16:40:23 PM
Here I am ;)
Title: Re: Multiple Quantity Question
Post by: turkish74 on January 31, 2013, 20:17:42 PM
Thank you Milbo.

We have a big Hostin Provider (hostpoint.ch) in Switzerland, and they will shutdown all J1.5 Installations on 6 April 2013.

I migrated one shop with this multiple Quantity Steps features from 1.1.9. I you have feeling, when this feature will be availabe, so then i can arrange me.

If you said this is not possible until april 2013, so then i have to look for a workaround. Any input will be helpful.

Cheers

Title: Re: Multiple Quantity Question
Post by: webgobe on January 31, 2013, 20:42:33 PM
You will have it in matter of days. Hopefully this weekend. Contact me, if you want it faster, to send you the hack,
I need to make some changes in order to be included in core distribution, this takes a bit of time. But I think, that worth waiting couple of days.
Title: Re: Multiple Quantity Question
Post by: turkish74 on February 13, 2013, 11:34:08 AM
Hi Milbo

Is there a new Version of Virtuemart on the way?

Cheers
Title: Re: Multiple Quantity Question
Post by: mikedunn on April 06, 2013, 05:44:17 AM
Hi .
I hope no one minds me jumping on this thread.

Like Lockerbie I have been trying to find a solution to this problem for a long time. This thread is as close as I have found to a solution but it is not quite there. 

What I need is a check to see if the TOTAL number of bottles at checkout is a multiple of 12. As far as I can see the script so graciously provided by webgobe checks for multiples per product in the checkout.

i.e I don't mind if there is 5 of one product and 7 of another just as long as the total is 12 ( or multiples of 12 i.e a carton for shipping)

I have tried to examine the code but my php skills are not that advanced.  Please could someone guide me as how to modify the code to suite my need. I would be forever grateful.

Cheers
Mike

Title: Re: Multiple Quantity Question
Post by: webgobe on April 07, 2013, 18:54:41 PM
Hmm, is not completely impossible, but needs heavy programming... A dirty, relatively quick workaround will be to store the number of bottles  in a session variable, to update it which each addon to cart or quantity modification in the cart, and run the check against the pre established number. But the solution currently implemented can be used just as a starting point. The possible situations in your scenario are too complex to be handled by using the implemented trickery.
Title: Re: Multiple Quantity Question
Post by: mikedunn on April 16, 2013, 05:44:35 AM
Thank you very much for the reply.

Sorry for the delay in responding I had to do some quick learning to get my head around your suggestions.

I have started a new thread here as I think the topic is sufficiently different.

https://forum.virtuemart.net/index.php?topic=114846.0

If you could please have a look and give me some more advice I would be very grateful.

Cheers
Mike
Title: Re: Multiple Quantity Question
Post by: John2400 on April 16, 2013, 09:45:29 AM
mikedunn,

I cannot help you on the coding but I just wonder if the cart was set to only work if the cart was divisible by 12 and give a whole number?

If it was not divisible then it would pop up a message and say - you must buy in multiples of 12?

just thinking -

Title: Re: Multiple Quantity Question
Post by: mikedunn on April 16, 2013, 11:01:29 AM
Thanks for the reply. I have been trying to think of alternate solutions as well.

I think you idea might be too limiting. I need the popup to occur when the confirm order button is pushed not before. ( although a warning is echoed inline before that)

i.e it is ok to add 7 bottles to the cart , view the cart, then continue shopping and add another 5. The error is only displayed if the confirm button is pressed and the final total of bottles is not a multiple of 12.

I am nearly there with my solution, I just need it to update.

Thanks for contributing though.

Cheers
Mike
Title: Re: Multiple Quantity Question
Post by: mediastreet on May 19, 2013, 18:03:40 PM
Hi there,

I can't get the link to http://webgobe.com/download/category/11-component-hacks.html to work (takes me to a 404). Is the solution still possible with the more recent versions of VM?

Thanks in advance,
Title: Re: Multiple Quantity Question
Post by: rainman2000 on May 19, 2013, 20:30:32 PM
This, my friends, is another example of Virtuemart sadly being a piece of broken software.

Over the past 4 years we have invested heavily in Virtuemart. A few months ago we decided to migrate from VM 1.1.9 to VM 2 to the tune of thousands of dollars. I was forewarned to abandon Virtuemart because it was in a death spiral but because we had so much already invested in the platform I decided to stick with it. However, in hindsight, I should have heeded those warnings and this thread is a perfect example of why. How does something as simple and basic as a customizable drop-down quantity box not make it in the core of VM 2 when it was so clear in VM 1? It's like an auto maker going from a decent vehicle one year to creating a vehicle the next year and not including a rear view mirror; a seemingly small addition that can result in a lot of frustration and headache if it's not there. And now it needs to become an "add-on" better known as a hack. Part of our reasoning for moving to VM 2 was so we would have code that wasn't hacked up. Well so much for that bright idea. Hikashop, Shopify, or even Magento Community is looking better by the day.

-Rainman
Title: Re: Multiple Quantity Question
Post by: webgobe on May 20, 2013, 09:16:54 AM
Checjking what a heck is with download URL - might be my fault.
Back to basics:
The multiple quantities hack is for long part of the core allready. Just download the latest, and you have it,  - with the risk to repeat myself - in the core.
I don't want to comment the rest...
Title: Re: Multiple Quantity Question
Post by: webgobe on May 20, 2013, 09:25:16 AM
BTW, the download is here:
http://webgobe.com/downloads/joomla-1-7/component-hacks/index.html
You need to register and login in if you want to download it. I migrated my site in mean time to latest Joomla, and not all the URL's are matching the old ones - yet. It's a work on progress - as the VM2...
and that's the ideea - it's an open source thing. You don't like some facets of it: contribute to it, to make it better... or choose another open source - or commercial - software. Nobody stops you. :-*
PS. BTW, I heavily invested in this piece of software too - in the past 10 years. At that time was called Mambo phpShop - and obviously has been running under Mambo. And yes, there are some parts of it I don't really like. So what???
Title: Re: Multiple Quantity Question
Post by: AH on May 20, 2013, 15:45:19 PM
Webgobe

I agree, all shops have good and not so good elements and if opensource you can "modify" if required.

As of an investment of thousands of dollars, seems pretty cheap compared to commercial offerings of e-com platforms. 

I also agree that there are some suprising things that have been left on the shelf for VM2 that were in VM1.1 which makes the transition a much bigger decision that it should have been. 
Title: Re: Multiple Quantity Question
Post by: dangelo on June 14, 2013, 16:26:58 PM
Trying to download the hack from your page but i can not register my self...
Title: Re: Multiple Quantity Question
Post by: webgobe on June 14, 2013, 17:08:08 PM
bottom right, privacy settings. You need to accept use of cookies to be able to register. Sorry, it is a legal requirement by EU.
Title: Re: Multiple Quantity Question
Post by: teddyfresco on September 26, 2014, 20:41:57 PM
Hi webgobe and others, do you know if you solution currently works with latest 2 version 2.6.10?
Thanks and regards
Title: Re: Multiple Quantity Question
Post by: Milbo on September 27, 2014, 08:14:42 AM
The js got updated in VM3. Please test there.
Title: Re: Multiple Quantity Question
Post by: webgobe on September 27, 2014, 18:51:00 PM
As Milbo said - you don't need the hack anymore, the trick is now part of the core code, should work - I did not tested with the current release, but in past ones worked withouth problems.
Title: Re: Multiple Quantity Question
Post by: drchance on October 17, 2014, 23:19:39 PM
Can someone summarize the original question to this two year old thread? The very first message back in 2012 is exactly what I'm looking at on a VirtueMart 2.6.6 installation. It is simply that I really want the "dropdown quantity box" like I had in 1.1.8. The current quantity box, while configured with a "step" of 5, will start at 5 but will allow a user to then hit the "+" key and enter a quantity of 6. In addition, I have the quantity max set to 100 but a user can continue to hit the "+" arrow and go over 100 ... he can't add it to the cart but the user won't know that until they hit the "add to cart" button. The dropdown quantity box was a little more eloquent solution way to select something like quantities of 5 ... and it kept the quantity in the proper min-max range.

As I read through the thread I noticed the "webgobe hack" recommendation ... and then I read "the js got updated in VM3". I'm not anxious about updating the 2.6.6 site this guy has but I really need to get past this problem since it is one of the final problems we have to work through. Any input at all would be greatly appreciated.

VirtueMart 2.6.6
PHP 5.3.28
Joomla 2.5.22

Thanks  - Donnie
Title: Re: Multiple Quantity Question
Post by: John2400 on October 19, 2014, 12:57:14 PM
Ok, at the moment 2.9.9 versions still work the same way as you described. It is only after you hit save the it says " you can only save in multiples of 5" eg. So it rounds to the nearest 5.


This option may appear in later versions or be part of an extension. So not changed yet.
Title: Re: Multiple Quantity Question
Post by: drchance on October 20, 2014, 21:14:33 PM
hey john2400 ... I'm not sure I read your reply correctly. Are you saying that versions 2.9.9 (and 2.10?) have the "quantity dropdown box" like we had back in 1.1.8?

And yes, if I was adventurous enough and could get off my lazy butt I would write an extension specifically for adding features and embellishment to the "quantity box" ... maybe tomorrow :)

Thanks - Donnie