示例#1
0
文件: UPS.php 项目: kewaunited/xcart
 /**
  * Returns shipping rates
  *
  * @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->prepareInputData($inputData);
         if (!empty($data)) {
             $rates = $this->doQuery($data, $ignoreCache);
             if (!$ignoreCache && !$data['cod_enabled'] && $rates && self::isCODPaymentEnabled() && $this->isCODAllowed('all', $data['srcAddress']['country'], $data['dstAddress']['country'])) {
                 // Calculate rates with COD enabled
                 $data['cod_enabled'] = true;
                 $ratesWithCOD = $this->doQuery($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\XC\UPS\Main::isStrictMode()) {
         $this->errorMsg = 'UPS module is not configured';
     }
     // Return shipping rates list
     return $rates;
 }
示例#2
0
文件: UPS.php 项目: kirkbauer2/kirkxc
 /**
  * Returns url for sign up
  *
  * @return string
  */
 public function getSettingsURL()
 {
     return \XLite\Module\XC\UPS\Main::getSettingsForm();
 }