/**
  * Get allowed containers of carrier
  *
  * @param \Magento\Framework\DataObject|null $params
  * @return array|bool
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _getAllowedContainers(\Magento\Framework\DataObject $params = null)
 {
     $containersAll = $this->getContainerTypesAll();
     if (empty($containersAll)) {
         return [];
     }
     if (empty($params)) {
         return $containersAll;
     }
     $containersFilter = $this->getContainerTypesFilter();
     $containersFiltered = [];
     $method = $params->getMethod();
     $countryShipper = $params->getCountryShipper();
     $countryRecipient = $params->getCountryRecipient();
     if (empty($containersFilter)) {
         return $containersAll;
     }
     if (!$params || !$method || !$countryShipper || !$countryRecipient) {
         return $containersAll;
     }
     if ($countryShipper == self::USA_COUNTRY_ID && $countryRecipient == self::USA_COUNTRY_ID) {
         $direction = 'within_us';
     } else {
         if ($countryShipper == self::USA_COUNTRY_ID && $countryRecipient != self::USA_COUNTRY_ID) {
             $direction = 'from_us';
         } else {
             return $containersAll;
         }
     }
     foreach ($containersFilter as $dataItem) {
         $containers = $dataItem['containers'];
         $filters = $dataItem['filters'];
         if (!empty($filters[$direction]['method']) && in_array($method, $filters[$direction]['method'])) {
             foreach ($containers as $container) {
                 if (!empty($containersAll[$container])) {
                     $containersFiltered[$container] = $containersAll[$container];
                 }
             }
         }
     }
     return !empty($containersFiltered) ? $containersFiltered : $containersAll;
 }
 /**
  * Return content types of package
  *
  * @param \Magento\Framework\DataObject $params
  * @return array
  */
 public function getContentTypes(\Magento\Framework\DataObject $params)
 {
     $countryShipper = $params->getCountryShipper();
     $countryRecipient = $params->getCountryRecipient();
     if ($countryShipper == self::USA_COUNTRY_ID && $countryRecipient != self::USA_COUNTRY_ID) {
         return ['MERCHANDISE' => __('Merchandise'), 'SAMPLE' => __('Sample'), 'GIFT' => __('Gift'), 'DOCUMENTS' => __('Documents'), 'RETURN' => __('Return'), 'OTHER' => __('Other')];
     }
     return [];
 }
Example #3
0
 /**
  * Return delivery confirmation types of carrier
  *
  * @param \Magento\Framework\DataObject|null $params
  * @return array|bool
  */
 public function getDeliveryConfirmationTypes(\Magento\Framework\DataObject $params = null)
 {
     $countryRecipient = $params != null ? $params->getCountryRecipient() : null;
     $deliveryConfirmationTypes = [];
     switch ($this->_getDeliveryConfirmationLevel($countryRecipient)) {
         case self::DELIVERY_CONFIRMATION_PACKAGE:
             $deliveryConfirmationTypes = [1 => __('Delivery Confirmation'), 2 => __('Signature Required'), 3 => __('Adult Signature Required')];
             break;
         case self::DELIVERY_CONFIRMATION_SHIPMENT:
             $deliveryConfirmationTypes = [1 => __('Signature Required'), 2 => __('Adult Signature Required')];
             break;
         default:
             break;
     }
     array_unshift($deliveryConfirmationTypes, __('Not Required'));
     return $deliveryConfirmationTypes;
 }