PHP Magento get customers last order total

Posted by simian on Stack Overflow See other posts from Stack Overflow or by simian
Published on 2012-08-31T21:36:44Z Indexed on 2012/08/31 21:37 UTC
Read the original article Hit count: 114

Filed under:
|

I am working outside of magento store root folder (1.4) and I would like to get customers order totals, and date of last order. I have started with this:

$customer = Mage::getModel('customer/customer')->load($entity_id);
         $customerTotals =Mage::getResourceModel('sales/sale_collection')
              ->setCustomerFilter($customer)
              ->load()
              ->getTotals();

         echo $customerTotals->getNumOrders();
         echo money_format('$%i',$customerTotals->getLifetime());

This seems to be giving me totals from the wrong customer... Also, can't quite figure out how to get customers last order day.

any help would be appreciated.

© Stack Overflow or respective owner

Related posts about php

Related posts about magento-1.4