12 thoughts on “Get customer order count in Magento

  1. hi
    how do I use this piece of code to retrieve the order count and put it on the order email sent out. The order email has the Order ID and next to it I’d like to put the order count for that customer i.e.

    Customer Name: John Smith
    Order ID: 0000000000012340
    Order Count: 8 ( this would include this particular order and the 7 before this)

    Thanks guys.

    1. You need to customize the email functionality for the same, the point where the email template HTML is generated dynamically.

      I am curious about guest customer, though.

      1. Will have to modify the code snippet to either show this only for registered user or will need to look for all orders by that particular email address

        its trick to say the least… currently we do not allow guest checkout… but we’re working towards that

        thanks for help

        1. $customer_email = 'abc@abc.com';
          $_orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_email',$customer_email);                
          

          Use the above code, it will work for registered as well as guest.

  2. Hi,

    We have started our new magento webstore recently. On the sales reports if along with the order id, customer name, customer email, order value & other attributes, we want to get the count of orders placed by that particular customer.

    Is there anything that you can help us in achieving this?

    Please advice

    Thanks,
    Ravi

Leave a Reply to Operations Cancel reply

Your email address will not be published. Required fields are marked *

Scroll to top