开发者

Magento failure.phtml, get the order total

开发者 https://www.devze.com 2023-02-01 07:10 出处:网络
One of the projects I work on has the failure page and success page in magento as exactly the same and requires some tracking code on both. The tracking code requires the order ID and the amount being

One of the projects I work on has the failure page and success page in magento as exactly the same and requires some tracking code on both. The tracking code requires the order ID and the amount being ordered. The issue I'm having is trying to get the order total on the failure开发者_如何学Python page.

The methods built into the block class Mage_Checkout_Block_Onepage_Failure are getRealOrderId(), getErrorMessage() and getContinueShoppingUrl(), so no help there.

I found some code to do what I want on the success page but it doesn't work for the failure page.

<?php
$orderId = $this->getRealOrderId();
$order = Mage::getSingleton('sales/order');
$order->load($orderId);
$_totalData = $order->getData();
$_grand = $_totalData['grand_total'];
?>

I dumped $order and $_totalData. $_totalData just an empty array and $order an empty Mage_Sales_Model_Order instance.

Does anyone have any suggestions for where to get the grand total of what is being purchased?

Regards, Kieran

(I'm also having issues testing the success page as I can't get to it, even putting in the correct test card details on the dev server - but I'll find a way around this)


If the order failed then there is no order to use, that seems sensible.

Perhaps, also, the cart hasn't been emptied in which case you can get the active totals with

$totals = Mage::helper('checkout')->getQuote()->getTotals();
$grand = $totals['grand_total'];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号