I needed to add the Order ID for guest checkout in the success page for my OpenCart installation v2.2.0.0
I did not find an extension to do this and the first set of instructions I found did not work. Eventually I got it working using a combination of solutions.
First, you need to edit the success.php file in catalog\controller\checkout\
Change this:
if (isset($this->session->data['order_id'])) { $this->cart->clear();
Into this:
if (isset($this->session->data['order_id'])) { $this->load->model('checkout/order'); $data['orderDetails'] = $this->model_checkout_order->getOrder($this->session->data['order_id']); $this->cart->clear();
Next, you need to edit success.tpl in catalog\view\theme\YOUR-THEME\template\common\
Under the line <h1><?php echo $heading_title; ?></h1> I added the following:
<?php if(!empty($orderDetails['order_id'])): ?> <h2>OrderID=<?php echo $orderDetails['order_id']; ?></h2> <?php endif; ?>
That’s it! When a new order is placed the success page will display the Order ID under Your order has been placed! If the page is refreshed the information goes away because the variable no longer has any value and would generate an error.
Hi Admin,
Thank you so much. I tried it’s working.
I need your help for showing Total Amount,
I want to show total amount on that page also. I tried following code but total amount not showing.
if (isset($this->session->data[‘order_id’])) {
$this->load->model(‘checkout/order’);
$data[‘orderDetails’] = $this->model_checkout_order->getOrder($this->session->data[‘order_id’]);
$data[‘orderAmount’] = $this->cart->getTotal($this->session->data[‘total’]);
Kinda just grasping at straws here but I think you would want to stick with orderDetails instead of changing it to orderAmount. Just change order_id to order_total
$data[‘orderDetails’] = $this->model_checkout_order->getOrder($this->session->data[‘order_total’]);
Then you would make is show up by adding
i want to add order status and order total..please help
I just approved and responded to an older comment. Check it out. It may help but I’m not really an expert on this and usually just keep trying things until one works.
The order status would always be the same wouldn’t it? That could just be static text.
Hi Ben,
Thank you for your solution to this problem, i spent more than 2 day searching for this problem
I am not a programer just few coding, i found this page by google
Now opencart 3 use twig instead of tpl
i made a change a simple change to your code
Change :
OrderID=
To:
{% if orderDetails[‘order_id’] is not empty %}
OrderID={{orderDetails[‘order_id’]}}
{% endif %}
My participation was to thank you and also to those who will come looking for this solution for those who do not have programming experience