/**
  * Override this for Shipwire.  We only quote $0 shipping cost if all the items in the cart qualify for free shipping
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return null
  */
 protected function _updateFreeMethodQuote($request)
 {
     //      echo "getFreeMethodWeight: " . $request->getFreeMethodWeight();
     //      echo "hasFreeMethodWeight: " . $request->hasFreeMethodWeight();
     //      echo "getPackageWeight: " . $request->getPackageWeight();
     if ($request->getFreeMethodWeight() == $request->getPackageWeight() || !$request->hasFreeMethodWeight()) {
         return;
     }
     $freeMethod = $this->getConfigData($this->_freeMethod);
     if (!$freeMethod) {
         return;
     }
     $freeRateId = false;
     if (is_object($this->_result)) {
         foreach ($this->_result->getAllRates() as $i => $item) {
             if ($item->getMethod() == $freeMethod) {
                 $freeRateId = $i;
                 break;
             }
         }
     }
     if ($freeRateId === false) {
         return;
     }
     if ($request->getFreeMethodWeight() == 0) {
         // If the entire order has no weight because it is free then set the price to 0
         $this->_result->getRateById($freeRateId)->setPrice(0);
     }
 }
Exemple #2
0
 /**
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return null
  */
 protected function _updateFreeMethodQuote($request)
 {
     if ($request->getFreeMethodWeight() == $request->getPackageWeight() || !$request->hasFreeMethodWeight()) {
         return;
     }
     $freeMethod = $this->getConfigData('free_method');
     if (!$freeMethod) {
         return;
     }
     $freeRateId = false;
     if (is_object($this->_result)) {
         foreach ($this->_result->getAllRates() as $i => $item) {
             if ($item->getMethod() == $freeMethod) {
                 $freeRateId = $i;
                 break;
             }
         }
     }
     if ($freeRateId === false) {
         return;
     }
     $price = null;
     if ($request->getFreeMethodWeight() > 0) {
         $this->_setFreeMethodRequest($freeMethod);
         $result = $this->_getQuotes();
         if ($result && ($rates = $result->getAllRates()) && count($rates) > 0) {
             if (count($rates) == 1 && $rates[0] instanceof Mage_Shipping_Model_Rate_Result_Method) {
                 $price = $rates[0]->getPrice();
             }
             if (count($rates) > 1) {
                 foreach ($rates as $rate) {
                     if ($rate instanceof Mage_Shipping_Model_Rate_Result_Method && $rate->getMethod() == $freeMethod) {
                         $price = $rate->getPrice();
                     }
                 }
             }
         }
     } else {
         /**
          * if we can apply free shipping for all order we should force price
          * to $0.00 for shipping with out sending second request to carrier
          */
         $price = 0;
     }
     /**
      * if we did not get our free shipping method in response we must use its old price
      */
     if (!is_null($price)) {
         $this->_result->getRateById($freeRateId)->setPrice($price);
     }
 }
Exemple #3
0
 /**
  * WebShopApps - Changed to support Free Shipping using either Ground or Home Delivery
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return null
  */
 protected function _updateFreeMethodQuote($request)
 {
     if ($request->getFreeMethodWeight() == $request->getPackageWeight() || !$request->hasFreeMethodWeight()) {
         return;
     }
     $freeCode = Mage::helper('wsacommon')->getNewVersion() < 12 ? 'free_method' : $this->_freeMethod;
     $freeMethod = $this->getConfigData($freeCode);
     if (!$freeMethod) {
         return;
     }
     $freeRateId = false;
     $matchFedexGround = false;
     if ($this->getConfigData('free_both_ground')) {
         if ($freeMethod == 'GROUND_HOME_DELIVERY') {
             $altMethod = 'FEDEX_GROUND';
             $matchFedexGround = true;
         } else {
             if ($freeMethod == 'FEDEX_GROUND') {
                 // could match on either, need to check
                 $altMethod = 'GROUND_HOME_DELIVERY';
                 $matchFedexGround = true;
             }
         }
     }
     if (is_object($this->_result)) {
         foreach ($this->_result->getAllRates() as $i => $item) {
             if ($item->getMethod() == $freeMethod || $matchFedexGround && $item->getMethod() == $altMethod) {
                 $freeRateId = $i;
                 break;
             }
         }
     }
     if ($freeRateId === false) {
         return;
     }
     $price = null;
     if ($request->getFreeMethodWeight() > 0) {
         $this->_setFreeMethodRequest($freeMethod);
         $result = $this->_getQuotes();
         if ($result && ($rates = $result->getAllRates()) && count($rates) > 0) {
             if (count($rates) == 1 && $rates[0] instanceof Mage_Shipping_Model_Rate_Result_Method) {
                 $price = $rates[0]->getPrice();
             }
             if (count($rates) > 1) {
                 foreach ($rates as $rate) {
                     if ($rate instanceof Mage_Shipping_Model_Rate_Result_Method && ($rate->getMethod() == $freeMethod || $matchFedexGround && $item->getMethod() == $altMethod)) {
                         $price = $rate->getPrice();
                     }
                 }
             }
         }
     } else {
         /**
          * if we can apply free shipping for all order we should force price
          * to $0.00 for shipping with out sending second request to carrier
          */
         $price = 0;
     }
     /**
      * if we did not get our free shipping method in response we must use its old price
      */
     if (!is_null($price)) {
         $this->_result->getRateById($freeRateId)->setPrice($price);
     }
 }