cancel
Showing results for 
Search instead for 
Did you mean: 

How to echo customer Lifetime Sales on admin Order View page

SOLVED

How to echo customer Lifetime Sales on admin Order View page

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>

 

Screenshot

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to echo customer Lifetime Sales on admin Order View page

$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;

View solution in original post

1 REPLY 1

Re: How to echo customer Lifetime Sales on admin Order View page

$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;