从Magento中的签出会话获取最后一个订单详细信息
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从Magento中的签出会话获取最后一个订单详细信息相关的知识,希望对你有一定的参考价值。
The code snippet below can be placed in any template file or anywhere after the Mage is initialized, and there has to be an order placed before.
<?php // First we need to the last real order id from the checkout/session and then passing this order id as a parameter to retrieve the order object from sales/order model. $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getSingleton('sales/order')->loadByIncrementId($orderId); // To get some basic order details, subtotal, shipping cost, discount, tax and grand total. echo "order subtotal: ".$order->getSubtotal()."<br>"; echo "shipping: ".$order->getShippingAmount()."<br>"; echo "discount: ".$order->getDiscountAmount()."<br>"; echo "tax: ".$order->getTaxAmount()."<br>"; echo "grand total".$order->getGrandTotal()."<br><br><br>"; // To show all the order details, the code below will pull all the order details for this order id from the table sales_flat_order // To get the order details for each item in the order, the order item detail is stored in the table sales_flat_order_item foreach($order->getItemsCollection() as $item) { //$product = Mage::getModel('catalog/product')->load($item->getProductId()); $row['sku'] = $item->getSku(); $row['original_price'] = $item->getOriginalPrice(); $row['price'] = $item->getPrice(); $row['qty_ordered']= (int)$item->getQtyOrdered(); $row['subtotal']= $item->getSubtotal(); $row['tax_amount']= $item->getTaxAmount(); $row['tax_percent']= $item->getTaxPercent(); $row['discount_amount']= $item->getDiscountAmount(); $row['row_total']= $item->getRowTotal(); $orderItems[]=$row; }
以上是关于从Magento中的签出会话获取最后一个订单详细信息的主要内容,如果未能解决你的问题,请参考以下文章
如何将订单详细信息传递到 magento 中的 paypal-express-checkout?