Page 1 of 1

Coupon Total not deducting from Order Total

Posted: Tue Apr 28, 2009 4:14 am
by campbellmac
Version 1.2.6

When using a coupon, whether is be % or fixed amount, the coupon value is correctly being calculated however the order total is not being updated.
coupon_issue.png

coupon_issue.png (37.78 KiB) Viewed 4139 times

Where Campbell's is a 10% coupon.
I'm using a CC payment gateway also

In model/total/coupon the following line should update the total:

Code: Select all

$total -= $discount_total;
But it seems like its being ignored.

All other 'Order Total' extensions are working

Re: Coupon Total not deducting from Order Total

Posted: Tue Apr 28, 2009 4:27 am
by Daniel
you seem to have posted this problem on more than one post.

I have no idea what is happening. This does not happen with any version ihave used so far.

Re: Coupon Total not deducting from Order Total

Posted: Wed Apr 29, 2009 5:30 am
by campbellmac
Yeah not sure what was going on either.

So Ive fixed my problem, its probably not relevant to anyone else but thought I'd note it just incase it happens to anyone.

I removed the total/total as an option and hard coded it as there is always going to be a total

I changed the sort order for this to 100 and this ensures that it always gets summed last.

Also there is a mistake on total/shipping where it references config_coupon_status, this should be config_shipping_status.

Re: Coupon Total not deducting from Order Total

Posted: Wed Apr 29, 2009 8:47 am
by Daniel
thanks for that bug.

Re: Coupon Total not deducting from Order Total

Posted: Wed Jun 10, 2009 4:39 pm
by Antonio Montana
Hi All!
Not sure if this is a problem at all, but i've faced this once applying a checkout totals.

Each of totals has it's sort order which is adjusted in the admin panel.
But this may not affect the actual order of totals being applied to the final value.

Code: Select all

$results = $this->model_checkout_extension->getExtensions('total');
		foreach ($results as $result) {
			$this->load->model('total/' . $result['key']);

			$this->{'model_total_' . $result['key']}->getTotal($total_data, $total, $taxes);
		}

Code: Select all

class ModelCheckoutExtension extends Model {
	function getExtensions($type) {
		$query = $this->db->query("SELECT * FROM extension WHERE `type` = '" . $this->db->escape($type) . "'");
		return $query->rows;
	}
}
So the order of totals list depends not on the actual sort order, but on the way how the list of total extensions is being retrieved from the base.

My problem was that the shipping was not applied to final total, because it's extenision's ID was higher than the final's one.

So:
1) Total's ID changed to the higher value in the database
2)

Code: Select all

class ModelCheckoutExtension extends Model {
	function getExtensions($type) {
		$query = $this->db->query( "SELECT * FROM extension WHERE `type` = '" . $this->db->escape($type) . "' ORDER BY extension_id ASC" );
		return $query->rows;
	}
}
P.S. I've been fixing a store made not by me and had a little time, so I'm not sure about OC's version (some kind of 1.2.* i guess)
and not sure that something is not going wrong after my interruption.
Also this problem may be fixed already, not sure :)

THANKS!

Re: Coupon Total not deducting from Order Total

Posted: Fri Jun 19, 2009 1:52 am
by iuliantoma
Daniel wrote:you seem to have posted this problem on more than one post.

I have no idea what is happening. This does not happen with any version ihave used so far.
This bug is still present for version 1.2.8
in confirm.php i did a hack like this that solves the problem but it must be solved in the core

Code: Select all

foreach ($results as $result) {
			if ($result['key'] != "total") {
				$this->load->model('total/' . $result['key']);
				$this->{'model_total_' . $result['key']}->getTotal($total_data, $total, $taxes);
			}
		}
		
		foreach ($results as $result) {
			if ($result['key'] == "total") {
				$this->load->model('total/' . $result['key']);
				$this->{'model_total_' . $result['key']}->getTotal($total_data, $total, $taxes);
			}
		}
the total is not well calculated because the toatal is not loaded last. please fix

Re: Coupon Total not deducting from Order Total

Posted: Fri Jun 19, 2009 2:06 am
by Daniel
Antonio Montana wrote:Hi All!
Not sure if this is a problem at all, but i've faced this once applying a checkout totals.

Each of totals has it's sort order which is adjusted in the admin panel.
But this may not affect the actual order of totals being applied to the final value.

Code: Select all

$results = $this->model_checkout_extension->getExtensions('total');
		foreach ($results as $result) {
			$this->load->model('total/' . $result['key']);

			$this->{'model_total_' . $result['key']}->getTotal($total_data, $total, $taxes);
		}

Code: Select all

class ModelCheckoutExtension extends Model {
	function getExtensions($type) {
		$query = $this->db->query("SELECT * FROM extension WHERE `type` = '" . $this->db->escape($type) . "'");
		return $query->rows;
	}
}
So the order of totals list depends not on the actual sort order, but on the way how the list of total extensions is being retrieved from the base.

My problem was that the shipping was not applied to final total, because it's extenision's ID was higher than the final's one.

So:
1) Total's ID changed to the higher value in the database
2)

Code: Select all

class ModelCheckoutExtension extends Model {
	function getExtensions($type) {
		$query = $this->db->query( "SELECT * FROM extension WHERE `type` = '" . $this->db->escape($type) . "' ORDER BY extension_id ASC" );
		return $query->rows;
	}
}
P.S. I've been fixing a store made not by me and had a little time, so I'm not sure about OC's version (some kind of 1.2.* i guess)
and not sure that something is not going wrong after my interruption.
Also this problem may be fixed already, not sure :)

THANKS!
Sorting is done on the checkout confirm page!!

Code: Select all

		$results = $this->model_checkout_extension->getExtensions('total');
		
		foreach ($results as $result) {
			$this->load->model('total/' . $result['key']);

			$this->{'model_total_' . $result['key']}->getTotal($total_data, $total, $taxes);
		}
		
		$sort_order = array(); 
	  
		foreach ($total_data as $key => $value) {
      		$sort_order[$key] = $value['sort_order'];
    	}

    	array_multisort($sort_order, SORT_ASC, $total_data);