Article

How to Display Order ID on Your Checkout Success Page?

Topic: Business DevelopmentPublished January 16, 2019
No ratings yet701 viewsSign in to rate
It is important to use the checkout success page effectively for the customers. You can use tricks that help your customers to remain on the page so that you get the opportunity to increase your sales. rnYou can easily obtain order ID with the help of existing code getOrderId(); ?> Now load order with the help of this particular order ID and fetch the data required load($orderId); ?> You can also get other details along with order ID using the code mentioned below getLastRealOrderId(); $order = Mage::getSingleton('sales/order')->loadByIncrementId($orderId); ?> How to fetch order details from your order IDrnThe code snippet mentioned below will help you obtain order details like order items, customer billing, payment and shipping details via order id.rnNote: For demonstration purpose Objectmanager.Codexblog is being used which is otherwise is not recommended for direct use. You should use a particular constructor method direct an object. create('Magento\Sales\Api\Data\OrderInterface')->load($orderid);   //fetch whole order informationrnprint_r($order->getData());   //Or fetch specific informationrnecho $order->getIncrementId();rnecho $order->getGrandTotal();rnecho $order->getSubtotal(); ?> Fetch information for order items create('Magento\Sales\Api\Data\OrderInterface')->load($orderid);   //Loop through each item and fetch datarnforeach ($order->getAllItems() as $item) {    //fetch whole item informationrn   print_r($item->getData());      //Or fetch specific item informationrn   echo $item->getId();    echo $item->getProductType();    echo $item->getQtyOrdered();    echo $item->getPrice();       } ?> Fetch order payment details create('Magento\Sales\Api\Data\OrderInterface')->load($orderid);   //fetch whole payment informationrnprint_r($order->getPayment()->getData());   //Or fetch specific payment informationrnecho $order->getPayment()->getAmountPaid();rnecho $order->getPayment()->getMethod();rnecho $order->getPayment()->getAdditionalInformation('method_title'); ?> Fetch order customer details create('Magento\Sales\Api\Data\OrderInterface')->load($orderid);   //fetch customer informationrnecho $order->getCustomerId();rnecho $order->getCustomerEmail();rnecho $order->getCustomerFirstname();rnecho $order->getCustomerLastname(); ?> Fetch order shipping & billing details create('Magento\Sales\Api\Data\OrderInterface')->load($orderid); //fetch whole billing informationrnprint_r($order->getBillingAddress()->getData()); //Or fetch specific billing informationrnecho $order->getBillingAddress()->getCity();rnecho $order->getBillingAddress()->getRegionId();rnecho $order->getBillingAddress()->getCountryId(); //fetch whole shipping informationrnprint_r($order->getShippingAddress()->getData()); //Or fetch specific shipping informationrnecho $order->getShippingAddress()->getCity();rnecho $order->getShippingAddress()->getRegionId();rnecho $order->getShippingAddress()->getCountryId(); ?> How to show order details on success page after the order is placed rnCreate the file app/code/Vendor/Module/etc/di.xml and add the following: Create the file app/code/Vendor/Module/Block/Success.php and add the following: _checkoutSession->getLastRealOrder(); } } Override templaternCreate the file app/code/Vendor/Module/view/frontend/layout/checkout_onepage_success.xml and add the following: Create the file app/code/Vendor/Module/view/frontend/templates/checkout/success.phtml and add the following:
getOrderId()):?> getCanViewOrder()) :?>

%s', $block->escapeHtml($block->getViewOrderUrl()), $block->escapeHtml($block->getOrderId()))) ?>

%1.', $block->escapeHtml($block->getOrderId())) ?>

getOrder()->getTotalQtyOrdered()) ?>

getAdditionalInfoHtml() ?>
To refresh the checkout success page multiple times – follow the code given below Head to file app/code/Magento/Checkout/Controller/Onepage/Success.phtml and changern$session->clearQuote();rntorn// $session->clearQuote();rnThis will not clear your quote upon opening the page. Modify your success pagern rnAdding details to the purchased items is quite complicated so use the following code to load your order objectrn$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); Now you can access the items purchased by following the codern$orderItems = $order->getAllItems(); $purchasedSkus = array();rnforeach($orderItems as $orderItem) {     $purchasedSkus[] = $orderItem->getSku(); } Preview success pagernThe problem exists when you try to modify any of the details on the page and you would certainly wish to preview what the end results would be like. Well, when an order is placed and you head to the success page, refreshing the page would end the session and divert you to shopping cart empty page. In short when you change the success template you just need to create new order altogether always to preview the end result. rnThe above codes and snippets will help you display order ID on checkout success page and also carry out many more tasks on checkout success page.rnYou need to have proper knowledge of php programming so that you can make necessary changes to the code to get the final result. You can try these codes and check the final result. The codes mentioned above can help you make the changes to your checkout success page and you can easily achieve your goal. Related Post :- How to get the items from the order into the Magento 2 success page?

Further reading

Further Reading

4 total

Article

Artificial intelligence continues to dominate business conversations, but enthusiasm alone does not guarantee results. While many companies rush to adopt AI in hopes of gaining a competitive edge, a large number of initiatives still fall short. The problem is rarely the technology itself. More often, failure happens because organizations approach AI without the structure, readiness, and discipline required for long-term success. AI projects do not fail because the technology

March 4, 2026

Article

AI Avatar Development: Real Innovation or Just Hype? In today’s hyperconnected world, attention is currency. To stand out, brands can no longer settle for flashy features or surface-level engagement. They need to build meaningful, scalable, and personalized experiences. Enter AI avatars: digital humans that are revolutionizing communication by bringing lifelike presence to virtual interactions. Imagine a team member who never takes a coffee break, speaks ten languages fluen

February 27, 2026

Article

The Quiet Engine Behind Every Connection Most people think of telecom services as towers, signals, and mobile data moving invisibly through the air. Yet behind every call that connects and every message that reaches its destination, there is another system quietly working in the background. That system is the call center. While customers often interact with telecom companies only when something goes wrong, these centers operate constantly, guiding problems toward solutions an

February 23, 2026

Article

Introduction The solar industry once believed that collecting as many leads as possible was the fastest path to growth. Marketing teams focused on filling databases with names, phone numbers, and email addresses. At first, the numbers looked promising. Dashboards showed rising interest and more inquiries than ever before. Yet behind the scenes, many companies began to notice a quiet problem. Revenue growth did not match the flood of leads. Sales teams felt overwhelmed, conver

February 6, 2026