Exemplo n.º 1
0
 /**
  * Prepare input data from order modifier
  *
  * @param \XLite\Logic\Order\Modifier\Shipping $inputData Shipping order modifier
  *
  * @return array
  */
 protected function prepareDataFromModifier(\XLite\Logic\Order\Modifier\Shipping $inputData)
 {
     $data = array();
     $sourceAddress = $inputData->getOrder()->getSourceAddress();
     if ('AU' === $sourceAddress->getCountryCode()) {
         $addrInfo = array();
         $addrInfo['from_postcode'] = $sourceAddress->getZipcode();
         $dstAddress = \XLite\Model\Shipping::getInstance()->getDestinationAddress($inputData);
         if (null !== $dstAddress) {
             $addrInfo['to_postcode'] = $dstAddress['zipcode'];
             $addrInfo['country_code'] = $dstAddress['country'];
             $data['packages'] = $this->getPackages($inputData);
             foreach ($data['packages'] as $key => $package) {
                 $data['packages'][$key] = array_merge($package, $addrInfo);
             }
         }
     }
     return $data;
 }
Exemplo n.º 2
0
 /**
  * Prepare input data from order modifier
  *
  * @param \XLite\Logic\Order\Modifier\Shipping $inputData Shipping order modifier
  *
  * @return array
  */
 protected function prepareDataFromModifier(\XLite\Logic\Order\Modifier\Shipping $inputData)
 {
     $result = array();
     $sourceAddress = $inputData->getOrder()->getSourceAddress();
     $result['srcAddress'] = array('zipcode' => $sourceAddress->getZipcode(), 'country' => $sourceAddress->getCountryCode());
     if ($sourceAddress->getStatе()) {
         $result['srcAddress']['state'] = $sourceAddress->getStatе()->getCode();
     }
     $result['dstAddress'] = \XLite\Model\Shipping::getInstance()->getDestinationAddress($inputData);
     if (empty($result['dstAddress']['country'])) {
         $result['dstAddress'] = null;
     } elseif (isset($result['dstAddress']['state'])) {
         /** @var \XLite\Model\Repo\State $repo */
         $repo = \XLite\Core\Database::getRepo('XLite\\Model\\State');
         $result['dstAddress']['state'] = $repo->getCodeById($result['dstAddress']['state']);
     }
     $result['packages'] = $this->getPackages($inputData);
     // Detect if COD payment method has been selected by customer on checkout
     if ($inputData->getOrder()->getFirstOpenPaymentTransaction()) {
         $paymentMethod = $inputData->getOrder()->getPaymentMethod();
         if ($paymentMethod && 'COD_FEDEX' === $paymentMethod->getServiceName()) {
             $result['cod_enabled'] = true;
         }
     }
     return $result;
 }
Exemplo n.º 3
0
 /**
  * Get destination address
  *
  * @param \XLite\Logic\Order\Modifier\Shipping $modifier Shipping order modifier
  *
  * @return array
  */
 public function getDestinationAddress(\XLite\Logic\Order\Modifier\Shipping $modifier)
 {
     $address = null;
     $profile = $modifier->getOrder()->getProfile();
     if ($profile && $profile->getShippingAddress()) {
         // Profile is exists
         $address = static::prepareAddressData($profile->getShippingAddress());
     }
     return null === $address ? static::getDefaultAddress() : $address;
 }
Exemplo n.º 4
0
 /**
  * Prepare input data from order modifier
  *
  * @param \XLite\Logic\Order\Modifier\Shipping $inputData Shipping order modifier
  *
  * @return array
  */
 protected function prepareDataFromModifier(\XLite\Logic\Order\Modifier\Shipping $inputData)
 {
     $result = array();
     $config = $this->getConfiguration();
     /** @var \XLite\Model\Repo\State $repo */
     $repo = \XLite\Core\Database::getRepo('XLite\\Model\\State');
     $sourceAddress = $inputData->getOrder()->getSourceAddress();
     $result['srcAddress'] = array('country' => $sourceAddress->getCountryCode(), 'zipcode' => $sourceAddress->getZipcode(), 'state' => $sourceAddress->getState()->getCode());
     $destinationAddress = \XLite\Model\Shipping::getInstance()->getDestinationAddress($inputData);
     if (null !== $destinationAddress) {
         $stateCode = $repo->getCodeById($destinationAddress['state']);
         $shippingAddress = $inputData->getOrder()->getProfile() ? $inputData->getOrder()->getProfile()->getShippingAddress() : null;
         $type = $shippingAddress && $shippingAddress->getType() ? $shippingAddress->getType() : $config->destinationType;
         $result['dstAddress'] = array('country' => $destinationAddress['country'], 'zipcode' => $destinationAddress['zipcode'], 'state' => $stateCode, 'type' => $type);
         $result['items'] = $this->getItems($inputData);
     }
     return array('package' => $result);
 }
Exemplo n.º 5
0
 /**
  * Get destination address
  *
  * @param \XLite\Logic\Order\Modifier\Shipping $modifier Shipping order modifier
  *
  * @return array
  */
 public function getDestinationAddress(\XLite\Logic\Order\Modifier\Shipping $modifier)
 {
     $address = null;
     if ($modifier->getOrder()->getProfile() && $modifier->getOrder()->getProfile()->getShippingAddress()) {
         // Profile is exists
         $address = static::prepareAddressData($modifier->getOrder()->getProfile()->getShippingAddress());
     }
     if (!isset($address)) {
         $address = static::getDefaultAddress();
     }
     return $address;
 }
Exemplo n.º 6
0
 /**
  * Prepare input data from order modifier
  *
  * @param \XLite\Logic\Order\Modifier\Shipping $inputData Shipping order modifier
  *
  * @return array
  */
 protected function prepareDataFromModifier(\XLite\Logic\Order\Modifier\Shipping $inputData)
 {
     $data = array();
     $sourceAddress = $inputData->getOrder()->getSourceAddress();
     $data['srcAddress'] = array('city' => $sourceAddress->getCity(), 'zipcode' => $sourceAddress->getZipcode(), 'country' => $sourceAddress->getCountryCode());
     if ($sourceAddress->getState()) {
         $data['srcAddress']['state'] = $sourceAddress->getStateCode();
     }
     $data['dstAddress'] = \XLite\Model\Shipping::getInstance()->getDestinationAddress($inputData);
     if (isset($data['dstAddress']['state'])) {
         $data['dstAddress']['state'] = \XLite\Core\Database::getRepo('XLite\\Model\\State')->getCodeById($data['dstAddress']['state']);
     }
     $data['packages'] = $this->getPackages($inputData);
     $data['cod_enabled'] = false;
     // Detect if COD payment method has been selected by customer on checkout
     if ($inputData->getOrder()->getFirstOpenPaymentTransaction()) {
         $paymentMethod = $inputData->getOrder()->getPaymentMethod();
         if ($paymentMethod && 'COD_UPS' === $paymentMethod->getServiceName()) {
             $data['cod_enabled'] = true;
         }
     }
     return $data;
 }
Exemplo n.º 7
0
 /**
  * Prepare input data from order modifier
  *
  * @param \XLite\Logic\Order\Modifier\Shipping $inputData Shipping order modifier
  *
  * @return array
  */
 protected function prepareDataFromModifier(\XLite\Logic\Order\Modifier\Shipping $inputData)
 {
     $data = array();
     $commonData = array();
     $sourceAddress = $inputData->getOrder()->getSourceAddress();
     if ('CA' === $sourceAddress->getCountryCode()) {
         $commonData['srcAddress'] = array('zipcode' => $sourceAddress->getZipcode());
     }
     $commonData['dstAddress'] = \XLite\Model\Shipping::getInstance()->getDestinationAddress($inputData);
     if (!empty($commonData['srcAddress']) && !empty($commonData['dstAddress'])) {
         $data['packages'] = $this->getPackages($inputData);
         $data['commonData'] = $commonData;
     }
     return $data;
 }
Exemplo n.º 8
0
 /**
  * Get destination address
  *
  * @param \XLite\Logic\Order\Modifier\Shipping $modifier Shipping order modifier
  *
  * @return array
  */
 public function getDestinationAddress(\XLite\Logic\Order\Modifier\Shipping $modifier)
 {
     $address = null;
     if ($modifier->getOrder()->getProfile() && $modifier->getOrder()->getProfile()->getShippingAddress()) {
         // Profile is exists
         $addressObj = $modifier->getOrder()->getProfile()->getShippingAddress();
         $address = array('address' => $addressObj->getStreet(), 'city' => $addressObj->getCity(), 'state' => $addressObj->getState()->getStateId(), 'zipcode' => $addressObj->getZipcode(), 'country' => $addressObj->getCountry() ? $addressObj->getCountry()->getCode() : '');
     }
     if (!isset($address)) {
         // Anonymous address
         $config = \XLite\Core\Config::getInstance()->Shipping;
         $address = array('address' => $config->anonymous_address, 'city' => $config->anonymous_city, 'state' => $config->anonymous_state, 'zipcode' => $config->anonymous_zipcode, 'country' => $config->anonymous_country);
     }
     return $address;
 }