Guest Posted August 7, 2006 Share Posted August 7, 2006 Hey all. I'm trying to code a very simple "coupon-like" contrib that'll allow the admin to configure a global discount (ie, 20%) to be calculated after subtotal but before taxes. So far so good, but I can't seem to get it to work. Example code: function process() { global $order, $currencies; if ($this->magic != 1.00) { $this->title = $this->title . " (" . number_format(((1.00 - $this->magic) * 100), 0) . "%)"; $this->desc = 1.00 - $this->magic; $this->output[] = array('title' => $this->title . ':', 'text' => "-" . $currencies->format($order->info['subtotal'] * $this->desc, true, $order->info['currency'], $order->info['currency_value']), 'value' => -$order->info['subtotal'] * $this->desc); } } $this->magic holds the discount number (0.8 for 20%). It doesn't seem to modify the end price at all... doesn't even add to it if I remove the sign. Hope someone can enlighten me... Thanks in advance. Quote Link to comment Share on other sites More sharing options...
boxtel Posted August 7, 2006 Share Posted August 7, 2006 Hey all. I'm trying to code a very simple "coupon-like" contrib that'll allow the admin to configure a global discount (ie, 20%) to be calculated after subtotal but before taxes. So far so good, but I can't seem to get it to work. Example code: function process() { global $order, $currencies; if ($this->magic != 1.00) { $this->title = $this->title . " (" . number_format(((1.00 - $this->magic) * 100), 0) . "%)"; $this->desc = 1.00 - $this->magic; $this->output[] = array('title' => $this->title . ':', 'text' => "-" . $currencies->format($order->info['subtotal'] * $this->desc, true, $order->info['currency'], $order->info['currency_value']), 'value' => -$order->info['subtotal'] * $this->desc); } } $this->magic holds the discount number (0.8 for 20%). It doesn't seem to modify the end price at all... doesn't even add to it if I remove the sign. Hope someone can enlighten me... Thanks in advance. this is not the way to do that, this will only display the discount, not process it. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted August 7, 2006 Share Posted August 7, 2006 this is not the way to do that, this will only display the discount, not process it. So... how do I process it? I've decided to use your contrib... but just for the sake of curiousity. Thanks. Quote Link to comment Share on other sites More sharing options...
boxtel Posted August 7, 2006 Share Posted August 7, 2006 So... how do I process it? I've decided to use your contrib... but just for the sake of curiousity. Thanks. look at the examples, basically every ot module is a class which manipulates the order information. Mostly order subtotals and totals depending on the sort order, then also puts a display out regarding its discount. Many even manipulate the tax deductions. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
insomniac2 Posted August 9, 2006 Share Posted August 9, 2006 There is a contribution called Group Discount v1.4 that you could use to do what you want. I installed it very easily with no problems at all. You can assign a default discount to all customers as a percentage + or - You can assign discount types to each customer You can add and delete discount types in admin Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.