Forums / Managing Customers and Orders / total sales on customer profile

total sales on customer profile

Started by purple_heart on 20 Mar 2012, 10:26 AM · Views: 1,289

Results 1 to 5 of 5
20 Mar 2012, 10:26 AM
#1
purple_heart avatar

purple_heart

New Zenner

Join Date:
Mar 2012
Location:
Melbourne, Australia
Posts:
10
Plugin Contributions:
0

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.

20 Mar 2012, 2:45 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

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:

<?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>

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

20 Mar 2012, 10:39 PM
#3
purple_heart avatar

purple_heart

New Zenner

Join Date:
Mar 2012
Location:
Melbourne, Australia
Posts:
10
Plugin Contributions:
0

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!

20 Mar 2012, 10:40 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

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:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

21 Mar 2012, 5:12 AM
#5
purple_heart avatar

purple_heart

New Zenner

Join Date:
Mar 2012
Location:
Melbourne, Australia
Posts:
10
Plugin Contributions:
0

Re: total sales on customer profile

thanks so much that is exactly what I was after thank-you!