Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Global discount


Guest

Recommended Posts

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.

Link to comment
Share on other sites

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.

Treasurer MFC

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Treasurer MFC

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...