/** * get Total Point that customer can earn by purchase current order/ quote * * @param null|Mage_Sales_Model_Quote $quote * @return int */ public function getTotalPointsEarning($quote = null) { if (is_null($quote)) { $quote = $this->getQuote(); } if ($quote->isVirtual()) { $address = $quote->getBillingAddress(); } else { $address = $quote->getShippingAddress(); } //Hai.Tran 21/11 $grandTotal = $quote->getBaseGrandTotal(); if (!Mage::getStoreConfigFlag(self::XML_PATH_EARNING_BY_SHIPPING, $quote->getStoreId())) { $grandTotal -= $address->getBaseShippingAmount(); } if (!Mage::getStoreConfigFlag(self::XML_PATH_EARNING_BY_TAX, $quote->getStoreId())) { $grandTotal -= $address->getBaseTaxAmount(); } $grandTotal = max(0, $grandTotal); //end Hai.Tran 21/11 $container = new Varien_Object(array('total_points' => $this->getRateEarningPoints($grandTotal, $quote->getStoreId()))); Mage::dispatchEvent('rewardpoints_calculation_earning_total_points', array('quote' => $quote, 'container' => $container)); return $container->getTotalPoints(); }