Post by jlg89 » Wed Mar 03, 2010 2:50 am

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?

New member

Posts

Joined
Tue Aug 04, 2009 11:32 am

Post by Qphoria » Wed Mar 03, 2010 3:00 am

$this->cart->getSubTotal()

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by jlg89 » Wed Mar 03, 2010 5:45 am

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?

New member

Posts

Joined
Tue Aug 04, 2009 11:32 am

Post by jlg89 » Wed Mar 03, 2010 5:54 am

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. ?

New member

Posts

Joined
Tue Aug 04, 2009 11:32 am

Post by jlg89 » Thu May 27, 2010 11:06 pm

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?

New member

Posts

Joined
Tue Aug 04, 2009 11:32 am

Post by Qphoria » Thu May 27, 2010 11:53 pm

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:

Code: Select all

if ($total) {
    echo 'yes';
} 

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by jlg89 » Fri May 28, 2010 1:14 am

Glory! Works like a champ. Thanks for the help! Maybe now I can keep the rest of my hair...

New member

Posts

Joined
Tue Aug 04, 2009 11:32 am

Post by henkster » Fri Jan 20, 2012 9:42 pm

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?

Newbie

Posts

Joined
Wed Jul 13, 2011 5:34 am

Post by uefa_celt » Fri Feb 17, 2012 1:36 am

I would like this too. Has this changed in 1.5.1.3?

Newbie

Posts

Joined
Thu Feb 16, 2012 8:08 am

Post by uefa_celt » Fri Feb 17, 2012 5:50 am

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);
				}
			}

Newbie

Posts

Joined
Thu Feb 16, 2012 8:08 am

Post by henkster » Fri Feb 24, 2012 6:34 pm

Thanks! Works a treat.

Newbie

Posts

Joined
Wed Jul 13, 2011 5:34 am

Post by gastadas » Thu Jan 30, 2014 3:43 am

Where i can post this code in bank_transfer.php?

Sorry, i am new ;)

Newbie

Posts

Joined
Tue Jan 28, 2014 6:50 pm

Post by gastadas » Thu Jan 30, 2014 6:03 pm

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);
} 

Newbie

Posts

Joined
Tue Jan 28, 2014 6:50 pm
Who is online

Users browsing this forum: No registered users and 29 guests