Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How to obtain Checkout information
 
mencargo
Member
 
Total Posts:  45
Joined:  2008-09-03
 

Hi there, I’m developing a custom payment module.
I need to obtain the users Total amount (including shipping & taxes)
And the order ID or checkout ID or something like that.

I found this code for the amount:

$mageFilename 'app/Mage.php';
require_once 
$mageFilename;

umask(0);
Mage::app();

// Secret Sauce - Initializes the Session for the FRONTEND
// Magento uses different sessions for 'frontend' and 'adminhtml'
Mage::getSingleton('core/session', array('name'=>'frontend'));
$cart number_format(Mage::getSingleton('checkout/session')->getQuote()->getSubtotal(),2)
echo 
'Subtotal: ' $cart;

But I can’t get the total, and it’s not the obvious “getTotal()"…
Someone?

 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

its

getGrandTotal()

Cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
mencargo
Member
 
Total Posts:  45
Joined:  2008-09-03
 

Substituting getSubtotal with getGrandTotal, the result it’s always $1.
Am I missing something?

 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

$1 = shipping costs or other fees? Maybe a problem with rounding values?

Cheers

stefan

 
Magento Community Magento Community
Magento Community
Magento Community
 
mencargo
Member
 
Total Posts:  45
Joined:  2008-09-03
 

I think it’s a problem with the session because now “getSubtotal()” doesn’t work either.
This code is in a Custom Payment Module.

$mageFilename 'app/Mage.php';
require_once 
$mageFilename;
umask(0);
Mage::app();
Mage::getSingleton('core/session', array('name'=>'frontend'));
$total number_format(Mage::getSingleton('checkout/session')->getQuote()->getGrandTotal(),2);
echo 
'Total: $' $total;
 
Magento Community Magento Community
Magento Community
Magento Community
 
mencargo
Member
 
Total Posts:  45
Joined:  2008-09-03
 

I have been testing it, and it seems that if I’m a visitor, it get’s my session and the checkout data, but if I’m a registered user it doesn’t.
So there’s probably something more or something different at the session.

 
Magento Community Magento Community
Magento Community
Magento Community
 
mencargo
Member
 
Total Posts:  45
Joined:  2008-09-03
 

OMG!
That’s not it!
hahahaha
Works excellent, the problem is at my PHP number_format
When it’s more than 999.0000, it formats it like 1,000.00
And this somehow messes with my code, because I need the number without any punctuation.
Solved with:
$total = number_format(Mage::getSingleton(’checkout/session’)->getQuote()->getGrandTotal(),2,’’,’’);

Thanks!!!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top