Forums / All Other Contributions/Addons / order quantity discount calculation

order quantity discount calculation

Locked

Views: 2,473

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
11 Dec 2006, 6:46 AM
#1
ecomm avatar

ecomm

New Zenner

Join Date:
Oct 2006
Posts:
6
Plugin Contributions:
0

order quantity discount calculation

hi guys and gals
Running zc 1.3.6
Installed order quantity mod which seems to work fine untill you manually add the totals up and relize it dont add up correctly
eg
Sub total $81.45 correct
shippin: $12.10 correct
discount -$8.14 correct
tax @10% $7.69 correct
total $84.60 incorrect when you add this up it should be $85.41

my settings are
uantity Discount
This module is installed - version 1.3
true
Sort Order
295
Include Tax
true
Re-calculate Tax
Standard
Discount Units
percentage
Discount Basis
Total Items in Cart
Discount Level 1
5
Discount Amount 1
10

Now if I change recalulate tax to "none" this changes my total to correct amount but obviously leaves my tax at original calculated amount
Sub total $81.45 correct
shippin: $12.10 correct
discount -$8.14 correct
tax @10% $8.50 correct
total $85.41
any ideas
thanks

11 Dec 2006, 11:07 PM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: order quantity discount calculation

I can't dup this. Using your settings, I get the right numbers.

Do you display prices with taxes included? Any other non-US style
settings I may not have tested?

Scott

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

12 Dec 2006, 12:48 AM
#3
ecomm avatar

ecomm

New Zenner

Join Date:
Oct 2006
Posts:
6
Plugin Contributions:
0

Re: order quantity discount calculation

I do display prices including tax
Have only one tax setup in one zone which is 10%

Arhhh just spotted wats happening!! not that i know how to fix it but you guys might.
It seems that when i choose to recalulate tax (which is 10%) its adding 10% to the discount price even though it doesnt show it then taking that figure off thoe total price.
EG
$362.00
Sub-Total:

  $12.10
 Flat Rate (Best Way):


  -$36.19 if you were to add 10% here $39.80 so 362+12.10-39.80= 334.30

 Quantity Discount:


  $30.39
 GST 10%:


  $334.29   this should be  337.91

 Total:

Hope this is explained ok
Also i have another zen cart setup and i just installed this mod there and it does the same thing??
Thanx in advanced
Michael

12 Dec 2006, 10:45 AM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: order quantity discount calculation

OK. Try replacing process() in ot_quantity_discount.php with this:

    function process() {
       global $db, $order, $currencies;
       $od_amount = $this->calculate_deductions();
       if ($od_amount['total'] > 0) {
         $show_amt = $od_amount['total'];
         reset($order->info['tax_groups']);
         while (list($key, $value) = each($order->info['tax_groups'])) {
           $tax_rate = zen_get_tax_rate_from_desc($key);
           if ($od_amount[$key]) {
             $order->info['tax_groups'][$key] -= $od_amount[$key];
             if (DISPLAY_PRICE_WITH_TAX == 'true') {
                $show_amt += $od_amount[$key];
                $tax_deduct = $od_amount[$key] - ($od_amount[$key] * $tax_rate/100);
                $order->info['total'] -=  $tax_deduct;
             } else {
                $order->info['total'] -=  $od_amount[$key];
             }
           }
         }
         $order->info['total'] = $order->info['total'] - $show_amt;
         $this->title = '<a href="javascript:alert(\'' . $this->explanation . '\');">' . $this->title . '</a>';
         $this->output[] = array('title' => $this->title . ':',
         'text' => '-' . $currencies->format($show_amt, true, $order->info['currency'], $order->info['currency_value']),
         'value' => $od_amount['total']);
       }
    }

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

12 Dec 2006, 11:36 AM
#5
ecomm avatar

ecomm

New Zenner

Join Date:
Oct 2006
Posts:
6
Plugin Contributions:
0

Re: order quantity discount calculation

thanks for the reply
seems you are sorta getting closer to the answer
ok still the discount is a little off
eg
sub total 100
disc. -10
tax 10% 8.18
total 89.18

as you can see the total is still out not by much but the more you add the more it is out

the tax seems to be calculating on the correct total amount of the total eg we work out the gst by total
$90/11 =8.18
90-8.18=81.82 exclusive
81.82+10%=90inclusive
thanks again for your time

ps a quick explaination in the code so i know what why this is happening would be great unless it is more than just a couple of lines