Page 1 of 1
Accessing order total from payment module?
Posted: Wed Mar 03, 2010 2:50 am
by jlg89
I'm trying to create a custom payment module, and I need to be able to pull the order_id and total from the current session. What's the correct syntax for this? I've been able to get order_id, but not total. I've been pulling out what little hair I have left. Can anyone give me some direction?
Re: Accessing order total from payment module?
Posted: Wed Mar 03, 2010 3:00 am
by Qphoria
$this->cart->getSubTotal()
Re: Accessing order total from payment module?
Posted: Wed Mar 03, 2010 5:45 am
by jlg89
Beautiful. OK, so I've generated a URL that shows up on the "order confirmation" page:
"
https://external.payment.com/etc.php?Reference=" . $this->session->data['order_id'] . "&Amount=" . $this->cart->getSubTotal()
Is there any trick to making this same URL appear on the "success" page?
Re: Accessing order total from payment module?
Posted: Wed Mar 03, 2010 5:54 am
by jlg89
Oh, hang on... $this->cart->getSubTotal() is giving me the sub-total, not the final total (so, in this case, it's leaving off the tax). I tried $this->cart->getTotal() but that gives me the same number. ?
Re: Accessing order total from payment module?
Posted: Thu May 27, 2010 11:06 pm
by jlg89
Still having trouble getting the complete, final, master, everything-included-here, TOTAL for the order. Currently, I'm using
round(($this->cart->getSubTotal() + array_sum($this->cart->getTaxes())),2)
But this leaves out shipping, handling fees and other stuff. What variable stores the grand total?
Re: Accessing order total from payment module?
Posted: Thu May 27, 2010 11:53 pm
by Qphoria
Grand total in 1.4.7 is calculated on the confirm page
The code you can reuse in your payment module is:
Code: Select all
$total = 0;
$taxes = $this->cart->getTaxes();
$this->load->model('checkout/extension');
$sort_order = array();
$results = $this->model_checkout_extension->getExtensions('total');
foreach ($results as $key => $value) {
$sort_order[$key] = $this->config->get($value['key'] . '_sort_order');
}
array_multisort($sort_order, SORT_ASC, $results);
foreach ($results as $result) {
$this->load->model('total/' . $result['key']);
$this->{'model_total_' . $result['key']}->getTotal($total_data, $total, $taxes);
}
The after that you can check it:
Re: Accessing order total from payment module?
Posted: Fri May 28, 2010 1:14 am
by jlg89
Glory! Works like a champ. Thanks for the help! Maybe now I can keep the rest of my hair...
Re: Accessing order total from payment module?
Posted: Fri Jan 20, 2012 9:42 pm
by henkster
I would like to do the exact same thing with v1.5.1.3 but the above code doesn't work. I can't for the life of me work out what changed to break the code...
Any chance of an update to pick up the total?
Re: Accessing order total from payment module?
Posted: Fri Feb 17, 2012 1:36 am
by uefa_celt
I would like this too. Has this changed in 1.5.1.3?
Re: Accessing order total from payment module?
Posted: Fri Feb 17, 2012 5:50 am
by uefa_celt
Ok, got this from confirm.php in 1.5.1.3. Slightly different :
Code: Select all
$total = 0;
$taxes = $this->cart->getTaxes();
$this->load->model('setting/extension');
$sort_order = array();
$results = $this->model_setting_extension->getExtensions('total');
foreach ($results as $key => $value) {
$sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
}
array_multisort($sort_order, SORT_ASC, $results);
foreach ($results as $result) {
if ($this->config->get($result['code'] . '_status')) {
$this->load->model('total/' . $result['code']);
$this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
}
}
Re: Accessing order total from payment module?
Posted: Fri Feb 24, 2012 6:34 pm
by henkster
Thanks! Works a treat.
Re: Accessing order total from payment module?
Posted: Thu Jan 30, 2014 3:43 am
by gastadas
Where i can post this code in bank_transfer.php?
Sorry, i am new

Re: Accessing order total from payment module?
Posted: Thu Jan 30, 2014 6:03 pm
by gastadas
something bad with this code? Where i should paste this code?
Code: Select all
$total = 0;
$taxes = $this->cart->getTaxes();
$this->load->model('checkout/extension');
$sort_order = array();
$results = $this->model_checkout_extension->getExtensions('total');
foreach ($results as $key => $value) {
$sort_order[$key] = $this->config->get($value['key'] . '_sort_order');
}
array_multisort($sort_order, SORT_ASC, $results);
foreach ($results as $result) {
$this->load->model('total/' . $result['key']);
$this->{'model_total_' . $result['key']}->getTotal($total_data, $total, $taxes);
}