コード例 #1
0
ファイル: Fedexbase.php プロジェクト: audiblePi/devOdyssey
 /**
  * Makes remote request to the carrier and returns a response
  *
  * @param string $purpose
  * @return mixed
  */
 protected function _doRatesRequest($purpose)
 {
     if (!Mage::getStoreConfig('shipping/shipusa/active')) {
         return Mage_Usa_Model_Shipping_Carrier_Fedex::_doRatesRequest($purpose);
     }
     $this->_handlingProductFee = 0;
     $ratesRequest = $this->_formRateRequest($purpose);
     $requestString = serialize($ratesRequest);
     $response = $this->_getCachedQuotes($requestString);
     $debugData = array('request' => $ratesRequest);
     if ($response === null) {
         try {
             $client = $this->_createRateSoapClient();
             $response = $client->getRates($ratesRequest);
             $this->_setCachedQuotes($requestString, serialize($response));
             $debugData['result'] = $response;
         } catch (Exception $e) {
             $debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
             Mage::logException($e);
             if ($this->getDebugFlag()) {
                 Mage::helper('wsalogger/log')->postCritical('usashipping', 'Fedex Soap Exception', $e->getMessage());
             }
         }
     } else {
         $response = unserialize($response);
         $debugData['result'] = $response;
     }
     $this->_debug($debugData);
     if ($this->getDebugFlag()) {
         Mage::helper('wsalogger/log')->postInfo('usashipping', 'Fedex Soap Request/Response', $debugData);
         Mage::helper('wsalogger/log')->postInfo('usashipping', 'Handing Fee', $this->_handlingProductFee);
     }
     return $response;
 }
コード例 #2
0
ファイル: Fedex.php プロジェクト: audiblePi/devOdyssey
 /**
  * Processing additional validation to check is carrier applicable.
  *
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return Mage_Shipping_Model_Carrier_Abstract|Mage_Shipping_Model_Rate_Result_Error|boolean
  */
 public function proccessAdditionalValidation(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!Mage::getStoreConfig('shipping/shipusa/active')) {
         return Mage_Usa_Model_Shipping_Carrier_Fedex::proccessAdditionalValidation($request);
     }
     //Skip by item validation if there is no items in request
     if (!count($request->getAllItems())) {
         return $this;
     }
     //  $maxAllowedWeight = (float) $this->getConfigData('max_package_weight');
     $errorMsg = '';
     $configErrorMsg = $this->getConfigData('specificerrmsg');
     $defaultErrorMsg = Mage::helper('shipping')->__('The shipping module is not available.');
     $showMethod = $this->getConfigData('showmethod');
     /*  foreach ($request->getAllItems() as $item) {
             if ($item->getProduct() && $item->getProduct()->getId()) {
                 if ($item->getProduct()->getWeight() > $maxAllowedWeight) {
                     $errorMsg = ($configErrorMsg) ? $configErrorMsg : $defaultErrorMsg;
                     break;
                 }
             }
         } */
     if (!$errorMsg && !$request->getDestPostcode() && $this->isZipCodeRequired($request->getDestCountryId())) {
         $errorMsg = Mage::helper('shipping')->__('This shipping method is not available, please specify ZIP-code');
     }
     if ($errorMsg && $showMethod) {
         $error = Mage::getModel('shipping/rate_result_error');
         $error->setCarrier($this->_code);
         $error->setCarrierTitle($this->getConfigData('title'));
         $error->setErrorMessage($errorMsg);
         return $error;
     } elseif ($errorMsg) {
         return false;
     }
     return $this;
 }