Hi I would like to know how to track the total amount spent by 1 individual customer? As in a customer might have made many transactions and the total amount spend for that customer.

Main reason is I need to find out my top spending customer from 1st transactions till present.

2 Answers 2


Here is the query to get life time sales of particular customer,

SELECT DISTINCT customer_email, customer_firstname, customer_lastname, SUM( subtotal_invoiced ) AS Total
FROM `sales_flat_order` AS a
WHERE customer_email = 'customer_email'
GROUP BY customer_email
ORDER BY SUM( subtotal_invoiced ) DESC
LIMIT 0 , 30

Here replace customer_email with user's email.


I wrote a simple module for you, In your controller, add this method,

 public function IndexAction() {

     $orders = Mage::getModel('sales/order')->getCollection()
     ->addAttributeToFilter('customer_email', '[email protected]');

foreach ($orders as $order) {
    $total = $order->getGrandTotal();
     $sum+= $total;

   echo $sum ;


If you want filter order status,then

    ->addFieldToFilter('status', 'complete')

Add this filter option in your order collection like this,

$orders = Mage::getModel('sales/order')->getCollection()
     ->addAttributeToFilter('customer_email', '[email protected]')
     ->addFieldToFilter('status', 'complete'); 



Or you could go to Customers >Manage Customers > Select the customer you want .... Here you will see a lifetime sales figure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.