In the Print Invoice template , how can we have the field displaying the total number of orders given by same client till date?
The same field is displayed in the Customer Orders Report under reports > customers > order > No. Orders(column)
thanks.
Hi ssjal,
You need to create your own query to call that total.
Open and edit admin/model/sale/order.php and add a function to calculate total order by a customer:
Then call the function in your controller here in admin/controller/sale/order.php around line 2060:
So now you can use the 'order_total' variable in your invoice, for example, in admin/view/template/sale/order_invoice.tpl after line 37:
Hope this will get you started somehow.
You need to create your own query to call that total.
Open and edit admin/model/sale/order.php and add a function to calculate total order by a customer:
Code: Select all
public function getTotalOrdersByCustomerId($customer_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE customer_id = '" . (int)$customer_id. "' AND order_status_id != 0");
return $query->row['total'];
}
Code: Select all
'order_total' => $this->model_sale_order->getTotalOrdersByCustomerId($order_info['customer_id']),
Code: Select all
<tr>
<td><b>Number of orders from this customer so far:</b></td>
<td><?php echo $order['order_total']; ?></td>
</tr>
Developing Quality OpenCart Extensions since 2011.
View my extensions
Who is online
Users browsing this forum: No registered users and 21 guests