Hi there,
I'm looking to display the customer Lifetime Sales value (£) within the admin on admin Order View page. I've managed to pull in the customer total order count with the code below, and basically would like to do the same with the lifetime value, any ideas?
<div class="label"><label><?php $customer_id = $this->getOrder()->getCustomerId(); $_orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id',$customer_id); $_orderCnt = $_orders->count(); //orders count ?></label></div> <div class="value"><?php echo 'Total number of orders <i>(Including this order)</i>: <font color="#eb5e00"><strong>'.$_orderCnt.'</strong></font>'; ?></div> <div><br /></div>
Solved! Go to Solution.
$customerId = <CUSTOMER_ID>; $customer = Mage::getModel('customer/customer')->load($customerId);$customerTotals = Mage::getResourceModel('sales/sale_collection') ->setOrderStateFilter(Mage_Sales_Model_Order::STATE_CANCELED, true) ->setCustomerFilter($customer) ->load() ->getTotals();$customerLifetimeSales = $customerTotals->getLifetime(); echo "Life Time Sales: ".$customerLifetimeSales;
$customerId = <CUSTOMER_ID>; $customer = Mage::getModel('customer/customer')->load($customerId);$customerTotals = Mage::getResourceModel('sales/sale_collection') ->setOrderStateFilter(Mage_Sales_Model_Order::STATE_CANCELED, true) ->setCustomerFilter($customer) ->load() ->getTotals();$customerLifetimeSales = $customerTotals->getLifetime(); echo "Life Time Sales: ".$customerLifetimeSales;