How to update all quantities from the cart page in one click

I was recently asked by one of my customers how he could have a button to save all quantities in the cart in one click.
Indeed his cutomers do recurring orders and have several line items for each order. With the help of our clone order plugin, they can quickly add all the products from a former order to their cart.
However this will copy the quantites over and from time to time, they might want to change the number of each item.


Reviewing all the product lines and clicking on each quantity update button can quickly turn into a long process

It would be nice to have one button to update all quantities at once. Here is a quick solution for this:


This change implies modifying a Virtuemart template file. since you don't want to loose your changes when you upgrade Virtuemart to a newer version, start by copying this file





  • replace YOUR_TEMPLATE by your actual joomla template name
  • you may have to create the folder structure
  • the file might be present already, in this case keep a copy of it and modify the existing one

Locate a good placement for the new button. One common place would be in the table header:

add the following button to the column header of the Quantity / Update column:

<input type="button" class="vmicon vm2-add_quantity_cart" id="updateall"/>

<table class="cart-summary" cellspacing="0" cellpadding="0" border="0" width="100%">
<th align="left"><?php echo JText::_ ('COM_VIRTUEMART_CART_NAME') ?></th>
<th align="left"><?php echo JText::_ ('COM_VIRTUEMART_CART_SKU') ?></th>
<th align="center" width="60px"><?php echo JText::_ ('COM_VIRTUEMART_CART_PRICE') ?></th>
<th align="right" width="140px">
<input type="button" class="vmicon vm2-add_quantity_cart" id="updateall" />
<?php echo JText::_ ('COM_VIRTUEMART_CART_QUANTITY') ?>
/ <?php echo JText::_ ('COM_VIRTUEMART_CART_ACTION') ?>
<?php if (VmConfig::get ('show_tax')) { ?>
<th align="right" width="60px"><?php echo "<span class='priceColor2'>" . JText::_ ('COM_VIRTUEMART_CART_SUBTOTAL_TAX_AMOUNT') . '</span>' ?></th>
<?php } ?>
<th align="right" width="60px"><?php echo "<span class='priceColor2'>" . JText::_ ('COM_VIRTUEMART_CART_SUBTOTAL_DISCOUNT_AMOUNT') . '</span>' ?></th>
<th align="right" width="70px"><?php echo JText::_ ('COM_VIRTUEMART_CART_TOTAL') ?></th>

We will now attach a javascript event to this button to trigger all the quantity updates.

Add the following piece of code at the end of your file:

$js = "
jQuery(document).ready(function($) {
//Update all quantities
$('#updateall').click(function() {
//Find order item lines forms
$('form').has('input[name=task][value=update]').each(function() {
var editForm = $(this);
//we need to submit these forms asynchronously
async: false,
//Finaly relad the page to see the changes

Matukio - Event Management, Booking and Payment Processing.