/** * Overwrite parent method to check codes based on easyshippingmethod * and retrieving properly carrier * * @return Mage_Shipping_Model_Carrier_Abstract */ public function getCarrierInstance() { $code = $this->getCarrier(); // checking if code starts with easyshippingrules code if (!isset(self::$_instances[$code]) && strpos($code, MatheusGontijo_EasyShippingRules_Model_Shipping_Carrier::EASY_SHIPPING_RULES_CODE) === 0) { self::$_instances[$code] = Mage::getModel('easyshippingrules/shipping_carrier'); } return parent::getCarrierInstance(); }
protected function sortRates(Mage_Sales_Model_Quote_Address_Rate $a, Mage_Sales_Model_Quote_Address_Rate $b) { // Sort by price (lowest first) // This is a crappy solution and should be rewritten $aSort = intval(round(floatval($a->getPrice()) * 10000)); $bSort = intval(round(floatval($b->getPrice()) * 10000)); if ($aSort < $bSort) { return -1; } elseif ($aSort > $bSort) { return 1; } // Sory by carrier order (lowest first) $aSort = $a->getCarrierInstance()->getSortOrder(); $bSort = $b->getCarrierInstance()->getSortOrder(); if ($aSort < $bSort) { return -1; } elseif ($aSort > $bSort) { return 1; } // Sort my method order (lowest first) $aSort = intval($a->getSortOrder()); $bSort = intval($b->getSortOrder()); if ($aSort < $bSort) { return -1; } elseif ($aSort > $bSort) { return 1; } return 0; }