Example #1
0
 /**
  * Gets the final price of the freight
  * Follows the rules of free shipping
  *
  * @param Varien_Object $method
  * @return boolean|int|float
  */
 protected function _getFinalPrice(Varien_Object $method, Mage_Shipping_Model_Rate_Request $request)
 {
     $freeMethod = $this->getConfigData('free_shipping_method');
     if ($method->hasError() && !$method->getShowMessage() || $method->getPrice() <= 0) {
         return false;
     }
     if ($request->getFreeShipping() === true) {
         if ($freeMethod == 'lower-price') {
             if ($bestMethod = $this->getLowerPriceMethod($this->_getClientRequest())) {
                 if ($bestMethod->getCode() == $method->getCode()) {
                     return 0;
                 }
             }
         }
         if ($freeMethod == $method->getCode()) {
             return 0;
         }
     }
     $finalPrice = $method->getPrice();
     if ($handlingFee = $this->getConfigData('handling_fee')) {
         switch ($this->getConfigData('handling_type')) {
             case 'F':
                 $finalPrice += $handlingFee;
                 break;
             case 'P':
                 $finalPrice = $handlingFee * $finalPrice / 100 + $finalPrice;
                 break;
         }
     }
     return $finalPrice;
 }