phpopencart2.x

Adding price and total column in shipping invoice in opencart


Opencart by default doesn't show price and total in the print shipping at the admin side. So I added two more columns to the table in shipping invoice in order_shipping.tpl in admin/view/template/sale/order_shipping.tpl but I got the error as

Notice: Undefined variable: column_price in /home/blossewp/public_html/admin/view/template/sale/order_shipping.tpl on line 69 Notice: Undefined index: price in /home/blossewp/public_html/admin/view/template/sale/order_shipping.tpl on line 81

enter image description here

To me it seems the value is coming from the same controller order.php, I can't guess why then these variables are not visible inside order_shipping.tpl if they are visible in /home/blossewp/public_html/admin/view/template/sale/order_invoice.tpl.

Please help. The shipping invoice must have the price and total column.


Solution

  • The error is very clear

    Notice: Undefined variable: column_price in /home/blossewp/public_html/admin/view/template/sale/order_shipping.tpl on line 69 Notice: Undefined index: price in /home/blossewp/public_html/admin/view/template/sale/order_shipping.tpl on line 81

    It means that these variables are not defined, hence they are not passed from the controller to the view, the appropriate controller is located in <OC_ROOT>/admin/controller/sale/order.php , class ControllerSaleOrder @ function shipping() and I don't see your entries defined there

    To solve the problem, just define them:
    (1) Find $data['column_... = $this->language->get(... and add after $data['column_price'] = $this->language->get('column_price');
    (2) Find $product_data[] = array( and add an entry 'price' => $product_info['price'], or $this->currency->format($product_info['price']) if you want to format it!