PHP Magento get customers last order total
- by simian
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.