6

I need to know, if any solution how to add in magento success.phtml order's total price? Because I want after placed order, customer get all info how to make payment including what price need to pay, because customer don't remember in last step what is total price.

Brek
  • 193
  • 2
  • 2
  • 12
  • please search this has been answered before here – Anton S Jan 30 '12 at 10:39
  • you talking about this one? http://stackoverflow.com/questions/3927685/magento-checkout-success-page-product-price-and-sku-retrival this one don't work – Brek Jan 30 '12 at 10:48

2 Answers2

12

You could use something like this in your success.phtml:

$sOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
$oOrder = Mage::getModel('sales/order')->load($sOrderId);
echo $oOrder->getGrandTotal();
Jürgen Thelen
  • 12,745
  • 7
  • 52
  • 71
  • 1
    This is a terrible answer. You could easily accidentally show someone elses order if 2 orders came through with miliseconds of each other. Use `$order = Mage::getModel('sales/order')->load($this->getOrderId());` instead. – dotty Sep 25 '17 at 10:36
  • 1
    @dotty: The `last_order_id` is saved in the PHP session when the user clicks 'Buy'. The PHP session id is bound to the browser of a specific user, usually by cookie. Mind to explain, how a value read from a user specific session should lead to show the order of a different user? – Jürgen Thelen Sep 26 '17 at 07:22
10

in success.phtml template you can use

$order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
$total = $order->getGrandTotal();

proper way is to extend the Mage_Checkout_Block_Onepage_Success and add your own method for loading the order again (As in this page quote is inactive already) as it is not nice to load such stuff in templates

Anton S
  • 12,750
  • 2
  • 35
  • 37