News:

Looking for documentation? Take a look on our wiki

Main Menu

Force total order to be in multiple of 12 items

Started by mikedunn, April 16, 2013, 05:41:05 AM

Previous topic - Next topic

mikedunn

Hi,

This is a continuation of a question I asked here:  https://forum.virtuemart.net/index.php?topic=101894.45

I have started a new thread as I think it is sufficiently different from the original to warrant a new topic.

I am trying to set up a check to force order totals to be in multiples of 12 items. The web site is for wine, mixed dozens are allowed and freight is free but must be in multiples of 12 bottles.

http://112.140.180.21/~watersh1/index.php

Joomla 2.5
VM 2.08

Following the advice from the previous thread I have put the following code code into the foreach loop that fills the cart with the products in

/public_html/templates/my_template/html/com_virtuemart/cart/default_pricelist.php


   
$session =& JFactory::getSession();
$session->set( stotal , $total );
$total = 0;


    $i=1;
        foreach( $this->cart->products as $pkey =>$prow ) {

...


    <?php $total += $prow->quantity; ?>


...
}

This works to get the total number of items in the cart.

Then in

/public_html/templates/my_template/html/com_virtuemart/cart/default.php


<?php
$session = JFactory::getSession();
$tot = $session->get('stotal');
if ($tot % 12 != 0) {
                echo  "\n The total number of bottles in your order is not a multiple of 12. Please correct. " ;
                }               
?>

This also works and adds a message stating that the total number is not a multiple of 12.

My problem is that when the amount of products is modified ( and the update button pressed) the calculation is not refreshed. The price total in the cart updates as it should  but not the message related to the number of bottles.   

I can see that this must be related to the update_form() function but I do not know how to go any further.

Any advice on how to proceed wold be greatly appreciated.

Mike


John2400

mikedunn,

Hi since the first lot of postings in the original thread - VM developers created this extension

Might save you a lot of coding - and in the same area is an extension for shipping with a sliding scale.
this was - one type of product it was developed for as wine is a pricy product to ship and sell in samll quantities.

http://extensions.virtuemart.net/products/quantity-related-price-calculation-detail

mikedunn

Hi,
Thanks for the reply. I am having a look at that plugin but I am so very close with my solution. I am sure it is as simple as adding a couple of lines of code to the update_form() function in
/public_html/templates/my_template/html/com_virtuemart/cart/default.php

I am quickly trying to teach myself to solve this problem (while having my client breathing down my neck) but could really use a few pearls of wisdom from some programming gurus.

Cheers
M

mikedunn

Can anyone help me with this? Even point me toward the code that I should be looking at?

Please!

Cheers
Mike