Is it possible to get the basket table with Product name, quantity and price to show on the Order success page?

Also to show the shipping and billing address underneath this.

Please Advise.


Yes, you can get the order by using the order increment id (which is already on success page) on the success page. And after that you can get the order items from order. After that get the product from order item.

Use following code

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$incrId = 100005363;
$collection = $objectManager->create('Magento\Sales\Model\Order'); 
$order = $collection->loadByIncrementId($incrId);

        $orderItems = $order->getAllItems();

        foreach($orderItems as $item)
            $product = $item->getProduct();

Get shiiping and billing address

$billingAddress = $order->getBillingAddress();
$shippingAddress = $order->getShippingAddress();
  • Let me know if you have any question for above code. – DJ Dev Nov 20 '19 at 12:59
  • Thank you for the response. Would this code go on the success.phtml page? If not which template would this need to be added to? – Developer Nov 20 '19 at 14:44
  • Direct use of ObjectManager is not good practice for magento development. – Ronak Chauhan Nov 20 '19 at 15:27
  • Yes you can use this code into directly in success.phtml. And if you don't want to use objectMnager then first you'll need to override success block. – DJ Dev Nov 21 '19 at 7:18

Yes, It is possible to show recent order data on order success page. As you already have recent order increment Id.

protected $orderFactory;

public function __construct(
    \Magento\Sales\Api\Data\OrderInterfaceFactory $orderFactory,
) {
    $this->orderFactory = $orderFactory;


Load order object by increment id:

/** @var \Magento\Sales\Api\Data\OrderInterface $order **/
$order = $this->orderFactory->create()->loadByIncrementId('00001952-42');
$orderItems = $order->getAllItems();
foreach($orderItems as $item) {
      $product = $item->getProduct()

Template to ovveride in your theme vendor/magento/module-checkout/view/frontend/templates/success.phtml

  • Thank you for your reply. Where would this code go? I am new to Magento. – Developer Nov 20 '19 at 14:02
  • you can place this code into helper class or override block of order success page and place custom function in it. – Ronak Chauhan Nov 20 '19 at 15:27
  • Which template does this need to be added to? – Developer Nov 20 '19 at 15:40
  • answer updated! – Ronak Chauhan Nov 21 '19 at 8:58
  • I added this to the success.phtml template and still not showing the product table. Please can you further advise on this? – Developer Nov 21 '19 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.