Example #1
0
 /**
  * Returns url for sign up
  *
  * @return string
  */
 public function getSettingsURL()
 {
     return \XLite\Module\CDev\FedEx\Main::getSettingsForm();
 }
Example #2
0
 /**
  * Returns shipping rates by shipping order modifier (used on checkout)
  *
  * @param array|\XLite\Logic\Order\Modifier\Shipping $inputData   Shipping order modifier or array of data for request
  * @param boolean                                    $ignoreCache Flag: if true then do not get rates from cache OPTIONAL
  *
  * @return array
  */
 public function getRates($inputData, $ignoreCache = false)
 {
     $this->errorMsg = null;
     $rates = array();
     if ($this->isConfigured()) {
         $data = $this->prepareRequestData($inputData);
         if (!empty($data)) {
             // Calculate rates
             $rates = $this->doRequest($data, $ignoreCache);
             if (!$ignoreCache && !empty($data['cod_enabled']) && $rates && self::isCODPaymentEnabled()) {
                 // Calculate rates with COD enabled
                 $data['cod_enabled'] = true;
                 $ratesWithCOD = $this->doRequest($data, $ignoreCache);
                 if ($ratesWithCOD) {
                     foreach ($rates as $k => $rate) {
                         $rateCode = $rate->getMethod()->getCode();
                         foreach ($ratesWithCOD as $rt) {
                             if ($rt->getMethod()->getCode() == $rateCode) {
                                 $extra = $rates[$k]->getExtraData() ?: new \XLite\Core\CommonCell();
                                 $extra->cod_supported = true;
                                 $extra->cod_rate = $rt->getBaseRate();
                                 $rates[$k]->setExtraData($extra);
                                 break;
                             }
                         }
                     }
                 }
             }
         } else {
             $this->errorMsg = 'Wrong input data';
         }
     } elseif (\XLite\Module\CDev\FedEx\Main::isStrictMode()) {
         $this->errorMsg = 'FedEx module is not configured';
     }
     return $rates;
 }