RE: need a quick help with an order total module
dreamscape <[email protected]>
| Newsgroups | gmane.comp.web.oscommerce.devel |
|---|---|
| Message-ID | <066f2c2ba366594b101b05f329ac2147@osCommerce-Forums> |
This message was sent from: Development
http://forums.oscommerce.com/viewtopic.php?p=162346#162346
----------------------------------------------------------------
thanks Ian,
I sort of got it by looking at your low order fee. but I only have one tax class. Some users may have more than one tax class, so I'd like to update it to MS1 logic for users with more than one class (so it will pick the right class).
here is the code for the part that processes the discounts and applies it to the order total (recalculating subtotal, total, and tax if these attributesa re turned on in the admin):
[code] function process()
{
global $order, $currencies, $cart, $ot_subtotal;
if ($this->calculate_tax == 'true') {
$tod_amount = $this->calculate_discount($order->info['tax']);
}
$od_amount = $this->calculate_discount($this->get_order_total());
if ($od_amount>0)
{
$tax_description = tep_get_tax_description(1, $order->delivery['country']['id'], $order->delivery['zone_id']);
if (MODULE_QTY_DISCOUNT_RATE_TYPE == 'percentage') $title_ext = ' ('.$this->calculate_rate($cart->count_contents()).'%)';
$this->deduction = $od_amount+$tod_amount;
$this->output[] = array('title' => $this->title . $title_ext . ':',
'text' => '<b>-' . $currencies->format($od_amount) . '</b>',
'value' => $od_amount);
$order->info['total'] -= $this->deduction;
$order->info['tax'] -= $tod_amount;
$order->info['tax_groups']["$tax_description"] -= $tod_amount;
if ($this->sort_order < $ot_subtotal->sort_order) {
$order->info['subtotal'] -= $this->deduction;
}
}
}[/code]