
To Get real order ID from order increment id in Magento: lets assume your order increment id is #10001222 and you need to get real order ID, you can use following code:
$orderIncrementId = 10001222; $orderId = Mage::getModel('sales/order') ->loadByIncrementId($orderIncrementId) ->getEntityId();
You can get order details by order increment ID as follow:
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
If you know the real order ID you can get order details by using following code:
$order = Mage::getModel("sales/order")->load($orderId); To get order total value: $orderTotalValue = number_format ($order->getGrandTotal(), 2, '.' , $thousands_sep = ''); To get order items collection: $orderItems = $order->getItemsCollection(); 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(); } To get shipping method from order: $shipping_method = $order->getShippingMethod(); To get payment method code from order you can use following code: $payment_method_code = $order->getPayment()->getMethodInstance()->getCode();
I hope this tutorial will help you to get order details from order ID in Magento.
About Author:
Kalpesh Chavada
Kalpesh Chavada is Our Founder & CEO of Akshar Group Technologies. He is serving with 11+ years of experience in different technologies like Magento, WordPress, Laravel, jQuery, Shopify, Branding, and Digital Marketing. He is very good with creative logic and always ready to take on challenges.
