How to Display Order ID on Your Checkout Success Page?

Author: Viha Digital Commerce

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.

You can easily obtain order ID with the help of existing code

Now load order with the help of this particular order ID and fetch the data required

You can also get other details along with order ID using the code mentioned below

How to fetch order details from your order ID

The code snippet mentioned below will help you obtain order details like order items, customer billing, payment and shipping details via order id.

Note: 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.

Fetch information for order items

Fetch order payment details

Fetch order customer details

Fetch order shipping & billing details

How to show order details on success page after the order is placed

Create 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:

Create the file app/code/Vendor/Module/view/frontend/templates/checkout/success.phtml and add the following: