예제 #1
0
 /**
  * Set request data to API connector
  *
  * @param array $data Request data
  *
  * @return void
  */
 protected function setRequestData($data)
 {
     $APIConnector = $this->getAPIConnector();
     $package = $data['package'];
     // SSL currently not supported
     $APIConnector->setSecureComm(false);
     // curl option (use only if you have the libcurl package installed)
     $APIConnector->useCurl(false);
     //************************************************************
     // Set the Detail Level (1, 2 or 3) (Default = 1)
     // DL 1:  minimum required data returned
     // DL 2:  shipping rate components included
     // DL 3:  package-level detail included
     //************************************************************
     $detailLevel = 3;
     $APIConnector->setDetailLevel($detailLevel);
     //************************************************************
     // Set Currency
     // Determines the currency of the returned rates
     // and the expected currency of any monetary values set in your call
     // (declared value, item handling fee, fixed fees)
     //************************************************************
     $APIConnector->setCurrency(\XLite::getInstance()->getCurrency()->getCode());
     //************************************************************
     // Set Header Reference Code (optional)
     // can be used to identify and track a subset of calls,
     // such as a particular seller
     // (trackable in AuctionInc acct => API Statistics)
     //************************************************************
     if (\XLite\Module\XC\AuctionInc\Main::isXSAvailable()) {
         $APIConnector->setHeaderRefCode($this->getHeaderReferenceCode());
     }
     //**************************************************************
     // Set Origin Address/es for this Seller
     // (typically fed in from your seller account configuration)
     //**************************************************************
     if (\XLite\Module\XC\AuctionInc\Main::isXSAvailable() && $package['srcAddress']) {
         $APIConnector->addOriginAddress($package['srcAddress']['country'], $package['srcAddress']['zipcode'], $package['srcAddress']['state']);
     }
     //************************************************************
     // Set Destination Address for this API call
     // (These values would typically come from your cart)
     //************************************************************
     if ($package['dstAddress']) {
         $APIConnector->setDestinationAddress($package['dstAddress']['country'], $package['dstAddress']['zipcode'], $package['dstAddress']['state'], \XLite\View\FormField\Select\AddressType::TYPE_RESIDENTIAL === $package['dstAddress']['type']);
     }
     $this->setItemsData($package['items']);
     //*************************************************************
     // Set Carriers/Services to rate for this shipment
     // (on-demand flag is optional, see documentation)
     // (typically fed in from your seller account configuration)
     //*************************************************************
     $enabledCarriers = $this->getEnabledCarriers();
     foreach ($enabledCarriers as $carrier) {
         $entryPoint = \XLite\Core\Config::getInstance()->XC->AuctionInc->{'entryPoint' . $carrier};
         $APIConnector->addCarrier($carrier, $entryPoint);
     }
     $methods = $this->getEnabledMethods();
     /** @var \XLite\Model\Shipping\Method $method */
     foreach ($methods as $method) {
         list($carrierCode, $serviceCode) = explode('_', $method->getCode());
         $APIConnector->addService($carrierCode, $serviceCode, $method->getOnDemand());
     }
 }
예제 #2
0
 /**
  * Check if XS available
  *
  * @return boolean
  */
 public function isXSAvailable()
 {
     return \XLite\Module\XC\AuctionInc\Main::isXSAvailable();
 }