total sales on customer profile
I have had a look at the customers.php page under admin and would like some advice as to how i should go about adding one field in on the customers page for total_sales (it could replace the GV balance as my store wont offer this service anyway and isnt really needed at this early stage.
Then on the edit customer page how I would best add the total_sales from phporders table on this page? (if the customer has more than one purchase it will need to add this up so it is a true total sales). It can be view only as it doesn't need to be edited.
Pretty much need to add the report customer orders total into the customers page so I can see totals to easily apply discounts based on the total sales.
I hope someone could help point me in the right direction.
Re: total sales on customer profile
You can get the data by using the same select from the stats_customers.php and adapt it for the info that you want, example:
Code:
<?php
$customers_total_query_raw = "select c.customers_id, c.customers_firstname, c.customers_lastname, sum(op.products_quantity * op.final_price)+sum(op.onetime_charges) as ordersum from " . TABLE_CUSTOMERS . " c, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS . " o where c.customers_id ='" . $customers->fields['customers_id'] . "' and c.customers_id = o.customers_id and o.orders_id = op.orders_id group by c.customers_id order by ordersum DESC";
$customers_total = $db->Execute($customers_total_query_raw);
?>
<td class="dataTableContent" align="right"><?php echo $currencies->format($customers_total->fields['ordersum']); ?></td>
Re: total sales on customer profile
Thanks Ajeh! I was going on that track myself but hadn't found what I was looking for in what query to use from that script yet but this helps thanks!
Re: total sales on customer profile
You are most welcome ... that should also give you additional info if you need it or a way to pull it up ... :smile:
Re: total sales on customer profile
thanks so much that is exactly what I was after thank-you!