I have custom PHP code shown below that exports orders in Magento. I need this code to be able to get the total discount of the order as well as the amount of items in the order. Can someone please help me with this?
// ! ----- GET NEW ORDERS -----
$myOrder=Mage::getModel('sales/order');
$orders=Mage::getModel('sales/mysql4_order_collection');
//Optional filters you might want to use - more available operations in method _getConditionSql in Varien_Data_Collection_Db.
$orders->addFieldToFilter('total_paid',Array('gt'=>0)); //Amount paid larger than 0
$orders->addFieldToFilter('status',Array('eq'=>"processing")); //Status is "processing"
$allIds=$orders->getAllIds();
foreach($allIds as $thisId) {
$myOrder->reset()->load($thisId);
//Getting Order Fields
echo "'" . $myOrder->getBillingAddress()->getLastname() . "',";
echo "'" . $myOrder->getTotal_paid() . "',";
echo "'" . $myOrder->getShippingAddress()->getTelephone() . "',";
echo "'" . $myOrder->getPayment()->getCc_type() . "',";
echo "'" . $myOrder->getStatus() . "',";
echo "\r\n";
}
As you are loading the order model you can use the getDiscountAmount method.
You can get the number of items from: