Speaktech.in

Display order id and amount on order success page in Opencart 3

Display order id and amount on order success page in Opencart 3


Controller : checkout / succss

    if (isset($this->session->data['order_id'])) {
       
            /** add below two lines **/
               $data['orderID'] = = $this->session->data['order_id'];
               $data['orderTotal']= $this->cart->getTotal();
              
          
            $this->cart->clear();

            unset($this->session->data['shipping_method']);
            unset($this->session->data['shipping_methods']);
            unset($this->session->data['payment_method']);
            unset($this->session->data['payment_methods']);
            unset($this->session->data['guest']);
            unset($this->session->data['comment']);
            unset($this->session->data['order_id']);
            unset($this->session->data['coupon']);
            unset($this->session->data['reward']);
            unset($this->session->data['voucher']);
            unset($this->session->data['vouchers']);
            unset($this->session->data['totals']);
        }



Update success.twig file in common

      {{ text_message }}
      {% if (orderID is not empty) %}
      <h2>Order Summary</h2>
      <div class="col-md-6">
      <div class="table-responsive">
  <table class="table table-bordered table-hover">
   <!-- <thead>
      <tr>
        <td class="text-left">Order Summary</td>
        <td class="text-left"></td>
      </tr>
    </thead> -->
    <tbody>
   
        <tr>
      <td class="text-right">  Order ID / Reference    </td>
      <td class="text-right">{{ orderID }}</td>
    
    </tr>
              </tbody>
   
    <tfoot>
   
        <tr>
      <td  class="text-right"><strong>Total:</strong></td>
      <td class="text-right">₹ {{ orderTotal }}</td>
    </tr>
       </tfoot>
   
  </table>
</div></div>