/** * Return content types of package * * @param Varien_Object $params * @return array */ public function getContentTypes(Varien_Object $params) { $countryShipper = $params->getCountryShipper(); $countryRecipient = $params->getCountryRecipient(); if ($countryShipper == self::USA_COUNTRY_ID && $countryRecipient != self::USA_COUNTRY_ID) { return array('MERCHANDISE' => Mage::helper('usa')->__('Merchandise'), 'SAMPLE' => Mage::helper('usa')->__('Sample'), 'GIFT' => Mage::helper('usa')->__('Gift'), 'DOCUMENTS' => Mage::helper('usa')->__('Documents'), 'RETURN' => Mage::helper('usa')->__('Return'), 'OTHER' => Mage::helper('usa')->__('Other')); } return array(); }
/** * Get allowed containers of carrier * * @param Varien_Object|null $params * @return array|bool */ protected function _getAllowedContainers(Varien_Object $params = null) { $containersAll = $this->getContainerTypesAll(); if (empty($containersAll)) { return array(); } if (empty($params)) { return $containersAll; } $containersFilter = $this->getContainerTypesFilter(); $containersFiltered = array(); $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; }