7

I want to get order date, ship method & payment method name after place order in Success.phtml file.

Magento 2 Learner
  • 700
  • 1
  • 9
  • 25

1 Answers1

17

Try below code to get order data, ship method & payment method name

if ($this->getOrderId())
{
   $order = Mage::getModel("sales/order")->load($orderId);

   $orderTotalValue = number_format ($order->getGrandTotal(), 2, '.' , $thousands_sep = ''); //Fetch the order total value

   $orderItems = $order->getItemsCollection();
   //Fetch the order items detail
   foreach ($orderItems as $item){
      $product_id = $item->product_id;
      $product_sku = $item->sku;
      $product_price = $item->getPrice();
      $product_name = $item->getName();
      $_product = Mage::getModel('catalog/product')->load($product_id);
      $cats = $_product->getCategoryIds();
      $category_id = $cats[0]; // just get the first id
      $category = Mage::getModel('catalog/category')->load($category_id);
      $category_name = $category->getName();
   }

   $shipping_method = $order->getShippingMethod(); //Fetch the shipping method from order

   $payment_method_code = $order->getPayment()->getMethodInstance()->getCode(); //Fetch the payment method code from order
}
Gopal Patel
  • 3,139
  • 2
  • 15
  • 32