- My function returns 0 on total sum of orders from a client when status is set to complete. When status is set to processing, everything goes O.K. Is it the right way to obtain a complete status?
- Also, I want to get all the SKUs from the customer of all orders. I tried to change getGrandTotal to getSku() but it returns nothing.
The code:
$customer_email = Mage::getSingleton('customer/session')->getCustomer()->getEmail();
$collection = Mage::getModel('sales/order')->getCollection()
->addFieldToFilter('status', 'complete')
->addAttributeToFilter('customer_email', array('like' => $customer_email));
foreach ($collection as $order) {
//do something
//echo round($order->getGrandTotal(), 2) . " ";
$sum += $order->getGrandTotal();
}
echo round($sum,2); ?>
var_dump()
?