diff --git app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php index 2e33750..fde58be 100644 --- app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php +++ app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php @@ -736,6 +736,9 @@ class Mage_Adminhtml_Catalog_ProductController extends Mage_Adminhtml_Controller else { $this->_redirect('*/*/', array('store'=>$storeId)); } + if (!isset($stockData['is_decimal_divided']) || $stockData['is_qty_decimal'] == 0) { + $stockData['is_decimal_divided'] = 0; + } } /** diff --git app/code/core/Mage/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php app/code/core/Mage/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php new file mode 100644 index 0000000..73b1c8f --- /dev/null +++ app/code/core/Mage/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php @@ -0,0 +1,58 @@ + + */ +class Mage_Catalog_Model_Product_Attribute_Source_Countryofmanufacture + extends Mage_Eav_Model_Entity_Attribute_Source_Abstract +{ + /** + * Get list of all available countries + * + * @return mixed + */ + public function getAllOptions() + { + $cacheKey = 'DIRECTORY_COUNTRY_SELECT_STORE_'.Mage::app()->getStore()->getCode(); + if (Mage::app()->useCache('config') && $cache = Mage::app()->loadCache($cacheKey)) { + $options = unserialize($cache); + } + else { + $collection = Mage::getModel('directory/country')->getResourceCollection() + ->loadByStore(); + $options = $collection->toOptionArray(); + if (Mage::app()->useCache('config')) { + Mage::app()->saveCache(serialize($options), $cacheKey, array('config')); + } + } + return $options; + } +} diff --git app/code/core/Mage/Catalog/etc/config.xml app/code/core/Mage/Catalog/etc/config.xml index 0caa010..a5edcce 100644 --- app/code/core/Mage/Catalog/etc/config.xml +++ app/code/core/Mage/Catalog/etc/config.xml @@ -28,7 +28,7 @@ - 1.4.0.0.44 + 1.4.0.0.44.1.2 @@ -59,6 +59,13 @@ + + 1 + + + + + 1 1 diff --git app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-upgrade-1.4.0.0.44.1.1-1.4.0.0.44.1.2.php app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-upgrade-1.4.0.0.44.1.1-1.4.0.0.44.1.2.php new file mode 100644 index 0000000..0ceab30 --- /dev/null +++ app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-upgrade-1.4.0.0.44.1.1-1.4.0.0.44.1.2.php @@ -0,0 +1,48 @@ +addAttribute(Mage_Catalog_Model_Product::ENTITY, 'country_of_manufacture', array( + 'group' => 'General', + 'type' => 'varchar', + 'backend' => '', + 'frontend' => '', + 'label' => 'Country of Manufacture', + 'input' => 'select', + 'class' => '', + 'source' => 'catalog/product_attribute_source_countryofmanufacture', + 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, + 'visible' => true, + 'required' => false, + 'user_defined' => false, + 'searchable' => false, + 'filterable' => false, + 'comparable' => false, + 'visible_on_front' => false, + 'unique' => false, + 'apply_to' => 'simple,configurable,bundle,grouped', + 'is_configurable' => false, +)); diff --git app/code/core/Mage/CatalogInventory/Helper/Data.php app/code/core/Mage/CatalogInventory/Helper/Data.php index 5e14ab6..314f196 100644 --- app/code/core/Mage/CatalogInventory/Helper/Data.php +++ app/code/core/Mage/CatalogInventory/Helper/Data.php @@ -97,6 +97,7 @@ class Mage_CatalogInventory_Helper_Data extends Mage_Core_Helper_Abstract 'manage_stock', 'enable_qty_increments', 'qty_increments', + 'is_decimal_divided', ); } diff --git app/code/core/Mage/CatalogInventory/Model/Stock/Item.php app/code/core/Mage/CatalogInventory/Model/Stock/Item.php index 3c40c9e..b7aba7c 100644 --- app/code/core/Mage/CatalogInventory/Model/Stock/Item.php +++ app/code/core/Mage/CatalogInventory/Model/Stock/Item.php @@ -589,7 +589,7 @@ class Mage_CatalogInventory_Model_Stock_Item extends Mage_Core_Model_Abstract } $qtyIncrements = $this->getQtyIncrements(); - if ($qtyIncrements && ($qty % $qtyIncrements != 0)) { + if ($qtyIncrements && (Mage::helper('core')->getExactDivision($qty, $qtyIncrements) != 0)) { $result->setHasError(true) ->setQuoteMessage(Mage::helper('cataloginventory')->__('Some of the products cannot be ordered in the requested quantity.')) ->setQuoteMessageIndex('qty'); diff --git app/code/core/Mage/CatalogInventory/etc/config.xml app/code/core/Mage/CatalogInventory/etc/config.xml index 9ae7c81..bf0a1ea 100644 --- app/code/core/Mage/CatalogInventory/etc/config.xml +++ app/code/core/Mage/CatalogInventory/etc/config.xml @@ -28,7 +28,7 @@ - 0.7.8 + 0.7.8.1.2 diff --git app/code/core/Mage/CatalogInventory/sql/cataloginventory_setup/mysql4-upgrade-0.7.8.1.1-0.7.8.1.2.php app/code/core/Mage/CatalogInventory/sql/cataloginventory_setup/mysql4-upgrade-0.7.8.1.1-0.7.8.1.2.php new file mode 100644 index 0000000..78c80b5 --- /dev/null +++ app/code/core/Mage/CatalogInventory/sql/cataloginventory_setup/mysql4-upgrade-0.7.8.1.1-0.7.8.1.2.php @@ -0,0 +1,38 @@ +getConnection() + ->addColumn( + $installer->getTable('cataloginventory/stock_item'), + 'is_decimal_divided', + "smallint(5) unsigned NOT NULL default '0' COMMENT 'Is Divided into Multiple Boxes for Shipping'" + ); diff --git app/code/core/Mage/Checkout/Block/Cart/Shipping.php app/code/core/Mage/Checkout/Block/Cart/Shipping.php index 2424271..0093ad5 100644 --- app/code/core/Mage/Checkout/Block/Cart/Shipping.php +++ app/code/core/Mage/Checkout/Block/Cart/Shipping.php @@ -27,10 +27,30 @@ class Mage_Checkout_Block_Cart_Shipping extends Mage_Checkout_Block_Cart_Abstract { + /** + * Available Carriers Instances + * @var null|array + */ protected $_carriers = null; + + /** + * Estimate Rates + * @var array + */ protected $_rates = array(); + + /** + * Address Model + * + * @var array + */ protected $_address = array(); + /** + * Get Estimate Rates + * + * @return array + */ public function getEstimateRates() { if (empty($this->_rates)) { @@ -41,7 +61,7 @@ class Mage_Checkout_Block_Cart_Shipping extends Mage_Checkout_Block_Cart_Abstrac } /** - * Get address model + * Get Address Model * * @return Mage_Sales_Model_Quote_Address */ @@ -53,6 +73,12 @@ class Mage_Checkout_Block_Cart_Shipping extends Mage_Checkout_Block_Cart_Abstrac return $this->_address; } + /** + * Get Carrier Name + * + * @param string $carrierCode + * @return mixed + */ public function getCarrierName($carrierCode) { if ($name = Mage::getStoreConfig('carriers/'.$carrierCode.'/title')) { @@ -61,51 +87,107 @@ class Mage_Checkout_Block_Cart_Shipping extends Mage_Checkout_Block_Cart_Abstrac return $carrierCode; } + /** + * Get Shipping Method + * + * @return string + */ public function getAddressShippingMethod() { return $this->getAddress()->getShippingMethod(); } + /** + * Get Estimate Country Id + * + * @return string + */ public function getEstimateCountryId() { return $this->getAddress()->getCountryId(); } + /** + * Get Estimate Postcode + * + * @return string + */ public function getEstimatePostcode() { return $this->getAddress()->getPostcode(); } + /** + * Get Estimate City + * + * @return string + */ public function getEstimateCity() { return $this->getAddress()->getCity(); } + /** + * Get Estimate Region Id + * + * @return mixed + */ public function getEstimateRegionId() { return $this->getAddress()->getRegionId(); } + /** + * Get Estimate Region + * + * @return string + */ public function getEstimateRegion() { return $this->getAddress()->getRegion(); } + /** + * Show City in Shipping Estimation + * + * @return bool + */ public function getCityActive() { - return (bool)Mage::getStoreConfig('carriers/dhl/active'); + return (bool)Mage::getStoreConfig('carriers/dhl/active') + || (bool)Mage::getStoreConfig('carriers/dhlint/active'); } + /** + * Show State in Shipping Estimation + * + * @return bool + */ public function getStateActive() { - return (bool)Mage::getStoreConfig('carriers/dhl/active') || (bool)Mage::getStoreConfig('carriers/tablerate/active'); + return (bool)Mage::getStoreConfig('carriers/dhl/active') + || (bool)Mage::getStoreConfig('carriers/tablerate/active') + || (bool)Mage::getStoreConfig('carriers/dhlint/active'); } + /** + * Convert price from default currency to current currency + * + * @param float $price + * @return float + */ public function formatPrice($price) { return $this->getQuote()->getStore()->convertPrice($price, true); } + /** + * Get Shipping Price + * + * @param float $price + * @param bool $flag + * @return float + */ public function getShippingPrice($price, $flag) { return $this->formatPrice($this->helper('tax')->getShippingPrice( @@ -175,7 +257,7 @@ class Mage_Checkout_Block_Cart_Shipping extends Mage_Checkout_Block_Cart_Abstrac public function isZipCodeRequired() { foreach ($this->getCarriers() as $carrier) { - if ($carrier->isZipCodeRequired()) { + if ($carrier->isZipCodeRequired($this->getEstimateCountryId())) { return true; } } diff --git app/code/core/Mage/Core/Helper/Data.php app/code/core/Mage/Core/Helper/Data.php index 2d959e9..6ec2bb1 100644 --- app/code/core/Mage/Core/Helper/Data.php +++ app/code/core/Mage/Core/Helper/Data.php @@ -36,6 +36,11 @@ class Mage_Core_Helper_Data extends Mage_Core_Helper_Abstract const XML_PATH_PUBLIC_FILES_VALID_PATHS = 'general/file/public_files_valid_paths'; /** + * Const for correct dividing decimal values + */ + const DIVIDE_EPSILON = 10000; + + /** * @var Mage_Core_Model_Encryption */ protected $_encryptor = null; @@ -788,4 +793,23 @@ XML; } return true; } + + /** + * Returns the floating point remainder (modulo) of the division of the arguments + * + * @param float|int $dividend + * @param float|int $divisor + * @return float|int + */ + public function getExactDivision($dividend, $divisor) + { + $epsilon = $divisor / self::DIVIDE_EPSILON; + + $remainder = fmod($dividend, $divisor); + if (abs($remainder - $divisor) < $epsilon || abs($remainder) < $epsilon) { + $remainder = 0; + } + + return $remainder; + } } diff --git app/code/core/Mage/Core/Model/Store.php app/code/core/Mage/Core/Model/Store.php index d944b2c0..bf77639 100644 --- app/code/core/Mage/Core/Model/Store.php +++ app/code/core/Mage/Core/Model/Store.php @@ -36,6 +36,8 @@ class Mage_Core_Model_Store extends Mage_Core_Model_Abstract { const ENTITY = 'core_store'; + const XML_PATH_STORE_STORE_NAME = 'general/store_information/name'; + const XML_PATH_STORE_IN_URL = 'web/url/use_store'; const XML_PATH_USE_REWRITES = 'web/seo/use_rewrites'; const XML_PATH_UNSECURE_BASE_URL = 'web/unsecure/base_url'; diff --git app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php index 4202021..a12a559 100644 --- app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php +++ app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php @@ -1240,6 +1240,7 @@ class Mage_ImportExport_Model_Import_Entity_Product extends Mage_ImportExport_Mo 'is_in_stock' => 0, 'low_stock_date' => null, 'stock_status_changed_automatically' => 0 + 'is_decimal_divided' => 0 ); $entityTable = Mage::getResourceModel('cataloginventory/stock_item')->getMainTable(); diff --git app/code/core/Mage/Sales/Model/Order.php app/code/core/Mage/Sales/Model/Order.php index dd920bd..cc70ad2 100644 --- app/code/core/Mage/Sales/Model/Order.php +++ app/code/core/Mage/Sales/Model/Order.php @@ -864,6 +864,11 @@ class Mage_Sales_Model_Order extends Mage_Sales_Model_Abstract return array(); } + /** + * Return model of shipping carrier + * + * @return bool|float|Mage_Shipping_Model_Carrier_Abstract + */ public function getShippingCarrier() { $carrierModel = $this->getData('shipping_carrier'); @@ -872,10 +877,9 @@ class Mage_Sales_Model_Order extends Mage_Sales_Model_Abstract /** * $method - carrier_method */ - if ($method = $this->getShippingMethod()) { - $data = explode('_', $method); - $carrierCode = $data[0]; - $className = Mage::getStoreConfig('carriers/'.$carrierCode.'/model'); + $method = $this->getShippingMethod(true); + if ($method instanceof Varien_Object) { + $className = Mage::getStoreConfig('carriers/' . $method->getCarrierCode() . '/model'); if ($className) { $carrierModel = Mage::getModel($className); } @@ -886,6 +890,26 @@ class Mage_Sales_Model_Order extends Mage_Sales_Model_Abstract } /** + * Retrieve shipping method + * + * @param bool $asObject return carrier code and shipping method data as object + * @return string|Varien_Object + */ + public function getShippingMethod($asObject = false) + { + $shippingMethod = parent::getShippingMethod(); + if (!$asObject) { + return $shippingMethod; + } else { + list($carrierCode, $method) = explode('_', $shippingMethod, 2); + return new Varien_Object(array( + 'carrier_code' => $carrierCode, + 'method' => $method + )); + } + } + + /** * Send email with order data * * @return Mage_Sales_Model_Order diff --git app/code/core/Mage/Sales/Model/Quote/Address.php app/code/core/Mage/Sales/Model/Quote/Address.php index 3e482d0..a9a0aa7 100644 --- app/code/core/Mage/Sales/Model/Quote/Address.php +++ app/code/core/Mage/Sales/Model/Quote/Address.php @@ -758,6 +758,8 @@ class Mage_Sales_Model_Quote_Address extends Mage_Customer_Model_Address_Abstrac $request->setPackageCurrency($this->getQuote()->getStore()->getCurrentCurrency()); $request->setLimitCarrier($this->getLimitCarrier()); + $request->setBaseSubtotalInclTax($this->getBaseSubtotalInclTax()); + $result = Mage::getModel('shipping/shipping')->collectRates($request)->getResult(); $found = false; diff --git app/code/core/Mage/Shipping/Model/Carrier/Abstract.php app/code/core/Mage/Shipping/Model/Carrier/Abstract.php index e16530c..83772ba 100644 --- app/code/core/Mage/Shipping/Model/Carrier/Abstract.php +++ app/code/core/Mage/Shipping/Model/Carrier/Abstract.php @@ -27,17 +27,52 @@ abstract class Mage_Shipping_Model_Carrier_Abstract extends Varien_Object { + /** + * Carrier's code + * + * @var string + */ protected $_code; + + /** + * Rates result + * + * @var array + */ protected $_rates = null; + + /** + * Number of boxes in package + * + * @var int + */ protected $_numBoxes = 1; /** + * Free Method config path + * + * @var string + */ + protected $_freeMethod = 'free_method'; + + /** * Whether this carrier has fixed rates calculation * * @var bool */ protected $_isFixed = false; + /** + * Container types that could be customized + * + * @var array + */ + protected $_customizableContainerTypes = array(); + + const USA_COUNTRY_ID = 'US'; + const CANADA_COUNTRY_ID = 'CA'; + const MEXICO_COUNTRY_ID = 'MX'; + const HANDLING_TYPE_PERCENT = 'P'; const HANDLING_TYPE_FIXED = 'F'; @@ -51,11 +86,6 @@ abstract class Mage_Shipping_Model_Carrier_Abstract extends Varien_Object */ protected $_debugReplacePrivateDataKeys = array(); - public function __construct() - { - - } - /** * Retrieve information from carrier configuration * @@ -71,6 +101,12 @@ abstract class Mage_Shipping_Model_Carrier_Abstract extends Varien_Object return Mage::getStoreConfig($path, $this->getStore()); } + /** + * Retrieve config flag for store by field + * + * @param string $field + * @return bool + */ public function getConfigFlag($field) { if (empty($this->_code)) { @@ -80,28 +116,146 @@ abstract class Mage_Shipping_Model_Carrier_Abstract extends Varien_Object return Mage::getStoreConfigFlag($path, $this->getStore()); } + /** + * Collect and get rates + * + * @abstract + * @param Mage_Shipping_Model_Rate_Request $request + * @return Mage_Shipping_Model_Rate_Result|bool|null + */ abstract public function collectRates(Mage_Shipping_Model_Rate_Request $request); + /** + * Do request to shipment + * Implementation must be in overridden method + * + * @param Mage_Shipping_Model_Shipment_Request $request + * @return Varien_Object + */ + public function requestToShipment(Mage_Shipping_Model_Shipment_Request $request) + { + return new Varien_Object(); + } + + /** + * Do return of shipment + * Implementation must be in overridden method + * + * @param $request + * @return Varien_Object + */ + public function returnOfShipment($request) + { + return new Varien_Object(); + } + + /** + * Return container types of carrier + * + * @param Varien_Object|null $params + * @return array + */ + public function getContainerTypes(Varien_Object $params = null) + { + 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; + } + + /** + * Get Container Types, that could be customized + * + * @return array + */ + public function getCustomizableContainerTypes() + { + return $this->_customizableContainerTypes; + } + + /** + * Return delivery confirmation types of carrier + * + * @param Varien_Object|null $params + * @return array + */ + public function getDeliveryConfirmationTypes(Varien_Object $params = null) + { + return array(); + } + public function checkAvailableShipCountries(Mage_Shipping_Model_Rate_Request $request) { $speCountriesAllow = $this->getConfigData('sallowspecific'); /* * for specific countries, the flag will be 1 */ - if($speCountriesAllow && $speCountriesAllow==1){ + if ($speCountriesAllow && $speCountriesAllow == 1){ $showMethod = $this->getConfigData('showmethod'); $availableCountries = array(); - if( $this->getConfigData('specificcountry') ) { + if($this->getConfigData('specificcountry')) { $availableCountries = explode(',',$this->getConfigData('specificcountry')); } if ($availableCountries && in_array($request->getDestCountryId(), $availableCountries)) { return $this; - } elseif ($showMethod && (!$availableCountries || ($availableCountries && !in_array($request->getDestCountryId(), $availableCountries)))){ + } elseif ($showMethod && (!$availableCountries || ($availableCountries + && !in_array($request->getDestCountryId(), $availableCountries))) + ){ $error = Mage::getModel('shipping/rate_result_error'); $error->setCarrier($this->_code); $error->setCarrierTitle($this->getConfigData('title')); $errorMsg = $this->getConfigData('specificerrmsg'); - $error->setErrorMessage($errorMsg?$errorMsg:Mage::helper('shipping')->__('The shipping module is not available for selected delivery country.')); + $error->setErrorMessage($errorMsg ? $errorMsg : Mage::helper('shipping')->__('The shipping module is not available for selected delivery country.')); return $error; } else { /* @@ -125,6 +279,11 @@ abstract class Mage_Shipping_Model_Carrier_Abstract extends Varien_Object return $this; } + /** + * Determine whether current carrier enabled for activity + * + * @return bool + */ public function isActive() { $active = $this->getConfigData('active'); @@ -151,6 +310,21 @@ abstract class Mage_Shipping_Model_Carrier_Abstract extends Varien_Object return false; } + /** + * Check if carrier has shipping label option available + * + * @return boolean + */ + public function isShippingLabelsAvailable() + { + return false; + } + + /** + * Retrieve sort order of current carrier + * + * @return mixed + */ public function getSortOrder() { return $this->getConfigData('sort_order'); @@ -158,34 +332,34 @@ abstract class Mage_Shipping_Model_Carrier_Abstract extends Varien_Object /** * @param Mage_Shipping_Model_Rate_Request $request - * @return void + * @return null */ protected function _updateFreeMethodQuote($request) { - if ($request->getFreeMethodWeight()==$request->getPackageWeight() - || !$request->hasFreeMethodWeight()) { + if ($request->getFreeMethodWeight() == $request->getPackageWeight() || !$request->hasFreeMethodWeight()) { return; } - if (!$freeMethod = $this->getConfigData('free_method')) { + $freeMethod = $this->getConfigData($this->_freeMethod); + if (!$freeMethod) { return; } $freeRateId = false; if (is_object($this->_result)) { foreach ($this->_result->getAllRates() as $i=>$item) { - if ($item->getMethod()==$freeMethod) { + if ($item->getMethod() == $freeMethod) { $freeRateId = $i; break; } } } - if ($freeRateId===false) { + if ($freeRateId === false) { return; } $price = null; - if ($request->getFreeMethodWeight()>0) { + if ($request->getFreeMethodWeight() > 0) { $this->_setFreeMethodRequest($freeMethod); $result = $this->_getQuotes(); @@ -195,7 +369,9 @@ abstract class Mage_Shipping_Model_Carrier_Abstract extends Varien_Object } if (count($rates) > 1) { foreach ($rates as $rate) { - if ($rate instanceof Mage_Shipping_Model_Rate_Result_Method && $rate->getMethod() == $freeMethod) { + if ($rate instanceof Mage_Shipping_Model_Rate_Result_Method + && $rate->getMethod() == $freeMethod + ) { $price = $rate->getPrice(); } } @@ -217,12 +393,18 @@ abstract class Mage_Shipping_Model_Carrier_Abstract extends Varien_Object } } + /** + * Calculate price considering free shipping and handling fee + * + * @param string $cost + * @param string $method + * @return string + */ public function getMethodPrice($cost, $method='') { - if ($method == $this->getConfigData('free_method') && - $this->getConfigData('free_shipping_enable') && - $this->getConfigData('free_shipping_subtotal') <= $this->_rawRequest->getValueWithDiscount()) - { + if ($method == $this->getConfigData($this->_freeMethod) && $this->getConfigData('free_shipping_enable') + && $this->getConfigData('free_shipping_subtotal') <= $this->_rawRequest->getBaseSubtotalInclTax() + ) { $price = '0.00'; } else { $price = $this->getFinalPriceWithHandlingFee($cost); @@ -230,15 +412,15 @@ abstract class Mage_Shipping_Model_Carrier_Abstract extends Varien_Object return $price; } - /** + /** * get the handling fee for the shipping + cost * - * @return final price for shipping emthod + * @param float $cost + * @return float final price for shipping method */ public function getFinalPriceWithHandlingFee($cost) { $handlingFee = $this->getConfigData('handling_fee'); - $finalMethodPrice = 0; $handlingType = $this->getConfigData('handling_type'); if (!$handlingType) { $handlingType = self::HANDLING_TYPE_FIXED; @@ -248,29 +430,50 @@ abstract class Mage_Shipping_Model_Carrier_Abstract extends Varien_Object $handlingAction = self::HANDLING_ACTION_PERORDER; } - if($handlingAction == self::HANDLING_ACTION_PERPACKAGE) - { - if ($handlingType == self::HANDLING_TYPE_PERCENT) { - $finalMethodPrice = ($cost + ($cost * $handlingFee/100)) * $this->_numBoxes; - } else { - $finalMethodPrice = ($cost + $handlingFee) * $this->_numBoxes; - } - } else { - if ($handlingType == self::HANDLING_TYPE_PERCENT) { - $finalMethodPrice = ($cost * $this->_numBoxes) + ($cost * $this->_numBoxes * $handlingFee/100); - } else { - $finalMethodPrice = ($cost * $this->_numBoxes) + $handlingFee; - } + return ($handlingAction == self::HANDLING_ACTION_PERPACKAGE) + ? $this->_getPerpackagePrice($cost, $handlingType, $handlingFee) + : $this->_getPerorderPrice($cost, $handlingType, $handlingFee); + } + /** + * Get final price for shipping method with handling fee per package + * + * @param float $cost + * @param string $handlingType + * @param float $handlingFee + * @return float + */ + protected function _getPerpackagePrice($cost, $handlingType, $handlingFee) + { + if ($handlingType == self::HANDLING_TYPE_PERCENT) { + return ($cost + ($cost * $handlingFee/100)) * $this->_numBoxes; } - return $finalMethodPrice; + + return ($cost + $handlingFee) * $this->_numBoxes; + } + + /** + * Get final price for shipping method with handling fee per order + * + * @param float $cost + * @param string $handlingType + * @param float $handlingFee + * @return float + */ + protected function _getPerorderPrice($cost, $handlingType, $handlingFee) + { + if ($handlingType == self::HANDLING_TYPE_PERCENT) { + return ($cost * $this->_numBoxes) + ($cost * $this->_numBoxes * $handlingFee / 100); + } + + return ($cost * $this->_numBoxes) + $handlingFee; } /** * Return weight in pounds * - * @param integer Weight in someone measure - * @return float Weight in pounds + * @param integer Weight in someone measure + * @return float Weight in pounds */ public function convertWeightToLbs($weight) { @@ -290,24 +493,40 @@ abstract class Mage_Shipping_Model_Carrier_Abstract extends Varien_Object $this->_numBoxes = 1; $weight = $this->convertWeightToLbs($weight); $maxPackageWeight = $this->getConfigData('max_package_weight'); - if($weight > $maxPackageWeight && $maxPackageWeight != 0) { + if ($weight > $maxPackageWeight && $maxPackageWeight != 0) { $this->_numBoxes = ceil($weight/$maxPackageWeight); $weight = $weight/$this->_numBoxes; } return $weight; } + /** + * Is state province required + * + * @return bool + */ public function isStateProvinceRequired() { return false; } + /** + * Check if city option required + * + * @return boolean + */ public function isCityRequired() { return false; } - public function isZipCodeRequired() + /** + * Determine whether zip-code is required for the country of destination + * + * @param string|null $countryId + * @return bool + */ + public function isZipCodeRequired($countryId = null) { return false; } @@ -355,4 +574,15 @@ abstract class Mage_Shipping_Model_Carrier_Abstract extends Varien_Object { return $this->_code; } + + /** + * Return content types of package + * + * @param Varien_Object $params + * @return array + */ + public function getContentTypes(Varien_Object $params) + { + return array(); + } } diff --git app/code/core/Mage/Shipping/Model/Carrier/Freeshipping.php app/code/core/Mage/Shipping/Model/Carrier/Freeshipping.php index 4b2bb1e..3dc5210 100644 --- app/code/core/Mage/Shipping/Model/Carrier/Freeshipping.php +++ app/code/core/Mage/Shipping/Model/Carrier/Freeshipping.php @@ -53,14 +53,12 @@ class Mage_Shipping_Model_Carrier_Freeshipping } $result = Mage::getModel('shipping/rate_result'); - $packageValue = $request->getPackageValue(); $this->_updateFreeMethodQuote($request); - $allow = ($request->getFreeShipping()) - || ($packageValue >= $this->getConfigData('free_shipping_subtotal')); - - if ($allow) { + if (($request->getFreeShipping()) + || ($request->getBaseSubtotalInclTax() >= $this->getConfigData('free_shipping_subtotal')) + ) { $method = Mage::getModel('shipping/rate_result_method'); $method->setCarrier('freeshipping'); diff --git app/code/core/Mage/Shipping/Model/Config.php app/code/core/Mage/Shipping/Model/Config.php index d0459b8..e3abdc3 100644 --- app/code/core/Mage/Shipping/Model/Config.php +++ app/code/core/Mage/Shipping/Model/Config.php @@ -103,13 +103,8 @@ class Mage_Shipping_Model_Config extends Varien_Object */ protected function _getCarrier($code, $config, $store = null) { -/* - if (isset(self::$_carriers[$code])) { - return self::$_carriers[$code]; - } -*/ if (!isset($config['model'])) { - throw Mage::exception('Mage_Shipping', 'Invalid model for shipping method: '.$code); + return false; } $modelName = $config['model']; diff --git app/code/core/Mage/Shipping/Model/Info.php app/code/core/Mage/Shipping/Model/Info.php index 6022ddd..c2e14c5 100644 --- app/code/core/Mage/Shipping/Model/Info.php +++ app/code/core/Mage/Shipping/Model/Info.php @@ -49,9 +49,9 @@ class Mage_Shipping_Model_Info extends Varien_Object $this->setData($data['key'], $data['id']); $this->setProtectCode($data['hash']); - if ($this->getOrderId()>0) { + if ($this->getOrderId() > 0) { $this->getTrackingInfoByOrder(); - } elseif($this->getShipId()>0) { + } elseif($this->getShipId() > 0) { $this->getTrackingInfoByShip(); } else { $this->getTrackingInfoByTrackId(); @@ -73,7 +73,7 @@ class Mage_Shipping_Model_Info extends Varien_Object /** * Instantiate order model * - * @return Mage_Sales_Model_Order || false + * @return Mage_Sales_Model_Order|bool */ protected function _initOrder() { @@ -89,7 +89,7 @@ class Mage_Shipping_Model_Info extends Varien_Object /** * Instantiate ship model * - * @return Mage_Sales_Model_Order_Shipment || false + * @return Mage_Sales_Model_Order_Shipment|bool */ protected function _initShipment() { @@ -111,7 +111,8 @@ class Mage_Shipping_Model_Info extends Varien_Object public function getTrackingInfoByOrder() { $shipTrack = array(); - if ($order = $this->_initOrder()) { + $order = $this->_initOrder(); + if ($order) { $shipments = $order->getShipmentsCollection(); foreach ($shipments as $shipment){ $increment_id = $shipment->getIncrementId(); @@ -136,7 +137,8 @@ class Mage_Shipping_Model_Info extends Varien_Object public function getTrackingInfoByShip() { $shipTrack = array(); - if ($shipment = $this->_initShipment()) { + $shipment = $this->_initShipment(); + if ($shipment) { $increment_id = $shipment->getIncrementId(); $tracks = $shipment->getTracksCollection(); diff --git app/code/core/Mage/Shipping/Model/Rate/Result.php app/code/core/Mage/Shipping/Model/Rate/Result.php index d9a1b07..96d0381 100644 --- app/code/core/Mage/Shipping/Model/Rate/Result.php +++ app/code/core/Mage/Shipping/Model/Rate/Result.php @@ -27,11 +27,24 @@ class Mage_Shipping_Model_Rate_Result { + /** + * Shippin method rates + * + * @var array + */ protected $_rates = array(); + + /** + * Shipping errors + * + * @var null|bool + */ protected $_error = null; /** * Reset result + * + * @return Mage_Shipping_Model_Rate_Result */ public function reset() { @@ -39,11 +52,22 @@ class Mage_Shipping_Model_Rate_Result return $this; } + /** + * Set Error + * + * @param bool $error + * @return void + */ public function setError($error) { $this->_error = $error; } + /** + * Get Error + * + * @return null|bool; + */ public function getError() { return $this->_error; @@ -53,6 +77,7 @@ class Mage_Shipping_Model_Rate_Result * Add a rate to the result * * @param Mage_Shipping_Model_Rate_Result_Abstract|Mage_Shipping_Model_Rate_Result $result + * @return Mage_Shipping_Model_Rate_Result */ public function append($result) { @@ -73,6 +98,8 @@ class Mage_Shipping_Model_Rate_Result /** * Return all quotes in the result + * + * @return array */ public function getAllRates() { @@ -81,6 +108,9 @@ class Mage_Shipping_Model_Rate_Result /** * Return rate by id in array + * + * @param int $id + * @return Mage_Shipping_Model_Rate_Result_Method|null */ public function getRateById($id) { @@ -90,19 +120,25 @@ class Mage_Shipping_Model_Rate_Result /** * Return quotes for specified type * - * @param string $type + * @param string $carrier + * @return array */ public function getRatesByCarrier($carrier) { $result = array(); foreach ($this->_rates as $rate) { - if ($rate->getCarrier()===$carrier) { + if ($rate->getCarrier() === $carrier) { $result[] = $rate; } } return $result; } + /** + * Converts object to array + * + * @return array + */ public function asArray() { $currencyFilter = Mage::app()->getStore()->getPriceFilter(); @@ -111,20 +147,25 @@ class Mage_Shipping_Model_Rate_Result foreach ($allRates as $rate) { $rates[$rate->getCarrier()]['title'] = $rate->getCarrierTitle(); $rates[$rate->getCarrier()]['methods'][$rate->getMethod()] = array( - 'title'=>$rate->getMethodTitle(), - 'price'=>$rate->getPrice(), - 'price_formatted'=>$currencyFilter->filter($rate->getPrice()), + 'title' => $rate->getMethodTitle(), + 'price' => $rate->getPrice(), + 'price_formatted' => $currencyFilter->filter($rate->getPrice()), ); } return $rates; } + /** + * Get cheapest rate + * + * @return null|Mage_Shipping_Model_Rate_Result_Method + */ public function getCheapestRate() { $cheapest = null; $minPrice = 100000; foreach ($this->getAllRates() as $rate) { - if (is_numeric($rate->getPrice()) && $rate->getPrice()<$minPrice) { + if (is_numeric($rate->getPrice()) && $rate->getPrice() < $minPrice) { $cheapest = $rate; $minPrice = $rate->getPrice(); } @@ -133,11 +174,11 @@ class Mage_Shipping_Model_Rate_Result } /** - * Sort rates by price from min to max + * Sort rates by price from min to max * - * @return Mage_Shipping_Model_Rate_Result + * @return Mage_Shipping_Model_Rate_Result */ - public function sortRatesByPrice () + public function sortRatesByPrice() { if (!is_array($this->_rates) || !count($this->_rates)) { return $this; @@ -157,4 +198,21 @@ class Mage_Shipping_Model_Rate_Result $this->_rates = $result; return $this; } + + /** + * Set price for each rate according to count of packages + * + * @param int $packageCount + * @return Mage_Shipping_Model_Rate_Result + */ + public function updateRatePrice($packageCount) + { + if ($packageCount > 1) { + foreach ($this->_rates as $rate) { + $rate->setPrice($rate->getPrice() * $packageCount); + } + } + + return $this; + } } diff --git app/code/core/Mage/Shipping/Model/Shipment/Request.php app/code/core/Mage/Shipping/Model/Shipment/Request.php new file mode 100644 index 0000000..2bee4e0 --- /dev/null +++ app/code/core/Mage/Shipping/Model/Shipment/Request.php @@ -0,0 +1,89 @@ + + */ +class Mage_Shipping_Model_Shipment_Request extends Varien_Object +{ +} diff --git app/code/core/Mage/Shipping/Model/Shipment/Return.php app/code/core/Mage/Shipping/Model/Shipment/Return.php new file mode 100644 index 0000000..46f5e62 --- /dev/null +++ app/code/core/Mage/Shipping/Model/Shipment/Return.php @@ -0,0 +1,89 @@ + + */ +class Mage_Shipping_Model_Shipment_Return extends Varien_Object +{ +} diff --git app/code/core/Mage/Shipping/Model/Shipping.php app/code/core/Mage/Shipping/Model/Shipping.php index c7d3ca9..3adc13c 100644 --- app/code/core/Mage/Shipping/Model/Shipping.php +++ app/code/core/Mage/Shipping/Model/Shipping.php @@ -28,6 +28,16 @@ class Mage_Shipping_Model_Shipping { /** + * Store address + */ + const XML_PATH_STORE_ADDRESS1 = 'shipping/origin/street_line1'; + const XML_PATH_STORE_ADDRESS2 = 'shipping/origin/street_line2'; + const XML_PATH_STORE_CITY = 'shipping/origin/city'; + const XML_PATH_STORE_REGION_ID = 'shipping/origin/region_id'; + const XML_PATH_STORE_ZIP = 'shipping/origin/postcode'; + const XML_PATH_STORE_COUNTRY_ID = 'shipping/origin/country_id'; + + /** * Default shipping orig for requests * * @var array @@ -41,6 +51,12 @@ class Mage_Shipping_Model_Shipping */ protected $_result = null; + /** + * Part of carrier xml config path + * + * @var string + */ + protected $_availabilityConfigField = 'active'; /** * Get shipping rate result model @@ -57,6 +73,9 @@ class Mage_Shipping_Model_Shipping /** * Set shipping orig data + * + * @param array $data + * @return null */ public function setOrigData($data) { @@ -65,6 +84,8 @@ class Mage_Shipping_Model_Shipping /** * Reset cached result + * + * @return Mage_Shipping_Model_Shipping */ public function resetResult() { @@ -94,10 +115,10 @@ class Mage_Shipping_Model_Shipping $storeId = $request->getStoreId(); if (!$request->getOrig()) { $request - ->setCountryId(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_COUNTRY_ID, $storeId)) - ->setRegionId(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_REGION_ID, $storeId)) - ->setCity(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_CITY, $storeId)) - ->setPostcode(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_POSTCODE, $storeId)); + ->setCountryId(Mage::getStoreConfig(self::XML_PATH_STORE_COUNTRY_ID, $request->getStore())) + ->setRegionId(Mage::getStoreConfig(self::XML_PATH_STORE_REGION_ID, $request->getStore())) + ->setCity(Mage::getStoreConfig(self::XML_PATH_STORE_CITY, $request->getStore())) + ->setPostcode(Mage::getStoreConfig(self::XML_PATH_STORE_ZIP, $request->getStore())); } $limitCarrier = $request->getLimitCarrier(); @@ -123,23 +144,68 @@ class Mage_Shipping_Model_Shipping return $this; } + /** + * Collect rates of given carrier + * + * @param string $carrierCode + * @param Mage_Shipping_Model_Rate_Request $request + * @return Mage_Shipping_Model_Shipping + */ public function collectCarrierRates($carrierCode, $request) { + /* @var $carrier Mage_Shipping_Model_Carrier_Abstract */ $carrier = $this->getCarrierByCode($carrierCode, $request->getStoreId()); if (!$carrier) { return $this; } + $carrier->setActiveFlag($this->_availabilityConfigField); $result = $carrier->checkAvailableShipCountries($request); if (false !== $result && !($result instanceof Mage_Shipping_Model_Rate_Result_Error)) { $result = $carrier->proccessAdditionalValidation($request); } /* * Result will be false if the admin set not to show the shipping module - * if the devliery country is not within specific countries + * if the delivery country is not within specific countries */ if (false !== $result){ if (!$result instanceof Mage_Shipping_Model_Rate_Result_Error) { - $result = $carrier->collectRates($request); + if ($carrier->getConfigData('shipment_requesttype')) { + $packages = $this->composePackagesForCarrier($carrier, $request); + if (!empty($packages)) { + $sumResults = array(); + foreach ($packages as $weight => $packageCount) { + $request->setPackageWeight($weight); + $result = $carrier->collectRates($request); + if (!$result) { + return $this; + } else { + $result->updateRatePrice($packageCount); + } + $sumResults[] = $result; + } + if (!empty($sumResults) && count($sumResults) > 1) { + $result = array(); + foreach ($sumResults as $res) { + if (empty($result)) { + $result = $res; + continue; + } + foreach ($res->getAllRates() as $method) { + foreach ($result->getAllRates() as $resultMethod) { + if ($method->getMethod() == $resultMethod->getMethod()) { + $resultMethod->setPrice($method->getPrice() + $resultMethod->getPrice()); + continue; + } + } + } + } + } + } else { + $result = $carrier->collectRates($request); + } + } else { + $result = $carrier->collectRates($request); + } if (!$result) { return $this; } @@ -156,7 +222,149 @@ class Mage_Shipping_Model_Shipping return $this; } - public function collectRatesByAddress(Varien_Object $address, $limitCarrier=null) + /** + * Compose Packages For Carrier. + * Devides order into items and items into parts if it's neccesary + * + * @param Mage_Shipping_Model_Carrier_Abstract $carrier + * @param Mage_Shipping_Model_Rate_Request $request + * @return array [int, float] + */ + public function composePackagesForCarrier($carrier, $request) + { + $allItems = $request->getAllItems(); + $fullItems = array(); + + $maxWeight = (float) $carrier->getConfigData('max_package_weight'); + + foreach ($allItems as $item) { + if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE + && $item->getProduct()->getShipmentType() + ) { + continue; + } + + $qty = $item->getQty(); + $changeQty = true; + $checkWeight = true; + $decimalItems = array(); + + if ($item->getParentItem()) { + if (!$item->getParentItem()->getProduct()->getShipmentType()) { + continue; + } + $qty = $item->getIsQtyDecimal() + ? $item->getParentItem()->getQty() + : $item->getParentItem()->getQty() * $item->getQty(); + } + + $itemWeight = $item->getWeight(); + if ($item->getIsQtyDecimal() && $item->getProductType() != Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) { + $stockItem = $item->getProduct()->getStockItem(); + if ($stockItem->getIsDecimalDivided()) { + if ($stockItem->getEnableQtyIncrements() && $stockItem->getQtyIncrements()) { + $itemWeight = $itemWeight * $stockItem->getQtyIncrements(); + $qty = round(($item->getWeight() / $itemWeight) * $qty); + $changeQty = false; + } else { + $itemWeight = $itemWeight * $item->getQty(); + if ($itemWeight > $maxWeight) { + $qtyItem = floor($itemWeight / $maxWeight); + $decimalItems[] = array('weight' => $maxWeight, 'qty' => $qtyItem); + $weightItem = Mage::helper('core')->getExactDivision($itemWeight, $maxWeight); + if ($weightItem) { + $decimalItems[] = array('weight' => $weightItem, 'qty' => 1); + } + $checkWeight = false; + } else { + $itemWeight = $itemWeight * $item->getQty(); + } + } + } else { + $itemWeight = $itemWeight * $item->getQty(); + } + } + + if ($checkWeight && $maxWeight && $itemWeight > $maxWeight) { + return array(); + } + + if ($changeQty && !$item->getParentItem() && $item->getIsQtyDecimal() + && $item->getProductType() != Mage_Catalog_Model_Product_Type::TYPE_BUNDLE + ) { + $qty = 1; + } + + if (!empty($decimalItems)) { + foreach ($decimalItems as $decimalItem) { + $fullItems = array_merge($fullItems, + array_fill(0, $decimalItem['qty'] * $qty, $decimalItem['weight']) + ); + } + } else { + $fullItems = array_merge($fullItems, array_fill(0, $qty, $itemWeight)); + } + } + sort($fullItems); + + return $this->_makePieces($fullItems, $maxWeight); + } + + /** + * Make pieces + * Compose packeges list based on given items, so that each package is as heavy as possible + * + * @param array $items + * @param float $maxWeight + * @return array + */ + protected function _makePieces($items, $maxWeight) + { + $pieces = array(); + if (!empty($items)) { + $sumWeight = 0; + + $reverseOrderItems = $items; + arsort($reverseOrderItems); + + foreach ($reverseOrderItems as $key => $weight) { + if (!isset($items[$key])) { + continue; + } + unset($items[$key]); + $sumWeight = $weight; + foreach ($items as $key => $weight) { + if (($sumWeight + $weight) < $maxWeight) { + unset($items[$key]); + $sumWeight += $weight; + } elseif (($sumWeight + $weight) > $maxWeight) { + $pieces[] = (string)(float)$sumWeight; + break; + } else { + unset($items[$key]); + $pieces[] = (string)(float)($sumWeight + $weight); + $sumWeight = 0; + break; + } + } + } + if ($sumWeight > 0) { + $pieces[] = (string)(float)$sumWeight; + } + $pieces = array_count_values($pieces); + } + + return $pieces; + } + + /** + * Collect rates by address + * + * @param Varien_Object $address + * @param null|bool|array $limitCarrier + * @return Mage_Shipping_Model_Shipping + */ + public function collectRatesByAddress(Varien_Object $address, $limitCarrier = null) { /** @var $request Mage_Shipping_Model_Rate_Request */ $request = Mage::getModel('shipping/rate_request'); @@ -175,18 +383,38 @@ class Mage_Shipping_Model_Shipping $request->setPackageCurrency(Mage::app()->getStore()->getCurrentCurrency()); $request->setLimitCarrier($limitCarrier); + $request->setBaseSubtotalInclTax($address->getBaseSubtotalInclTax()); + return $this->collectRates($request); } + /** + * Set part of carrier xml config path + * + * @param string $code + * @return Mage_Shipping_Model_Shipping + */ + public function setCarrierAvailabilityConfigField($code = 'active') + { + $this->_availabilityConfigField = $code; + return $this; + } + + /** + * Get carrier by its code + * + * @param string $carrierCode + * @param null|int $storeId + * @return bool|Mage_Core_Model_Abstract + */ public function getCarrierByCode($carrierCode, $storeId = null) { - if (!Mage::getStoreConfigFlag('carriers/'.$carrierCode.'/active', $storeId)) { + if (!Mage::getStoreConfigFlag('carriers/'.$carrierCode.'/'.$this->_availabilityConfigField, $storeId)) { return false; } $className = Mage::getStoreConfig('carriers/'.$carrierCode.'/model', $storeId); if (!$className) { return false; - #Mage::throwException('Invalid carrier: '.$carrierCode); } $obj = Mage::getModel($className); if ($storeId) { @@ -195,4 +423,81 @@ class Mage_Shipping_Model_Shipping return $obj; } + /** + * Prepare and do request to shipment + * + * @param Mage_Sales_Model_Order_Shipment $orderShipment + * @return Varien_Object + */ + public function requestToShipment(Mage_Sales_Model_Order_Shipment $orderShipment) + { + $admin = Mage::getSingleton('admin/session')->getUser(); + $order = $orderShipment->getOrder(); + $address = $order->getShippingAddress(); + $shippingMethod = $order->getShippingMethod(true); + $shipmentStoreId = $orderShipment->getStoreId(); + $shipmentCarrier = $order->getShippingCarrier(); + $baseCurrencyCode = Mage::app()->getStore($shipmentStoreId)->getBaseCurrencyCode(); + if (!$shipmentCarrier) { + Mage::throwException('Invalid carrier: ' . $shippingMethod->getCarrierCode()); + } + $shipperRegionCode = Mage::getStoreConfig(self::XML_PATH_STORE_REGION_ID, $shipmentStoreId); + if (is_numeric($shipperRegionCode)) { + $shipperRegionCode = Mage::getModel('directory/region')->load($shipperRegionCode)->getCode(); + } + + $recipientRegionCode = Mage::getModel('directory/region')->load($address->getRegionId())->getCode(); + + $originStreet1 = Mage::getStoreConfig(self::XML_PATH_STORE_ADDRESS1, $shipmentStoreId); + $originStreet2 = Mage::getStoreConfig(self::XML_PATH_STORE_ADDRESS2, $shipmentStoreId); + $storeInfo = new Varien_Object(Mage::getStoreConfig('general/store_information', $shipmentStoreId)); + + if (!$admin->getFirstname() || !$admin->getLastname() || !$storeInfo->getName() || !$storeInfo->getPhone() + || !$originStreet1 || !Mage::getStoreConfig(self::XML_PATH_STORE_CITY, $shipmentStoreId) + || !$shipperRegionCode || !Mage::getStoreConfig(self::XML_PATH_STORE_ZIP, $shipmentStoreId) + || !Mage::getStoreConfig(self::XML_PATH_STORE_COUNTRY_ID, $shipmentStoreId) + ) { + Mage::throwException( + Mage::helper('sales')->__('Insufficient information to create shipping label(s). Please verify your Store Information and Shipping Settings.') + ); + } + + /** @var $request Mage_Shipping_Model_Shipment_Request */ + $request = Mage::getModel('shipping/shipment_request'); + $request->setOrderShipment($orderShipment); + $request->setShipperContactPersonName($admin->getName()); + $request->setShipperContactPersonFirstName($admin->getFirstname()); + $request->setShipperContactPersonLastName($admin->getLastname()); + $request->setShipperContactCompanyName($storeInfo->getName()); + $request->setShipperContactPhoneNumber($storeInfo->getPhone()); + $request->setShipperEmail($admin->getEmail()); + $request->setShipperAddressStreet(trim($originStreet1 . ' ' . $originStreet2)); + $request->setShipperAddressStreet1($originStreet1); + $request->setShipperAddressStreet2($originStreet2); + $request->setShipperAddressCity(Mage::getStoreConfig(self::XML_PATH_STORE_CITY, $shipmentStoreId)); + $request->setShipperAddressStateOrProvinceCode($shipperRegionCode); + $request->setShipperAddressPostalCode(Mage::getStoreConfig(self::XML_PATH_STORE_ZIP, $shipmentStoreId)); + $request->setShipperAddressCountryCode(Mage::getStoreConfig(self::XML_PATH_STORE_COUNTRY_ID, $shipmentStoreId)); + $request->setRecipientContactPersonName(trim($address->getFirstname() . ' ' . $address->getLastname())); + $request->setRecipientContactPersonFirstName($address->getFirstname()); + $request->setRecipientContactPersonLastName($address->getLastname()); + $request->setRecipientContactCompanyName($address->getCompany()); + $request->setRecipientContactPhoneNumber($address->getTelephone()); + $request->setRecipientEmail($address->getEmail()); + $request->setRecipientAddressStreet(trim($address->getStreet1() . ' ' . $address->getStreet2())); + $request->setRecipientAddressStreet1($address->getStreet1()); + $request->setRecipientAddressStreet2($address->getStreet2()); + $request->setRecipientAddressCity($address->getCity()); + $request->setRecipientAddressStateOrProvinceCode($address->getRegionCode()); + $request->setRecipientAddressRegionCode($recipientRegionCode); + $request->setRecipientAddressPostalCode($address->getPostcode()); + $request->setRecipientAddressCountryCode($address->getCountryId()); + $request->setShippingMethod($shippingMethod->getMethod()); + $request->setPackageWeight($order->getWeight()); + $request->setPackages($orderShipment->getPackages()); + $request->setBaseCurrencyCode($baseCurrencyCode); + $request->setStoreId($shipmentStoreId); + + return $shipmentCarrier->requestToShipment($request); + } } diff --git app/code/core/Mage/Shipping/etc/system.xml app/code/core/Mage/Shipping/etc/system.xml index bad6fa6..0eec924 100644 --- app/code/core/Mage/Shipping/etc/system.xml +++ app/code/core/Mage/Shipping/etc/system.xml @@ -56,6 +56,7 @@ text + validate-number 2 1 1 @@ -105,6 +106,22 @@ 1 0 + + + text + 50 + 1 + 1 + 0 + + + + text + 60 + 1 + 1 + 0 + @@ -146,6 +163,7 @@ text + validate-number validate-zero-or-greater 5 1 1 @@ -163,6 +181,7 @@ text + validate-number validate-zero-or-greater 8 1 1 @@ -252,6 +271,7 @@ text + validate-number validate-zero-or-greater 4 1 1 @@ -340,6 +360,7 @@ text + validate-number validate-zero-or-greater 8 1 1 diff --git app/code/core/Mage/Usa/Block/Adminhtml/Dhl/Unitofmeasure.php app/code/core/Mage/Usa/Block/Adminhtml/Dhl/Unitofmeasure.php new file mode 100644 index 0000000..43bce83 --- /dev/null +++ app/code/core/Mage/Usa/Block/Adminhtml/Dhl/Unitofmeasure.php @@ -0,0 +1,82 @@ + + */ +class Mage_Usa_Block_Adminhtml_Dhl_Unitofmeasure extends Mage_Adminhtml_Block_System_Config_Form_Field +{ + + /** + * Define params and variables + * + * @return void + */ + public function _construct() + { + parent::_construct(); + + $carrierModel = Mage::getSingleton('usa/shipping_carrier_dhl_international'); + + $this->setInch($this->jsQuoteEscape($carrierModel->getCode('unit_of_dimension_cut', 'I'))); + $this->setCm($this->jsQuoteEscape($carrierModel->getCode('unit_of_dimension_cut', 'C'))); + + $this->setHeight($this->jsQuoteEscape($carrierModel->getCode('dimensions', 'height'))); + $this->setDepth($this->jsQuoteEscape($carrierModel->getCode('dimensions', 'depth'))); + $this->setWidth($this->jsQuoteEscape($carrierModel->getCode('dimensions', 'width'))); + + $kgWeight = 70; + + $this->setDivideOrderWeightNoteKg( + $this->jsQuoteEscape($this->__('Allows breaking total order weight into smaller pieces if it exeeds %s %s to ensure accurate calculation of shipping charges.', $kgWeight, 'kg')) + ); + + $weight = round( + Mage::helper('usa')->convertMeasureWeight( + $kgWeight, Zend_Measure_Weight::KILOGRAM, Zend_Measure_Weight::POUND), 3); + + $this->setDivideOrderWeightNoteLbp( + $this->jsQuoteEscape($this->__('Allows breaking total order weight into smaller pieces if it exeeds %s %s to ensure accurate calculation of shipping charges.', $weight, 'pounds')) + ); + + $this->setTemplate('usa/dhl/unitofmeasure.phtml'); + } + + /** + * Retrieve Element HTML fragment + * + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) + { + return parent::_getElementHtml($element) . $this->renderView(); + } +} diff --git app/code/core/Mage/Usa/Helper/Data.php app/code/core/Mage/Usa/Helper/Data.php index 3720eb7..175fb81 100644 --- app/code/core/Mage/Usa/Helper/Data.php +++ app/code/core/Mage/Usa/Helper/Data.php @@ -20,16 +20,119 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - + /** - * Catalog data helper + * Usa data helper * * @author Magento Core Team */ class Mage_Usa_Helper_Data extends Mage_Core_Helper_Abstract { + /** + * Convert weight in different measure types + * + * @param mixed $value + * @param string $sourceWeightMeasure + * @param string $toWeightMeasure + * @return int|null|string + */ + public function convertMeasureWeight($value, $sourceWeightMeasure, $toWeightMeasure) + { + if ($value) { + $locale = Mage::app()->getLocale()->getLocale(); + $unitWeight = new Zend_Measure_Weight($value, $sourceWeightMeasure, $locale); + $unitWeight->setType($toWeightMeasure); + return $unitWeight->getValue(); + } + return null; + } + + /** + * Convert dimensions in different measure types + * + * @param mixed $value + * @param string $sourceDimensionMeasure + * @param string $toDimensionMeasure + * @return int|null|string + */ + public function convertMeasureDimension($value, $sourceDimensionMeasure, $toDimensionMeasure) + { + if ($value) { + $locale = Mage::app()->getLocale()->getLocale(); + $unitDimension = new Zend_Measure_Length($value, $sourceDimensionMeasure, $locale); + $unitDimension->setType($toDimensionMeasure); + return $unitDimension->getValue(); + } + return null; + } + + /** + * Get name of measure by its type + * + * @param $key + * @return string + */ + public function getMeasureWeightName($key) + { + $weight = new Zend_Measure_Weight(0); + $conversionList = $weight->getConversionList(); + if (!empty($conversionList[$key]) && !empty($conversionList[$key][1])) { + return $conversionList[$key][1]; + } + return ''; + } + + /** + * Get name of measure by its type + * + * @param $key + * @return string + */ + public function getMeasureDimensionName($key) + { + $weight = new Zend_Measure_Length(0); + $conversionList = $weight->getConversionList(); + if (!empty($conversionList[$key]) && !empty($conversionList[$key][1])) { + return $conversionList[$key][1]; + } + return ''; + } + /** + * Define if we need girth parameter in the package window + * + * @param string $shippingMethod + * @return bool + */ + public function displayGirthValue($shippingMethod) + { + if (in_array($shippingMethod, array( + 'usps_Priority Mail International', + 'usps_Priority Mail International Small Flat Rate Box', + 'usps_Priority Mail International Medium Flat Rate Box', + 'usps_Priority Mail International Large Flat Rate Box', + 'usps_Priority Mail International Flat Rate Envelope', + 'usps_Express Mail International Flat Rate Envelope', + 'usps_Express Mail Hold For Pickup', + 'usps_Express Mail International', + 'usps_First-Class Mail International Package', + 'usps_First-Class Mail International Parcel', + 'usps_First-Class Mail International Large Envelope', + 'usps_First-Class Mail International', + 'usps_Global Express Guaranteed (GXG)', + 'usps_USPS GXG Envelopes', + 'usps_Global Express Guaranteed Non-Document Non-Rectangular', + 'usps_Media Mail', + 'usps_Parcel Post', + 'usps_Express Mail', + 'usps_Priority Mail' + ))) { + return true; + } else { + return false; + } + } } diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php index 5935aae..7a7cc8f 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -39,6 +39,35 @@ abstract class Mage_Usa_Model_Shipping_Carrier_Abstract extends Mage_Shipping_Mo protected static $_quotesCache = array(); + /** + * Flag for check carriers for activity + * + * @var string + */ + protected $_activeFlag = 'active'; + + /** + * Set flag for check carriers for activity + * + * @param string $code + * @return Mage_Usa_Model_Shipping_Carrier_Abstract + */ + public function setActiveFlag($code = 'active') + { + $this->_activeFlag = $code; + return $this; + } + + /** + * Return code of carrier + * + * @return string + */ + public function getCarrierCode() + { + return isset($this->_code) ? $this->_code : null; + } + public function getTrackingInfo($tracking) { $info = array(); @@ -68,18 +97,76 @@ abstract class Mage_Usa_Model_Shipping_Carrier_Abstract extends Mage_Shipping_Mo return true; } + /** + * Check if city option required + * + * @return boolean + */ public function isCityRequired() { return true; } - public function isZipCodeRequired() + /** + * Determine whether zip-code is required for the country of destination + * + * @param string|null $countryId + * @return bool + */ + public function isZipCodeRequired($countryId = null) { + if ($countryId != null) { + return !Mage::helper('directory')->isZipCodeOptional($countryId); + } return true; } /** - * Processing additional validation to check is carrier applicable. + * Check if carrier has shipping label option available + * + * @return boolean + */ + public function isShippingLabelsAvailable() + { + return true; + } + + /** + * Return items for further shipment rate evaluation. We need to pass children of a bundle instead passing the + * bundle itself, otherwise we may not get a rate at all (e.g. when total weight of a bundle exceeds max weight + * despite each item by itself is not) + * + * @param Mage_Shipping_Model_Rate_Request $request + * @return array + */ + public function getAllItems(Mage_Shipping_Model_Rate_Request $request) + { + $items = array(); + if ($request->getAllItems()) { + foreach ($request->getAllItems() as $item) { + /* @var $item Mage_Sales_Model_Quote_Item */ + if ($item->getProduct()->isVirtual() || $item->getParentItem()) { + // Don't process children here - we will process (or already have processed) them below + continue; + } + + if ($item->getHasChildren() && $item->isShipSeparately()) { + foreach ($item->getChildren() as $child) { + if (!$child->getFreeShipping() && !$child->getProduct()->isVirtual()) { + $items[] = $child; + } + } + } else { + // Ship together - count compound item as one solid + $items[] = $item; + } + } + } + return $items; + } + + /** + * Processing additional validation to check if carrier applicable. * * @param Mage_Shipping_Model_Rate_Request $request * @return Mage_Shipping_Model_Carrier_Abstract|Mage_Shipping_Model_Rate_Result_Error|boolean @@ -87,26 +174,40 @@ abstract class Mage_Usa_Model_Shipping_Carrier_Abstract extends Mage_Shipping_Mo public function proccessAdditionalValidation(Mage_Shipping_Model_Rate_Request $request) { //Skip by item validation if there is no items in request - if(!count($request->getAllItems())) { + if(!count($this->getAllItems($request))) { return $this; } - $maxAllowedWeight = (float) $this->getConfigData('max_package_weight'); - $errorMsg = ''; - $configErrorMsg = $this->getConfigData('specificerrmsg'); - $defaultErrorMsg = Mage::helper('shipping')->__('The shipping module is not available.'); - $showMethod = $this->getConfigData('showmethod'); + $maxAllowedWeight = (float) $this->getConfigData('max_package_weight'); + $errorMsg = ''; + $configErrorMsg = $this->getConfigData('specificerrmsg'); + $defaultErrorMsg = Mage::helper('shipping')->__('The shipping module is not available.'); + $showMethod = $this->getConfigData('showmethod'); - foreach ($request->getAllItems() as $item) { + foreach ($this->getAllItems($request) as $item) { if ($item->getProduct() && $item->getProduct()->getId()) { - if ($item->getProduct()->getWeight() > $maxAllowedWeight) { + $weight = $item->getProduct()->getWeight(); + $stockItem = $item->getProduct()->getStockItem(); + $doValidation = true; + + if ($stockItem->getIsQtyDecimal() && $stockItem->getIsDecimalDivided()) { + if ($stockItem->getEnableQtyIncrements() && $stockItem->getQtyIncrements()) { + $weight = $weight * $stockItem->getQtyIncrements(); + } else { + $doValidation = false; + } + } elseif ($stockItem->getIsQtyDecimal() && !$stockItem->getIsDecimalDivided()) { + $weight = $weight * $item->getQty(); + } + + if ($doValidation && $weight > $maxAllowedWeight) { $errorMsg = ($configErrorMsg) ? $configErrorMsg : $defaultErrorMsg; break; } } } - if (!$errorMsg && !$request->getDestPostcode() && $this->isZipCodeRequired()) { + if (!$errorMsg && !$request->getDestPostcode() && $this->isZipCodeRequired($request->getDestCountryId())) { $errorMsg = Mage::helper('shipping')->__('This shipping method is not available, please specify ZIP-code'); } @@ -131,7 +232,11 @@ abstract class Mage_Usa_Model_Shipping_Carrier_Abstract extends Mage_Shipping_Mo protected function _getQuotesCacheKey($requestParams) { if (is_array($requestParams)) { - $requestParams = implode(',', array_merge(array($this->getCarrierCode()), array_keys($requestParams), $requestParams)); + $requestParams = implode(',', array_merge( + array($this->getCarrierCode()), + array_keys($requestParams), + $requestParams) + ); } return crc32($requestParams); } @@ -164,4 +269,185 @@ abstract class Mage_Usa_Model_Shipping_Carrier_Abstract extends Mage_Shipping_Mo self::$_quotesCache[$key] = $response; return $this; } + + /** + * Prepare service name. Strip tags and entities from name + * + * @param string|object $name service name or object with implemented __toString() method + * @return string prepared service name + */ + protected function _prepareServiceName($name) + { + $name = html_entity_decode((string)$name); + $name = strip_tags(preg_replace('#&\w+;#', '', $name)); + return trim($name); + } + + /** + * Prepare shipment request. + * Validate and correct request information + * + * @param Varien_Object $request + * + */ + protected function _prepareShipmentRequest(Varien_Object $request) + { + $phonePattern = '/[\s\_\-\(\)]+/'; + $phoneNumber = $request->getShipperContactPhoneNumber(); + $phoneNumber = preg_replace($phonePattern, '', $phoneNumber); + $request->setShipperContactPhoneNumber($phoneNumber); + $phoneNumber = $request->getRecipientContactPhoneNumber(); + $phoneNumber = preg_replace($phonePattern, '', $phoneNumber); + $request->setRecipientContactPhoneNumber($phoneNumber); + } + + /** + * Do request to shipment + * + * @param Mage_Shipping_Model_Shipment_Request $request + * @return array + */ + public function requestToShipment(Mage_Shipping_Model_Shipment_Request $request) + { + $packages = $request->getPackages(); + if (!is_array($packages) || !$packages) { + Mage::throwException(Mage::helper('usa')->__('No packages for request')); + } + if ($request->getStoreId() != null) { + $this->setStore($request->getStoreId()); + } + $data = array(); + foreach ($packages as $packageId => $package) { + $request->setPackageId($packageId); + $request->setPackagingType($package['params']['container']); + $request->setPackageWeight($package['params']['weight']); + $request->setPackageParams(new Varien_Object($package['params'])); + $request->setPackageItems($package['items']); + $result = $this->_doShipmentRequest($request); + + if ($result->hasErrors()) { + $this->rollBack($data); + break; + } else { + $data[] = array( + 'tracking_number' => $result->getTrackingNumber(), + 'label_content' => $result->getShippingLabelContent() + ); + } + if (!isset($isFirstRequest)) { + $request->setMasterTrackingId($result->getTrackingNumber()); + $isFirstRequest = false; + } + } + + $response = new Varien_Object(array( + 'info' => $data + )); + if ($result->getErrors()) { + $response->setErrors($result->getErrors()); + } + return $response; + } + + /** + * Do request to RMA shipment + * + * @param $request + * @return array + */ + public function returnOfShipment($request) + { + $request->setIsReturn(true); + $packages = $request->getPackages(); + if (!is_array($packages) || !$packages) { + Mage::throwException(Mage::helper('usa')->__('No packages for request')); + } + if ($request->getStoreId() != null) { + $this->setStore($request->getStoreId()); + } + $data = array(); + foreach ($packages as $packageId => $package) { + $request->setPackageId($packageId); + $request->setPackagingType($package['params']['container']); + $request->setPackageWeight($package['params']['weight']); + $request->setPackageParams(new Varien_Object($package['params'])); + $request->setPackageItems($package['items']); + $result = $this->_doShipmentRequest($request); + + if ($result->hasErrors()) { + $this->rollBack($data); + break; + } else { + $data[] = array( + 'tracking_number' => $result->getTrackingNumber(), + 'label_content' => $result->getShippingLabelContent() + ); + } + if (!isset($isFirstRequest)) { + $request->setMasterTrackingId($result->getTrackingNumber()); + $isFirstRequest = false; + } + } + + $response = new Varien_Object(array( + 'info' => $data + )); + if ($result->getErrors()) { + $response->setErrors($result->getErrors()); + } + return $response; + } + + /** + * For multi package shipments. Delete requested shipments if the current shipment + * request is failed + * + * @todo implement rollback logic + * @param array $data + * @return bool + */ + public function rollBack($data) + { + return true; + } + + /** + * Do shipment request to carrier web service, obtain Print Shipping Labels and process errors in response + * + * @param Varien_Object $request + * @return Varien_Object + */ + abstract protected function _doShipmentRequest(Varien_Object $request); + + /** + * Check is Country U.S. Possessions and Trust Territories + * + * @param string $countyId + * @return boolean + */ + protected function _isUSCountry($countyId) + { + switch ($countyId) { + case 'AS': // Samoa American + case 'GU': // Guam + case 'MP': // Northern Mariana Islands + case 'PW': // Palau + case 'PR': // Puerto Rico + case 'VI': // Virgin Islands US + case 'US'; // United States + return true; + } + + return false; + } + + /** + * Check whether girth is allowed for the carrier + * + * @param null|string $countyDest + * @return bool + */ + public function isGirthAllowed($countyDest = null) { + return false; + } } diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract/Source/Mode.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract/Source/Mode.php new file mode 100644 index 0000000..18b97b9 --- /dev/null +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract/Source/Mode.php @@ -0,0 +1,49 @@ + + */ + +class Mage_Usa_Model_Shipping_Carrier_Abstract_Source_Mode +{ + /** + * Returns array to be used in packages request type on back-end + * + * @return array + */ + public function toOptionArray() + { + return array( + array('value' => '0', 'label' => Mage::helper('usa')->__('Development')), + array('value' => '1', 'label' => Mage::helper('usa')->__('Live')), + ); + } +} diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract/Source/Requesttype.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract/Source/Requesttype.php new file mode 100644 index 0000000..ce5bd74 --- /dev/null +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract/Source/Requesttype.php @@ -0,0 +1,48 @@ + + */ +class Mage_Usa_Model_Shipping_Carrier_Abstract_Source_Requesttype +{ + /** + * Returns array to be used in packages request type on back-end + * + * @return array + */ + public function toOptionArray() + { + return array( + array('value' => 0, 'label' => Mage::helper('shipping')->__('Divide to equal weight (one request)')), + array('value' => 1, 'label' => Mage::helper('shipping')->__('Use origin weight (few requests)')), + ); + } +} diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php index 0186fad..1612648 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php @@ -20,13 +20,13 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** - * DHL shipping rates estimation + * DHL shipping implementation * * @category Mage * @package Mage_Usa @@ -37,19 +37,71 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl implements Mage_Shipping_Model_Carrier_Interface { - protected $_code = 'dhl'; + /** + * Code of the carrier + * + * @var string + */ + const CODE = 'dhl'; + + /** + * Code of the carrier + * + * @var string + */ + protected $_code = self::CODE; + /** + * Rate request data + * + * @var Mage_Shipping_Model_Rate_Request|null + */ protected $_request = null; + /** + * Raw rate request data + * + * @var Varien_Object|null + */ + protected $_rawRequest = null; + + /** + * Rate result data + * + * @var Mage_Shipping_Model_Rate_Result|null + */ protected $_result = null; + /** + * Errors placeholder + * + * @var array + */ protected $_errors = array(); + /** + * Dhl rates result + * + * @var array + */ protected $_dhlRates = array(); + /** + * Default gateway url + * + * @var string + */ protected $_defaultGatewayUrl = 'https://eCommerce.airborne.com/ApiLandingTest.asp'; + /** + * Container types that could be customized + * + * @var array + */ + protected $_customizableContainerTypes = array('P'); + const SUCCESS_CODE = 203; + const SUCCESS_LABEL_CODE = 100; const ADDITIONAL_PROTECTION_ASSET = 'AP'; const ADDITIONAL_PROTECTION_NOT_REQUIRED = 'NR'; @@ -62,28 +114,87 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl const ADDITIONAL_PROTECTION_ROUNDING_CEIL = 1; const ADDITIONAL_PROTECTION_ROUNDING_ROUND = 2; - + /** + * Collect and get rates + * + * @param Mage_Shipping_Model_Rate_Request $request + * @return bool|Mage_Shipping_Model_Rate_Result|null + */ public function collectRates(Mage_Shipping_Model_Rate_Request $request) { - if (!$this->getConfigFlag('active')) { + if (!$this->getConfigFlag($this->_activeFlag)) { return false; } - $this->setRequest($request); + $requestDhl = clone $request; + $origCompanyName = $requestDhl->getOrigCompanyName(); + if (!$origCompanyName) { + $origCompanyName = Mage::getStoreConfig( + Mage_Core_Model_Store::XML_PATH_STORE_STORE_NAME, + $requestDhl->getStoreId() + ); + } - $this->_result = $this->_getQuotes(); + $origCountryId = $requestDhl->getOrigCountryId(); + if (!$origCountryId) { + $origCountryId = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, + $requestDhl->getStoreId() + ); + } + $origState = $requestDhl->getOrigState(); + if (!$origState) { + $origState = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_REGION_ID, + $requestDhl->getStoreId() + ); + } + $origCity = $requestDhl->getOrigCity(); + if (!$origCity) { + $origCity = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_CITY, + $requestDhl->getStoreId() + ); + } + $origPostcode = $requestDhl->getOrigPostcode(); + if (!$origPostcode) { + $origPostcode = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP, + $requestDhl->getStoreId() + ); + } + $requestDhl->setOrigCompanyName($origCompanyName) + ->setCountryId($origCountryId) + ->setOrigState($origState) + ->setOrigCity($origCity) + ->setOrigPostal($origPostcode); + $this->setRequest($requestDhl); + $this->_result = $this->_getQuotes(); $this->_updateFreeMethodQuote($request); return $this->getResult(); } - public function setRequest(Mage_Shipping_Model_Rate_Request $request) + /** + * Prepare and set request in property of current instance + * + * @param Varien_Object $request + * @return Mage_Usa_Model_Shipping_Carrier_Dhl + */ + public function setRequest(Varien_Object $request) { $this->_request = $request; $r = new Varien_Object(); + if ($request->getAction() == 'GenerateLabel') { + $r->setAction('GenerateLabel'); + } else { + $r->setAction('RateEstimate'); + } + $r->setIsGenerateLabelReturn($request->getIsGenerateLabelReturn()); + $r->setStoreId($request->getStoreId()); if ($request->getLimitMethod()) { @@ -132,24 +243,24 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl } $r->setShipmentType($shipmentType); - if($request->getDhlDutiable()){ + if ($request->getDhlDutiable()) { $shipmentDutible = $request->getDhlDutiable(); - }else{ + } else { $shipmentDutible = $this->getConfigData('dutiable'); } $r->setDutiable($shipmentDutible); - if($request->getDhlDutyPaymentType()){ + if ($request->getDhlDutyPaymentType()) { $dutypaytype = $request->getDhlDutyPaymentType(); - }else{ - $dutypaytype = $this->getConfigData('dutypaymenttype'); + } else { + $dutypaytype = $this->getConfigData('dutypaymenttype'); } $r->setDutyPaymentType($dutypaytype); - if($request->getDhlContentDesc()){ - $contentdesc = $request->getDhlContentDesc(); - }else{ - $contentdesc = $this->getConfigData('contentdesc'); + if ($request->getDhlContentDesc()) { + $contentdesc = $request->getDhlContentDesc(); + } else { + $contentdesc = $this->getConfigData('contentdesc'); } $r->setContentDesc($contentdesc); @@ -160,20 +271,89 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl if ($request->getOrigCountry()) { $origCountry = $request->getOrigCountry(); } else { - $origCountry = Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_COUNTRY_ID, $this->getStore()); + $origCountry = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, + $r->getStoreId() + ); } $r->setOrigCountry($origCountry); - /* - * DHL only accepts weight as a whole number. Maximum length is 3 digits. - */ - $weight = $this->getTotalNumOfBoxes($request->getPackageWeight()); - $shippingWeight = round(max(1, $weight),0); + if ($request->getOrigCountryId()) { + $origCountryId = $request->getOrigCountryId(); + } else { + $origCountryId = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, + $r->getStoreId() + ); + } + $r->setOrigCountryId($origCountryId); + + if ($request->getAction() == 'GenerateLabel') { + $packageParams = $request->getPackageParams(); + $shippingWeight = $request->getPackageWeight(); + if ($packageParams->getWeightUnits() != Zend_Measure_Weight::POUND) { + $shippingWeight = round(Mage::helper('usa')->convertMeasureWeight( + $request->getPackageWeight(), + $packageParams->getWeightUnits(), + Zend_Measure_Weight::POUND + )); + } + if ($packageParams->getDimensionUnits() != Zend_Measure_Length::INCH) { + $packageParams->setLength(round(Mage::helper('usa')->convertMeasureDimension( + $packageParams->getLength(), + $packageParams->getDimensionUnits(), + Zend_Measure_Length::INCH + ))); + $packageParams->setWidth(round(Mage::helper('usa')->convertMeasureDimension( + $packageParams->getWidth(), + $packageParams->getDimensionUnits(), + Zend_Measure_Length::INCH + ))); + $packageParams->setHeight(round(Mage::helper('usa')->convertMeasureDimension( + $packageParams->getHeight(), + $packageParams->getDimensionUnits(), + Zend_Measure_Length::INCH + ))); + } + $r->setPackageParams($packageParams); + } else { + /* + * DHL only accepts weight as a whole number. Maximum length is 3 digits. + */ + $shippingWeight = $request->getPackageWeight(); + if ($shipmentType != 'L') { + $weight = $this->getTotalNumOfBoxes($shippingWeight); + $shippingWeight = round(max(1, $weight), 0); + } + } - $r->setValue(round($request->getPackageValue(),2)); + $r->setValue(round($request->getPackageValue(), 2)); $r->setValueWithDiscount($request->getPackageValueWithDiscount()); - $r->setDestStreet(Mage::helper('core/string')->substr($request->getDestStreet(), 0, 35)); + $r->setCustomsValue($request->getPackageCustomsValue()); + $r->setDestStreet(Mage::helper('core/string')->substr(str_replace("\n", '', $request->getDestStreet()), 0, 35)); + $r->setDestStreetLine2($request->getDestStreetLine2()); $r->setDestCity($request->getDestCity()); + $r->setOrigCompanyName($request->getOrigCompanyName()); + $r->setOrigCity($request->getOrigCity()); + $r->setOrigPhoneNumber($request->getOrigPhoneNumber()); + $r->setOrigPersonName($request->getOrigPersonName()); + $r->setOrigEmail(Mage::getStoreConfig('trans_email/ident_general/email', $r->getStoreId())); + $r->setOrigCity($request->getOrigCity()); + $r->setOrigPostal($request->getOrigPostal()); + $originStreet1 = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_ADDRESS1,$r->getStoreId()); + $originStreet2 = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_ADDRESS2, $r->getStoreId()); + $r->setOrigStreet($request->getOrigStreet() ? $request->getOrigStreet() : $originStreet2); + $r->setOrigStreetLine2($request->getOrigStreetLine2()); + $r->setDestPhoneNumber($request->getDestPhoneNumber()); + $r->setDestPersonName($request->getDestPersonName()); + $r->setDestCompanyName($request->getDestCompanyName()); + + + if (is_numeric($request->getOrigState())) { + $r->setOrigState(Mage::getModel('directory/region')->load($request->getOrigState())->getCode()); + } else { + $r->setOrigState($request->getOrigState()); + } if ($request->getDestCountryId()) { $destCountry = $request->getDestCountryId(); @@ -183,110 +363,74 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl //for DHL, puero rico state for US will assume as puerto rico country //for puerto rico, dhl will ship as international - if ($destCountry==self::USA_COUNTRY_ID && ($request->getDestPostcode()=='00912' || $request->getDestRegionCode()==self::PUERTORICO_COUNTRY_ID)) { + if ($destCountry == self::USA_COUNTRY_ID && ($request->getDestPostcode() == '00912' + || $request->getDestRegionCode() == self::PUERTORICO_COUNTRY_ID) + ) { $destCountry = self::PUERTORICO_COUNTRY_ID; } $r->setDestCountryId($destCountry); - $r->setDestState( $request->getDestRegionCode()); - - $r->setWeight($shippingWeight); - $r->setFreeMethodWeight($request->getFreeMethodWeight()); - $this->_rawRequest = $r; -// $methods = explode(',', $this->getConfigData('allowed_methods')); -// -// $freeMethod = $this->getConfigData('free_method'); -// -// $internationcode = $this->getCode('international_searvice'); - - - -// $minOrderAmount = $this->getConfigData('cutoff_cost') ? $this->getConfigData('cutoff_cost') : 0; -// if ($shippingWeight>0) { -// $this->_rawRequest->setWeight($shippingWeight); -// $this->_getQuotes(); -// foreach ($methods as $method) { -// if(($method==$internationcode && ($r->getDestCountryId() != self::USA_COUNTRY_ID)) || -// ($method!=$internationcode && ($r->getDestCountryId() == self::USA_COUNTRY_ID))) -// { -// $weight = $freeMethod==$method && $this->getConfigData('cutoff_cost') <= $r->getValue() ? 0 : $shippingWeight; -// if ($weight>0) { -// $this->_rawRequest->setWeight($weight); -// $this->_rawRequest->setService($method); -// $this->_getQuotes(); -// } else { -// $this->_dhlRates[$method] = array( -// 'term' => $this->getCode('service', $method), -// 'price_total' => 0, -// ); -// } -// } -// } -// } else { -// $this->_errors[] = Mage::helper('usa')->__('Please enter the package weight'); -// } + $r->setDestState($request->getDestRegionCode()); + + $r->setWeight($shippingWeight); + $r->setFreeMethodWeight($request->getFreeMethodWeight()); + + $r->setOrderShipment($request->getOrderShipment()); + + if ($request->getPackageId()) { + $r->setPackageId($request->getPackageId()); + } + + $r->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax()); + $this->_rawRequest = $r; return $this; } + /** + * Get result of request + * + * @return mixed + */ public function getResult() { return $this->_result; -// $result = Mage::getModel('shipping/rate_result'); -// -// foreach ($this->_errors as $errorText) { -// $error = Mage::getModel('shipping/rate_result_error'); -// $error->setCarrier('dhl'); -// $error->setCarrierTitle($this->getConfigData('title')); -// $error->setErrorMessage($errorText); -// $result->append($error); -// } -// -// foreach($this->_dhlRates as $method => $data) { -// $rate = Mage::getModel('shipping/rate_result_method'); -// $rate->setCarrier('dhl'); -// $rate->setCarrierTitle($this->getConfigData('title')); -// $rate->setMethod($method); -// $rate->setMethodTitle($data['term']); -// $rate->setCost($data['price_total']); -// $rate->setPrice($data['price_total']); -// $result->append($rate); -// } -// -// return $result; } + /** + * Get quotes + * + * @return Mage_Shipping_Model_Rate_Result + */ protected function _getQuotes() { return $this->_getXmlQuotes(); } + /** + * Set free method request + * + * @param $freeMethod + * @return void + */ protected function _setFreeMethodRequest($freeMethod) { $r = $this->_rawRequest; $r->setFreeMethodRequest(true); $weight = $this->getTotalNumOfBoxes($r->getFreeMethodWeight()); - $freeWeight = round(max(1, $weight),0); + $freeWeight = round(max(1, $weight), 0); $r->setWeight($freeWeight); $r->setService($freeMethod); } -// protected function _getShipDate($includeSaturday=true) -// { -// $i = 0; -// $weekday = date('w'); -// /* -// * need to omit saturday and sunday -// * dhl will not work on sunday -// * 0 (for Sunday) through 6 (for Saturday) -// */ -// if (!$weekday || $weekday===0) $i += 1; -// elseif (!$includeSaturday && $weekday==6) $i += 2; -// return date('Y-m-d', strtotime("+$i day")); -// } - - protected function _getShipDate($domestic=true) + /** + * Get shipping date + * + * @param bool $domestic + * @return string + */ + protected function _getShipDate($domestic = true) { if ($domestic) { $days = explode(',', $this->getConfigData('shipment_days')); @@ -298,9 +442,9 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl return date('Y-m-d'); } - $i=0; + $i = 0; $weekday = date('w'); - while(!in_array($weekday, $days) && $i < 10) { + while (!in_array($weekday, $days) && $i < 10) { $i++; $weekday = date('w', strtotime("+$i day")); } @@ -308,8 +452,23 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl return date('Y-m-d', strtotime("+$i day")); } + /** + * Get xml quotes + * + * @return Mage_Core_Model_Abstract|Varien_Object + */ protected function _getXmlQuotes() { + return $this->_doRequest(); + } + + /** + * Do rate request and handle errors + * + * @return Mage_Shipping_Model_Rate_Result|Varien_Object + */ + protected function _doRequest() + { $r = $this->_rawRequest; $xml = new SimpleXMLElement(''); @@ -317,8 +476,8 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl $xml->addAttribute('version', '1.1'); $requestor = $xml->addChild('Requestor'); - $requestor->addChild('ID', $r->getId()); - $requestor->addChild('Password', $r->getPassword()); + $requestor->addChild('ID', $r->getId()); + $requestor->addChild('Password', $r->getPassword()); $methods = explode(',', $this->getConfigData('allowed_methods')); $internationcode = $this->getCode('international_searvice'); @@ -328,23 +487,28 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl if ($r->hasService() && $r->getFreeMethodRequest()) { if ($r->getDestCountryId() == self::USA_COUNTRY_ID) { - $shipment = $xml->addChild('Shipment'); - $shipKey=$r->getShippingKey(); - $r->setShipDate($shipDate); + $shipment = $xml->addChild('Shipment'); + $shipKey = $r->getShippingKey(); + $r->setShipDate($shipDate); } else { - $shipment = $xml->addChild('IntlShipment'); - $shipKey=$r->getShippingIntlKey(); - $r->setShipDate($this->_getShipDate(false)); - /* - * For internation shippingment customsvalue must be posted - */ - $shippingDuty = $shipment->addChild('Dutiable'); - $shippingDuty->addChild('DutiableFlag',($r->getDutiable()?'Y':'N')); - $shippingDuty->addChild('CustomsValue',$r->getValue()); + $shipment = $xml->addChild('IntlShipment'); + $shipKey = $r->getShippingIntlKey(); + $r->setShipDate($this->_getShipDate(false)); + /* + * For internation shippingment customsvalue must be posted + */ + $shippingDuty = $shipment->addChild('Dutiable'); + $shippingDuty->addChild('DutiableFlag', ($r->getDutiable() ? 'Y' : 'N')); + $shippingDuty->addChild('CustomsValue', $r->getValue()); + $shippingDuty->addChild('IsSEDReqd', 'N'); } $hasShipCode = true; - $this->_createShipmentXml($shipment,$shipKey); + $this->_createShipmentXml($shipment, $shipKey); } else { + if ($r->getAction() == 'GenerateLabel') { + $methods = array($r->getService()); + } + foreach ($methods as $method) { $shipment = false; if (in_array($method, array_keys($this->getCode('special_express')))) { @@ -354,25 +518,32 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl $r->setService($method); $r->setExtendedService(null); } - if ($r->getDestCountryId() == self::USA_COUNTRY_ID && $method!=$internationcode) { + if ($r->getDestCountryId() == self::USA_COUNTRY_ID && $method != $internationcode) { $shipment = $xml->addChild('Shipment'); - $shipKey=$r->getShippingKey(); + $shipKey = $r->getShippingKey(); $r->setShipDate($shipDate); - }elseif($r->getDestCountryId() != self::USA_COUNTRY_ID && $method==$internationcode){ + } elseif ($r->getDestCountryId() != self::USA_COUNTRY_ID && $method == $internationcode) { $shipment = $xml->addChild('IntlShipment'); - $shipKey=$r->getShippingIntlKey(); + $shipKey = $r->getShippingIntlKey(); + if ($r->getCustomsValue() != null && $r->getCustomsValue() != '') { + $customsValue = $r->getCustomsValue(); + } else { + $customsValue = $r->getValue(); + } + $r->setShipDate($this->_getShipDate(false)); /* * For internation shippingment customsvalue must be posted */ $shippingDuty = $shipment->addChild('Dutiable'); - $shippingDuty->addChild('DutiableFlag',($r->getDutiable()?'Y':'N')); - $shippingDuty->addChild('CustomsValue',$r->getValue()); + $shippingDuty->addChild('DutiableFlag', ($r->getDutiable() ? 'Y' : 'N')); + $shippingDuty->addChild('CustomsValue', $customsValue); + $shippingDuty->addChild('IsSEDReqd', 'N'); } - if ($shipment!==false) { + if ($shipment !== false) { $hasShipCode = true; - $this->_createShipmentXml($shipment,$shipKey); + $this->_createShipmentXml($shipment, $shipKey); } } } @@ -383,6 +554,7 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl } $request = $xml->asXML(); + $request = utf8_encode($request); $responseBody = $this->_getCachedQuotes($request); if ($responseBody === null) { $debugData = array('request' => $request); @@ -398,7 +570,7 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_POSTFIELDS, $request); $responseBody = curl_exec($ch); - curl_close ($ch); + curl_close($ch); $debugData['result'] = $responseBody; $this->_setCachedQuotes($request, $responseBody); @@ -413,7 +585,14 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl return $this->_parseXmlResponse($responseBody); } - protected function _createShipmentXml($shipment,$shipKey) + /** + * Create shipment xml + * + * @param $shipment + * @param $shipKey + * @return void + */ + protected function _createShipmentXml($shipment, $shipKey) { $r = $this->_rawRequest; @@ -424,14 +603,21 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl $_subtotal = $r->getValue(); $_subtotalWithDiscount = $r->getValueWithDiscount(); - $_width = max(0, (double) $this->getConfigData('default_width')); - $_height = max(0, (double) $this->getConfigData('default_height')); - $_length = max(0, (double) $this->getConfigData('default_length')); + $_width = max(0, (double)$this->getConfigData('default_width')); + $_height = max(0, (double)$this->getConfigData('default_height')); + $_length = max(0, (double)$this->getConfigData('default_length')); + + $packageParams = $r->getPackageParams(); + if ($packageParams) { + $_length = $packageParams->getLength(); + $_width = $packageParams->getWidth(); + $_height = $packageParams->getHeight(); + } $_apEnabled = $this->getConfigFlag('additional_protection_enabled'); $_apUseSubtotal = $this->getConfigData('additional_protection_use_subtotal'); - $_apConfigValue = max(0, (double) $this->getConfigData('additional_protection_value')); - $_apMinValue = max(0, (double) $this->getConfigData('additional_protection_min_value')); + $_apConfigValue = max(0, (double)$this->getConfigData('additional_protection_value')); + $_apMinValue = max(0, (double)$this->getConfigData('additional_protection_min_value')); $_apValueRounding = $this->getConfigData('additional_protection_rounding'); $apValue = 0; @@ -471,79 +657,122 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl } } - $shipment->addAttribute('action', 'RateEstimate'); - $shipment->addAttribute('version', '1.0'); + if ($r->getAction() == 'GenerateLabel') { + $shipment->addAttribute('action', 'GenerateLabel'); + } else { + $shipment->addAttribute('action', 'RateEstimate'); + } + $shipment->addAttribute('version', '1.0'); $shippingCredentials = $shipment->addChild('ShippingCredentials'); - $shippingCredentials->addChild('ShippingKey',$shipKey); - $shippingCredentials->addChild('AccountNbr', $r->getAccountNbr()); + $shippingCredentials->addChild('ShippingKey', $shipKey); + $shippingCredentials->addChild('AccountNbr', $r->getAccountNbr()); $shipmentDetail = $shipment->addChild('ShipmentDetail'); - $shipmentDetail->addChild('ShipDate', $r->getShipDate()); - $shipmentDetail->addChild('Service')->addChild('Code', $r->getService()); - $shipmentDetail->addChild('ShipmentType')->addChild('Code', $r->getShipmentType()); - $shipmentDetail->addChild('Weight', $r->getWeight()); - $shipmentDetail->addChild('ContentDesc', $r->getContentDesc()); - $additionalProtection = $shipmentDetail->addChild('AdditionalProtection'); - $additionalProtection->addChild('Code', $apCode); - $additionalProtection->addChild('Value', floor($apValue)); - - if ($_width && $_height && $_length) { - $dimensions = $shipmentDetail->addChild('Dimensions'); - $dimensions->addChild('Length', $_length); - $dimensions->addChild('Width', $_width); - $dimensions->addChild('Height', $_height); + if ($r->getAction() == 'GenerateLabel') { + if ($this->_request->getReferenceData()) { + $referenceData = $this->_request->getReferenceData() . $this->_request->getPackageId(); + } else { + $referenceData = 'Order #' + . $r->getOrderShipment()->getOrder()->getIncrementId() + . ' P' + . $r->getPackageId(); } - if ($_haz || ($r->getExtendedService())) { - $specialServices = $shipmentDetail->addChild('SpecialServices'); - } + $shipmentDetail->addChild('ShipperReference', $referenceData); + } + $shipmentDetail->addChild('ShipDate', $r->getShipDate()); + $shipmentDetail->addChild('Service')->addChild('Code', $r->getService()); + $shipmentDetail->addChild('ShipmentType')->addChild('Code', $r->getShipmentType()); + $shipmentDetail->addChild('Weight', $r->getWeight()); + $shipmentDetail->addChild('ContentDesc', $r->getContentDesc()); + $additionalProtection = $shipmentDetail->addChild('AdditionalProtection'); + $additionalProtection->addChild('Code', $apCode); + $additionalProtection->addChild('Value', floor($apValue)); + + if ($_width || $_height || $_length) { + $dimensions = $shipmentDetail->addChild('Dimensions'); + $dimensions->addChild('Length', $_length); + $dimensions->addChild('Width', $_width); + $dimensions->addChild('Height', $_height); + } - if ($_haz) { - $hazardousMaterials = $specialServices->addChild('SpecialService'); - $hazardousMaterials->addChild('Code', 'HAZ'); - } + if ($_haz || ($r->getExtendedService())) { + $specialServices = $shipmentDetail->addChild('SpecialServices'); + } - if ($r->getExtendedService()) { - $extendedService = $specialServices->addChild('SpecialService'); - $extendedService->addChild('Code', $r->getExtendedService()); - } + if ($_haz) { + $hazardousMaterials = $specialServices->addChild('SpecialService'); + $hazardousMaterials->addChild('Code', 'HAZ'); + } + if ($r->getExtendedService()) { + $extendedService = $specialServices->addChild('SpecialService'); + $extendedService->addChild('Code', $r->getExtendedService()); + } - /* - * R = Receiver (if receiver, need AccountNbr) - * S = Sender - * 3 = Third Party (if third party, need AccountNbr) - */ - $billing = $shipment->addChild('Billing'); - $billing->addChild('Party')->addChild('Code', 'S'); - $billing->addChild('DutyPaymentType',$r->getDutyPaymentType()); - /* - $cod = $billing->addChild('CODPayment'); - $cod->addChild('Code', 'P'); - $cod->addChild('Value', 100); - */ + /* + * R = Receiver (if receiver, need AccountNbr) + * S = Sender + * 3 = Third Party (if third party, need AccountNbr) + */ + $billing = $shipment->addChild('Billing'); + $billing->addChild('Party')->addChild('Code', $r->getIsGenerateLabelReturn() ? 'R' : 'S'); + $billing->addChild('DutyPaymentType', $r->getDutyPaymentType()); + if ($r->getIsGenerateLabelReturn()) { + $billing->addChild('AccountNbr', $r->getAccountNbr()); + } + $sender = $shipment->addChild('Sender'); + $sender->addChild('SentBy', ($r->getOrigPersonName())); + $sender->addChild('PhoneNbr', $r->getOrigPhoneNumber()); + $sender->addChild('Email', $r->getOrigEmail()); - $receiverAddress = $shipment->addChild('Receiver')->addChild('Address'); - $receiverAddress->addChild('Street', htmlspecialchars($r->getDestStreet()?$r->getDestStreet():'NA')); - $receiverAddress->addChild('City', htmlspecialchars($r->getDestCity())); - $receiverAddress->addChild('State', htmlspecialchars($r->getDestState())); - /* - * DHL xml service is using UK for united kingdom instead of GB which is a standard ISO country code - */ - $receiverAddress->addChild('Country', ($r->getDestCountryId()=='GB'?'UK':$r->getDestCountryId())); - $receiverAddress->addChild('PostalCode', $r->getDestPostal()); + $senderAddress = $sender->addChild('Address'); + $senderAddress->addChild('Street', htmlspecialchars($r->getOrigStreet() ? $r->getOrigStreet() : 'N/A')); + $senderAddress->addChild('City', htmlspecialchars($r->getOrigCity())); + $senderAddress->addChild('State', htmlspecialchars($r->getOrigState())); + $senderAddress->addChild('CompanyName', htmlspecialchars($r->getOrigCompanyName())); /* - $special_service=$this->getCode('special_service'); - if(array_key_exists($r->getService(),$special_service)){ - $specialService = $shipment->addChild('SpecialServices')->addChild('SpecialService'); - $specialService->addChild('Code',$special_service[$r->getService()]); - } + * DHL xml service is using UK for united kingdom instead of GB which is a standard ISO country code + */ + $senderAddress->addChild('Country', ($r->getOrigCountryId() == 'GB' ? 'UK' : $r->getOrigCountryId())); + $senderAddress->addChild('PostalCode', $r->getOrigPostal()); + + $receiver = $shipment->addChild('Receiver'); + $receiver->addChild('AttnTo', $r->getDestPersonName()); + $receiver->addChild('PhoneNbr', $r->getDestPhoneNumber()); + + $receiverAddress = $receiver->addChild('Address'); + $receiverAddress->addChild('Street', htmlspecialchars($r->getDestStreet() ? $r->getDestStreet() : 'N/A')); + $receiverAddress->addChild('StreetLine2', + htmlspecialchars($r->getDestStreetLine2() ? $r->getDestStreetLine2() : 'N/A') + ); + $receiverAddress->addChild('City', htmlspecialchars($r->getDestCity())); + $receiverAddress->addChild('State', htmlspecialchars($r->getDestState())); + $receiverAddress->addChild('CompanyName', + htmlspecialchars($r->getDestCompanyName() ? $r->getDestCompanyName() : 'N/A') + ); + + /* + * DHL xml service is using UK for united kingdom instead of GB which is a standard ISO country code */ + $receiverAddress->addChild('Country', ($r->getDestCountryId() == 'GB' ? 'UK' : $r->getDestCountryId())); + $receiverAddress->addChild('PostalCode', $r->getDestPostal()); + + if ($r->getAction() == 'GenerateLabel') { + $label = $shipment->addChild('ShipmentProcessingInstructions')->addChild('Label'); + $label->addChild('ImageType', 'PNG'); + } } + /** + * Parse xml response and return result + * + * @param string $response + * @return Mage_Shipping_Model_Rate_Result|Varien_Object + */ protected function _parseXmlResponse($response) { $r = $this->_rawRequest; @@ -555,8 +784,8 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl unset($tr['<'], $tr['>'], $tr['"']); $response = str_replace(array_keys($tr), array_values($tr), $response); - if (strlen(trim($response))>0) { - if (strpos(trim($response), ' 0) { + if (strpos(trim($response), 'Faults->Fault->Code) && is_object($xml->Faults->Fault->Description) && is_object($xml->Faults->Fault->Context) - ) { + ) { $code = (string)$xml->Faults->Fault->Code; $description = $xml->Faults->Fault->Description; $context = $xml->Faults->Fault->Context; @@ -573,17 +802,20 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl } else { if ($r->getDestCountryId() == self::USA_COUNTRY_ID) { if ($xml->Shipment) { - foreach($xml->Shipment as $shipXml){ - $this->_parseXmlObject($shipXml); + foreach ($xml->Shipment as $shipXml) { + $this->_parseXmlObject($shipXml); } } else { - $this->_errors[] = Mage::helper('usa')->__('Shipment is not available.'); + $this->_errors[] = Mage::helper('usa')->__('Shipment is not available.'); } } else { $shipXml = $xml->IntlShipment; $this->_parseXmlObject($shipXml); } - $shipXml=(($r->getDestCountryId() == self::USA_COUNTRY_ID)?$xml->Shipment:$xml->IntlShipment); + $shipXml = (($r->getDestCountryId() == self::USA_COUNTRY_ID) + ? $xml->Shipment + : $xml->IntlShipment + ); } } } else { @@ -591,214 +823,96 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl } } - $result = Mage::getModel('shipping/rate_result'); - - foreach ($this->_errors as $errorText) { - $error = Mage::getModel('shipping/rate_result_error'); - $error->setCarrier('dhl'); - $error->setCarrierTitle($this->getConfigData('title')); - //$error->setErrorMessage($errorText); - $error->setErrorMessage($this->getConfigData('specificerrmsg')); - $result->append($error); - } - - foreach($this->_dhlRates as $rate) { - $method = $rate['service']; - $data = $rate['data']; - $rate = Mage::getModel('shipping/rate_result_method'); - $rate->setCarrier('dhl'); - $rate->setCarrierTitle($this->getConfigData('title')); - $rate->setMethod($method); - $rate->setMethodTitle($data['term']); - $rate->setCost($data['price_total']); - $rate->setPrice($data['price_total']); - $result->append($rate); + if ($this->_rawRequest->getAction() == 'GenerateLabel') { + $result = new Varien_Object(); + if (!empty($this->_errors)) { + $result->setErrors(implode($this->_errors, '; ')); + } else { + if ($xml !== false) { + if ($r->getDestCountryId() == self::USA_COUNTRY_ID) { + $shippingLabelContent = base64_decode((string)$xml->Shipment->Label->Image); + $trackingNumber = (string)$xml->Shipment->ShipmentDetail->AirbillNbr; + } else { + $shippingLabelContent = base64_decode((string)$xml->IntlShipment->Label->Image); + $trackingNumber = (string)$xml->IntlShipment->ShipmentDetail->AirbillNbr; + } + } + $result->setShippingLabelContent($shippingLabelContent); + $result->setTrackingNumber($trackingNumber); + } + return $result; + } else { + $result = Mage::getModel('shipping/rate_result'); + if ($this->_dhlRates) { + foreach ($this->_dhlRates as $rate) { + $method = $rate['service']; + $data = $rate['data']; + $rate = Mage::getModel('shipping/rate_result_method'); + $rate->setCarrier('dhl'); + $rate->setCarrierTitle($this->getConfigData('title')); + $rate->setMethod($method); + $rate->setMethodTitle($data['term']); + $rate->setCost($data['price_total']); + $rate->setPrice($data['price_total']); + $result->append($rate); + } + } else if (!empty($this->_errors)) { + $error = Mage::getModel('shipping/rate_result_error'); + $error->setCarrier('dhl'); + $error->setCarrierTitle($this->getConfigData('title')); + $error->setErrorMessage($this->getConfigData('specificerrmsg')); + $result->append($error); + } + return $result; } - return $result; - } + /** + * Parse xml object + * + * @param mixed $shipXml + * @return Mage_Usa_Model_Shipping_Carrier_Dhl + */ protected function _parseXmlObject($shipXml) { - if( + if ( is_object($shipXml->Faults) && is_object($shipXml->Faults->Fault) && is_object($shipXml->Faults->Fault->Desc) && intval($shipXml->Faults->Fault->Code) != self::SUCCESS_CODE - ) { - $code = (string)$shipXml->Faults->Fault->Code; - $description = $shipXml->Faults->Fault->Desc; - $this->_errors[$code] = Mage::helper('usa')->__('Error #%s: %s', $code, $description); - } elseif( + && intval($shipXml->Faults->Fault->Code) != self::SUCCESS_LABEL_CODE + ) { + $code = (string)$shipXml->Faults->Fault->Code; + $description = $shipXml->Faults->Fault->Desc; + $this->_errors[$code] = Mage::helper('usa')->__('Error #%s: %s', $code, $description); + } elseif ( is_object($shipXml->Faults) && is_object($shipXml->Result->Code) && is_object($shipXml->Result->Desc) && intval($shipXml->Result->Code) != self::SUCCESS_CODE - ) { - $code = (string)$shipXml->Result->Code; - $description = $shipXml->Result->Desc; - $this->_errors[$code] = Mage::helper('usa')->__('Error #%s: %s', $code, $description); - }else { + && intval($shipXml->Result->Code) != self::SUCCESS_LABEL_CODE + ) { + $code = (string)$shipXml->Result->Code; + $description = $shipXml->Result->Desc; + $this->_errors[$code] = Mage::helper('usa')->__('Error #%s: %s', $code, $description); + } else { $this->_addRate($shipXml); } return $this; } -// protected function _getXmlQuotes() -// { -// $r = $this->_rawRequest; -// -// $xml = new SimpleXMLElement(''); -// $xml->addAttribute('action', 'Request'); -// $xml->addAttribute('version', '1.1'); -// -// $requestor = $xml->addChild('Requestor'); -// $requestor->addChild('ID', $r->getId()); -// $requestor->addChild('Password', $r->getPassword()); -// -// -// if ($r->getDestCountryId() == self::USA_COUNTRY_ID) { -// $shipment = $xml->addChild('Shipment'); -// $shipKey=$r->getShippingKey(); -// }else{ -// $shipment = $xml->addChild('IntlShipment'); -// $shipKey=$r->getShippingIntlKey(); -// -// /* -// * For internation shippingment customsvalue must be posted -// */ -// $shippingDuty = $shipment->addChild('Dutiable'); -// $shippingDuty->addChild('DutiableFlag',($r->getDutiable()?'Y':'N')); -// $shippingDuty->addChild('CustomsValue',$r->getValue()); -// } -// -// $shipment->addAttribute('action', 'RateEstimate'); -// $shipment->addAttribute('version', '1.0'); -// -// $shippingCredentials = $shipment->addChild('ShippingCredentials'); -// $shippingCredentials->addChild('ShippingKey',$shipKey); -// $shippingCredentials->addChild('AccountNbr', $r->getAccountNbr()); -// -// $shipmentDetail = $shipment->addChild('ShipmentDetail'); -// $shipmentDetail->addChild('ShipDate', $this->_getShipDate()); -// $shipmentDetail->addChild('Service')->addChild('Code', $r->getService()); -// $shipmentDetail->addChild('ShipmentType')->addChild('Code', $r->getShipmentType()); -// $shipmentDetail->addChild('Weight', $r->getWeight()); -// $shipmentDetail->addChild('ContentDesc', $r->getContentDesc()); -// -// $billing = $shipment->addChild('Billing'); -// $billing->addChild('Party')->addChild('Code', 'S'); -// $billing->addChild('DutyPaymentType',$r->getDutyPaymentType()); -// -// $receiverAddress = $shipment->addChild('Receiver')->addChild('Address'); -// $receiverAddress->addChild('Street', htmlspecialchars($r->getDestStreet()?$r->getDestStreet():'NA')); -// $receiverAddress->addChild('City', htmlspecialchars($r->getDestCity())); -// $receiverAddress->addChild('State', htmlspecialchars($r->getDestState())); -// /* -// * DHL xml service is using UK for united kingdom instead of GB which is a standard ISO country code -// */ -// $receiverAddress->addChild('Country', ($r->getDestCountryId()=='GB'?'UK':$r->getDestCountryId())); -// $receiverAddress->addChild('PostalCode', $r->getDestPostal()); -// /* -// $special_service=$this->getCode('special_service'); -// if(array_key_exists($r->getService(),$special_service)){ -// $specialService = $shipment->addChild('SpecialServices')->addChild('SpecialService'); -// $specialService->addChild('Code',$special_service[$r->getService()]); -// } -// */ -// -// -// $request = $xml->asXML(); -// -// try { -// $url = $this->getConfigData('gateway_url'); -// if (!$url) { -// $url = $this->_defaultGatewayUrl; -// } -// $ch = curl_init(); -// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); -// curl_setopt($ch, CURLOPT_URL, $url); -// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); -// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); -// curl_setopt($ch, CURLOPT_POSTFIELDS, $request); -// $responseBody = curl_exec($ch); -// curl_close ($ch); -// } catch (Exception $e) { -// $responseBody = ''; -// } -// -// $this->_parseXmlResponse($responseBody); -// } - -// protected function _parseXmlResponse($response) -// { -// $r = $this->_rawRequest; -// $costArr = array(); -// $priceArr = array(); -// $errorTitle = 'Unable to retrieve quotes'; -// -// $tr = get_html_translation_table(HTML_ENTITIES); -// unset($tr['<'], $tr['>'], $tr['"']); -// $response = str_replace(array_keys($tr), array_values($tr), $response); -// -// -// if (strlen(trim($response))>0) { -// if (strpos(trim($response), 'DEBUG:\n"; -// print_r($xml); -// echo "";*/ -// -// -// if (is_object($xml)) { -// $shipXml=(($r->getDestCountryId() == self::USA_COUNTRY_ID)?$xml->Shipment:$xml->IntlShipment); -// if ( -// is_object($xml->Faults) -// && is_object($xml->Faults->Fault) -// && is_object($xml->Faults->Fault->Code) -// && is_object($xml->Faults->Fault->Description) -// && is_object($xml->Faults->Fault->Context) -// ) { -// $code = (string)$xml->Faults->Fault->Code; -// $description = $xml->Faults->Fault->Description; -// $context = $xml->Faults->Fault->Context; -// $this->_errors[$code] = Mage::helper('usa')->__('Error #%s : %s (%s)', $code, $description, $context); -// } elseif( -// is_object($shipXml->Faults) -// && is_object($shipXml->Faults->Fault) -// && is_object($shipXml->Faults->Fault->Desc) -// && intval($shipXml->Faults->Fault->Code) != self::SUCCESS_CODE -// ) { -// $code = (string)$shipXml->Faults->Fault->Code; -// $description = $shipXml->Faults->Fault->Desc; -// $this->_errors[$code] = Mage::helper('usa')->__('Error #%s: %s', $code, $description); -// } elseif( -// is_object($shipXml->Faults) -// && is_object($shipXml->Result->Code) -// && is_object($shipXml->Result->Desc) -// && intval($shipXml->Result->Code) != self::SUCCESS_CODE -// ) { -// $code = (string)$shipXml->Result->Code; -// $description = $shipXml->Result->Desc; -// $this->_errors[$code] = Mage::helper('usa')->__('Error #%s: %s', $code, $description); -// }else { -// $this->_addRate($xml); -// return $this; -// } -// } -// } else { -// $this->_errors[] = Mage::helper('usa')->__('Response is in the wrong format'); -// } -// } -// } - - public function getCode($type, $code='') + /** + * Get configuration data of carrier + * + * @param string $type + * @param string $code + * @return array|bool + */ + public function getCode($type, $code = '') { static $codes; $codes = array( - 'service'=>array( + 'service' => array( 'IE' => Mage::helper('usa')->__('International Express'), 'E SAT' => Mage::helper('usa')->__('Express Saturday'), 'E 10:30AM' => Mage::helper('usa')->__('Express 10:30 AM'), @@ -807,111 +921,103 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl 'S' => Mage::helper('usa')->__('Second Day Service'), 'G' => Mage::helper('usa')->__('Ground'), ), - 'shipment_type'=>array( + 'shipment_type' => array( 'L' => Mage::helper('usa')->__('Letter'), 'P' => Mage::helper('usa')->__('Package'), ), - 'international_searvice'=>'IE', - /* - 'special_service'=>array( - 'E SAT'=>'SAT', - 'E 10:30AM'=>'1030', - ), - */ - 'dutypayment_type'=>array( + 'international_searvice' => 'IE', + 'dutypayment_type' => array( 'S' => Mage::helper('usa')->__('Sender'), 'R' => Mage::helper('usa')->__('Receiver'), '3' => Mage::helper('usa')->__('Third Party'), - ), + ), - 'special_express'=>array( - 'E SAT'=>'SAT', - 'E 10:30AM'=>'1030', - ), + 'special_express' => array( + 'E SAT' => 'SAT', + 'E 10:30AM' => '1030', + ), - 'descr_to_service'=>array( - 'E SAT'=>'Saturday', - 'E 10:30AM'=>'10:30 A.M', - ), + 'descr_to_service' => array( + 'E SAT' => 'Saturday', + 'E 10:30AM' => '10:30 A.M', + ), ); - if (!isset($codes[$type])) { -// throw Mage::exception('Mage_Shipping', Mage::helper('usa')->__('Invalid DHL XML code type: %s.', $type)); return false; - } elseif (''===$code) { + } elseif ('' === $code) { return $codes[$type]; } if (!isset($codes[$type][$code])) { -// throw Mage::exception('Mage_Shipping', Mage::helper('usa')->__('Invalid DHL XML code for type %s: %s.', $type, $code)); return false; } else { return $codes[$type][$code]; } } -// protected function _addRate($xml) -// { -// $r = $this->_rawRequest; -// $services=$this->getCode('service'); -// $shipXml=(($r->getDestCountryId() == self::USA_COUNTRY_ID)?$xml->Shipment:$xml->IntlShipment); -// $desc=(string)$shipXml->EstimateDetail->ServiceLevelCommitment->Desc; -// $totalEstimate=(string)$shipXml->EstimateDetail->RateEstimate->TotalChargeEstimate; -// /* -// * DHL can return with empty result and success code -// * we need to make sure there is shipping estimate and code -// */ -// if($desc && $totalEstimate){ -// $service = (string)$shipXml->EstimateDetail->Service->Code; -// $data['term'] = (isset($services[$service])?$services[$service]:$desc); -// $data['price_total'] = $totalEstimate; -// $this->_dhlRates[$service] = $data; -// } -// } - + /** + * Parse xml and add rates to instance property + * + * @param mixed $shipXml + * @return void + */ protected function _addRate($shipXml) { $r = $this->_rawRequest; $services = $this->getCode('service'); $regexps = $this->getCode('descr_to_service'); - $desc=(string)$shipXml->EstimateDetail->ServiceLevelCommitment->Desc; - $totalEstimate=(string)$shipXml->EstimateDetail->RateEstimate->TotalChargeEstimate; + $desc = ($shipXml->EstimateDetail) ? (string)$shipXml->EstimateDetail->ServiceLevelCommitment->Desc : null; + + $totalEstimate = $shipXml->EstimateDetail + ? (string)$shipXml->EstimateDetail->RateEstimate->TotalChargeEstimate + : null; /* * DHL can return with empty result and success code * we need to make sure there is shipping estimate and code */ - if($desc && $totalEstimate){ + if ($desc && $totalEstimate) { $service = (string)$shipXml->EstimateDetail->Service->Code; $description = (string)$shipXml->EstimateDetail->ServiceLevelCommitment->Desc; if ($service == 'E') { - foreach ($regexps as $expService=>$exp) { - if (preg_match('/'.preg_quote($exp, '/').'/', $description)) { + foreach ($regexps as $expService => $exp) { + if (preg_match('/' . preg_quote($exp, '/') . '/', $description)) { $service = $expService; } } } - $data['term'] = (isset($services[$service])?$services[$service]:$desc); + $data['term'] = (isset($services[$service]) ? $services[$service] : $desc); $data['price_total'] = $this->getMethodPrice($totalEstimate, $service); - $this->_dhlRates[] = array('service'=>$service, 'data'=>$data); + $this->_dhlRates[] = array('service' => $service, 'data' => $data); } } + /** + * Get tracking + * + * @param mixed $trackings + * @return mixed + */ public function getTracking($trackings) { $this->setTrackingReqeust(); if (!is_array($trackings)) { - $trackings=array($trackings); + $trackings = array($trackings); } - $this->_getXMLTracking($trackings); + $this->_getXMLTracking($trackings); - return $this->_result; + return $this->_result; } + /** + * Set tracking request + * + * @return null + */ protected function setTrackingReqeust() { $r = new Varien_Object(); @@ -925,6 +1031,12 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl $this->_rawTrackRequest = $r; } + /** + * Send request for tracking + * + * @param array $tracking + * @return null + */ protected function _getXMLTracking($trackings) { $r = $this->_rawTrackRequest; @@ -934,34 +1046,23 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl $xml->addAttribute('version', '1.1'); $requestor = $xml->addChild('Requestor'); - $requestor->addChild('ID', $r->getId()); - $requestor->addChild('Password', $r->getPassword()); - - $track=$xml->addChild('Track'); - $track->addAttribute('action', 'Get'); - $track->addAttribute('version', '1.0'); - - //shippment has not been delivered or no scans - //$track->addChild('Shipment')->addChild('TrackingNbr','1231230011'); - //home shipment - //$track->addChild('Shipment')->addChild('TrackingNbr','2342340011'); - //international shipment - //$track->addChild('Shipment')->addChild('TrackingNbr','5675670011'); - //tracking not in airborme tracking tsystem - //$track->addChild('Shipment')->addChild('TrackingNbr','7897890011'); - //tracking need to contanct customer service for more information - //$track->addChild('Shipment')->addChild('TrackingNbr','8198190011'); - - foreach($trackings as $tracking){ - $track->addChild('Shipment')->addChild('TrackingNbr',$tracking); - } - $request = $xml->asXML(); - $debugData = array('request' => $request); - /* + $requestor->addChild('ID', $r->getId()); + $requestor->addChild('Password', $r->getPassword()); + + $track = $xml->addChild('Track'); + $track->addAttribute('action', 'Get'); + $track->addAttribute('version', '1.0'); + + foreach ($trackings as $tracking) { + $track->addChild('Shipment')->addChild('TrackingNbr', $tracking); + } + $request = $xml->asXML(); + $debugData = array('request' => $request); + /* * tracking api cannot process from 3pm to 5pm PST time on Sunday * DHL Airborne conduts a maintainance during that period. */ - try { + try { $url = $this->getConfigData('gateway_url'); if (!$url) { $url = $this->_defaultGatewayUrl; @@ -974,140 +1075,149 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl curl_setopt($ch, CURLOPT_POSTFIELDS, $request); $responseBody = curl_exec($ch); $debugData['result'] = $responseBody; - curl_close ($ch); - } - catch (Exception $e) { + curl_close($ch); + } catch (Exception $e) { $debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode()); $responseBody = ''; } $this->_debug($debugData); -#echo "".$responseBody.""; $this->_parseXmlTrackingResponse($trackings, $responseBody); } + /** + * Parse xml tracking response + * + * @param array $trackingvalue + * @param string $response + * @return null + */ protected function _parseXmlTrackingResponse($trackings, $response) { - $errorTitle = 'Unable to retrieve tracking'; - $resultArr=array(); - $errorArr=array(); - $trackingserror=array(); - $tracknum=''; - if (strlen(trim($response))>0) { - if (strpos(trim($response), 'Track; - if ( + $errorTitle = Mage::helper('usa')->__('Unable to retrieve tracking'); + $resultArr = array(); + $errorArr = array(); + $trackingserror = array(); + $tracknum = ''; + if (strlen(trim($response)) > 0) { + if (strpos(trim($response), 'Track; + if ( is_object($xml->Faults) && is_object($xml->Faults->Fault) && is_object($xml->Faults->Fault->Code) && is_object($xml->Faults->Fault->Description) && is_object($xml->Faults->Fault->Context) - ) { + ) { $code = (string)$xml->Faults->Fault->Code; $description = $xml->Faults->Fault->Description; $context = $xml->Faults->Fault->Context; $errorTitle = Mage::helper('usa')->__('Error #%s : %s (%s)', $code, $description, $context); - }elseif(is_object($trackxml) && is_object($trackxml->Shipment)){ - foreach($trackxml->Shipment as $txml){ - $rArr=array(); - - if(is_object($txml)){ - $tracknum=(string)$txml->TrackingNbr; - if($txml->Fault){ - $code = (string)$txml->Fault->Code; - $description = $txml->Fault->Description; - $errorArr[$tracknum] = Mage::helper('usa')->__('Error #%s: %s', $code, $description); - }elseif($txml->Result){ + } elseif (is_object($trackxml) && is_object($trackxml->Shipment)) { + foreach ($trackxml->Shipment as $txml) { + $rArr = array(); + + if (is_object($txml)) { + $tracknum = (string)$txml->TrackingNbr; + if ($txml->Fault) { + $code = (string)$txml->Fault->Code; + $description = $txml->Fault->Description; + $errorArr[$tracknum] = Mage::helper('usa')->__('Error #%s: %s', $code, $description); + } elseif ($txml->Result) { $code = (int)$txml->Result->Code; - if($code===0){ - /* + if ($code === 0) { + /* * Code 0== airbill found */ - $rArr['service']=(string)$txml->Service->Desc; - if(isset($txml->Weight)) - $rArr['weight']=(string)$txml->Weight." lbs"; + $rArr['service'] = (string)$txml->Service->Desc; + if (isset($txml->Weight)) + $rArr['weight'] = (string)$txml->Weight . " lbs"; if (isset($txml->Delivery)) { $rArr['deliverydate'] = (string)$txml->Delivery->Date; - $rArr['deliverytime'] = (string)$txml->Delivery->Time.':00'; + $rArr['deliverytime'] = (string)$txml->Delivery->Time . ':00'; $rArr['status'] = Mage::helper('usa')->__('Delivered'); if (isset($txml->Delivery->Location->Desc)) { $rArr['deliverylocation'] = (string)$txml->Delivery->Location->Desc; } } elseif (isset($txml->Pickup)) { $rArr['deliverydate'] = (string)$txml->Pickup->Date; - $rArr['deliverytime'] = (string)$txml->Pickup->Time.':00'; + $rArr['deliverytime'] = (string)$txml->Pickup->Time . ':00'; $rArr['status'] = Mage::helper('usa')->__('Shipment picked up'); } else { - $rArr['status']=(string)$txml->ShipmentType->Desc.Mage::helper('usa')->__(' was not delivered nor scanned'); + $rArr['status'] = (string)$txml->ShipmentType->Desc + . Mage::helper('usa')->__(' was not delivered nor scanned'); } $packageProgress = array(); if (isset($txml->TrackingHistory) && isset($txml->TrackingHistory->Status)) { foreach ($txml->TrackingHistory->Status as $thistory) { - $tempArr=array(); - $tempArr['activity'] = (string)$thistory->StatusDesc; - $tempArr['deliverydate'] = (string)$thistory->Date;//YYYY-MM-DD - $tempArr['deliverytime'] = (string)$thistory->Time.':00';//HH:MM:ss - $addArr=array(); - if (isset($thistory->Location->City)) { + $tempArr = array(); + $tempArr['activity'] = (string)$thistory->StatusDesc; + $tempArr['deliverydate'] = (string)$thistory->Date; //YYYY-MM-DD + $tempArr['deliverytime'] = (string)$thistory->Time . ':00'; //HH:MM:ss + $addArr = array(); + if (isset($thistory->Location->City)) { $addArr[] = (string)$thistory->Location->City; - } - if (isset($thistory->Location->State)) { + } + if (isset($thistory->Location->State)) { $addArr[] = (string)$thistory->Location->State; - } - if (isset($thistory->Location->CountryCode)) { + } + if (isset($thistory->Location->CountryCode)) { $addArr[] = (string)$thistory->Location->Country; - } - if ($addArr) { - $tempArr['deliverylocation']=implode(', ',$addArr); - }elseif(isset($thistory['final_delivery']) && (string)$thistory['final_delivery']==='true'){ - /* - if the history is final delivery, there is no informationabout city, state and country - */ - $addArr=array(); - if (isset($txml->Receiver->City)) { + } + if ($addArr) { + $tempArr['deliverylocation'] = implode(', ', $addArr); + } elseif (isset($thistory['final_delivery']) + && (string)$thistory['final_delivery'] === 'true' + ) { + /* + * if the history is final delivery, there is no informationabout + * city, state and country + */ + $addArr = array(); + if (isset($txml->Receiver->City)) { $addArr[] = (string)$txml->Receiver->City; - } - if (isset($thistory->Receiver->State)) { + } + if (isset($thistory->Receiver->State)) { $addArr[] = (string)$txml->Receiver->State; - } - if (isset($thistory->Receiver->CountryCode)) { + } + if (isset($thistory->Receiver->CountryCode)) { $addArr[] = (string)$txml->Receiver->Country; - } - $tempArr['deliverylocation']=implode(', ',$addArr); - } - $packageProgress[] = $tempArr; + } + $tempArr['deliverylocation'] = implode(', ', $addArr); + } + $packageProgress[] = $tempArr; } $rArr['progressdetail'] = $packageProgress; } - $resultArr[$tracknum]=$rArr; - }else{ - $description =(string)$txml->Result->Desc; - if($description) - $errorArr[$tracknum]=Mage::helper('usa')->__('Error #%s: %s', $code, $description); + $resultArr[$tracknum] = $rArr; + } else { + $description = (string)$txml->Result->Desc; + if ($description) + $errorArr[$tracknum] = Mage::helper('usa')->__('Error #%s: %s', $code, $description); else - $errorArr[$tracknum]=Mage::helper('usa')->__('Unable to retrieve tracking'); + $errorArr[$tracknum] = Mage::helper('usa')->__('Unable to retrieve tracking'); } - }else{ - $errorArr[$tracknum]=Mage::helper('usa')->__('Unable to retrieve tracking'); + } else { + $errorArr[$tracknum] = Mage::helper('usa')->__('Unable to retrieve tracking'); } } } } - } + } } else { $errorTitle = Mage::helper('usa')->__('Response is in the wrong format'); } - } + } - $result = Mage::getModel('shipping/tracking_result'); - if($errorArr || $resultArr){ - foreach ($errorArr as $t=>$r) { + $result = Mage::getModel('shipping/tracking_result'); + if ($errorArr || $resultArr) { + foreach ($errorArr as $t => $r) { $error = Mage::getModel('shipping/tracking_result_error'); $error->setCarrier('dhl'); $error->setCarrierTitle($this->getConfigData('title')); @@ -1116,22 +1226,17 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl $result->append($error); } - foreach($resultArr as $t => $data) { + foreach ($resultArr as $t => $data) { $tracking = Mage::getModel('shipping/tracking_result_status'); $tracking->setCarrier('dhl'); $tracking->setCarrierTitle($this->getConfigData('title')); $tracking->setTracking($t); $tracking->addData($data); - /* - $tracking->setStatus($data['status']); - $tracking->setService($data['service']); - if(isset($data['deliverydate'])) $tracking->setDeliveryDate($data['deliverydate']); - if(isset($data['deliverytime'])) $tracking->setDeliveryTime($data['deliverytime']); - */ + $result->append($tracking); } - }else{ - foreach($trackings as $t){ + } else { + foreach ($trackings as $t) { $error = Mage::getModel('shipping/tracking_result_error'); $error->setCarrier('dhl'); $error->setCarrierTitle($this->getConfigData('title')); @@ -1139,24 +1244,27 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl $error->setErrorMessage($errorTitle); $result->append($error); - } - } + } + } $this->_result = $result; -//echo "
";print_r($result);
-
     }
 
+    /**
+     * Get tracking response
+     *
+     * @return string
+     */
     public function getResponse()
     {
         $statuses = '';
-        if ($this->_result instanceof Mage_Shipping_Model_Tracking_Result){
+        if ($this->_result instanceof Mage_Shipping_Model_Tracking_Result) {
             if ($trackings = $this->_result->getAllTrackings()) {
-                foreach ($trackings as $tracking){
-                    if($data = $tracking->getAllData()){
+                foreach ($trackings as $tracking) {
+                    if ($data = $tracking->getAllData()) {
                         if (isset($data['status'])) {
-                            $statuses .= Mage::helper('usa')->__($data['status'])."\n
"; + $statuses .= Mage::helper('usa')->__($data['status']) . "\n
"; } else { - $statuses .= Mage::helper('usa')->__($data['error_message'])."\n
"; + $statuses .= Mage::helper('usa')->__($data['error_message']) . "\n
"; } } } @@ -1183,26 +1291,107 @@ class Mage_Usa_Model_Shipping_Carrier_Dhl return $arr; } + /** + * Is state province required + * + * @return bool + */ public function isStateProvinceRequired() { return true; } + /** + * Get additional protection value types + * + * @return array + */ public function getAdditionalProtectionValueTypes() { return array( - self::ADDITIONAL_PROTECTION_VALUE_CONFIG=>Mage::helper('usa')->__('Configuration'), - self::ADDITIONAL_PROTECTION_VALUE_SUBTOTAL=>Mage::helper('usa')->__('Subtotal'), - self::ADDITIONAL_PROTECTION_VALUE_SUBTOTAL_WITH_DISCOUNT=>Mage::helper('usa')->__('Subtotal With Discount'), - ); + self::ADDITIONAL_PROTECTION_VALUE_CONFIG => Mage::helper('usa')->__('Configuration'), + self::ADDITIONAL_PROTECTION_VALUE_SUBTOTAL => Mage::helper('usa')->__('Subtotal'), + self::ADDITIONAL_PROTECTION_VALUE_SUBTOTAL_WITH_DISCOUNT => Mage::helper('usa')->__('Subtotal With Discount'), + ); } + /** + * Get additional protection rounding types + * + * @return array + */ public function getAdditionalProtectionRoundingTypes() { return array( self::ADDITIONAL_PROTECTION_ROUNDING_FLOOR => Mage::helper('usa')->__('To Lower'), - self::ADDITIONAL_PROTECTION_ROUNDING_CEIL => Mage::helper('usa')->__('To Upper'), + self::ADDITIONAL_PROTECTION_ROUNDING_CEIL => Mage::helper('usa')->__('To Upper'), self::ADDITIONAL_PROTECTION_ROUNDING_ROUND => Mage::helper('usa')->__('Round'), - ); + ); + } + + /** + * Map request to shipment + * + * @param Varien_Object $request + * @return null + */ + protected function _mapRequestToShipment(Varien_Object $request) + { + $customsValue = $request->getPackageParams()->getCustomsValue(); + $request->setOrigPersonName($request->getShipperContactPersonName()); + $request->setOrigPostal($request->getShipperAddressPostalCode()); + $request->setOrigPhoneNumber($request->getShipperContactPhoneNumber()); + $request->setOrigCompanyName($request->getShipperContactCompanyName()); + $request->setOrigCountryId($request->getShipperAddressCountryCode()); + $request->setOrigState($request->getShipperAddressStateOrProvinceCode()); + $request->setOrigCity($request->getShipperAddressCity()); + $request->setOrigStreet($request->getShipperAddressStreet1() . ' ' . $request->getShipperAddressStreet2()); + $request->setOrigStreetLine2($request->getShipperAddressStreet2()); + + $request->setDestPersonName($request->getRecipientContactPersonName()); + $request->setDestPostcode($request->getRecipientAddressPostalCode()); + $request->setDestPhoneNumber($request->getRecipientContactPhoneNumber()); + $request->setDestCompanyName($request->getRecipientContactCompanyName()); + $request->setDestCountryId($request->getRecipientAddressCountryCode()); + $request->setDestRegionCode($request->getRecipientAddressStateOrProvinceCode()); + $request->setDestCity($request->getRecipientAddressCity()); + $request->setDestStreet($request->getRecipientAddressStreet1()); + $request->setDestStreetLine2($request->getRecipientAddressStreet2()); + + $request->setLimitMethod($request->getShippingMethod()); + $request->setPackageValue($customsValue); + $request->setValueWithDiscount($customsValue); + $request->setPackageCustomsValue($customsValue); + $request->setFreeMethodWeight(0); + $request->setDhlShipmentType($request->getPackagingType()); + + $request->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax()); + } + + /** + * Do shipment request to carrier web service, obtain Print Shipping Labels and process errors in response + * + * @param Varien_Object $request + * @return Varien_Object + */ + protected function _doShipmentRequest(Varien_Object $request) + { + $this->_prepareShipmentRequest($request); + $request->setAction('GenerateLabel'); + $this->_mapRequestToShipment($request); + $this->setRequest($request); + + return $this->_doRequest(); + } + + /** + * Return container types of carrier + * + * @param Varien_Object|null $params + * @return array|bool + */ + public function getContainerTypes(Varien_Object $params = null) + { + return $this->getCode('shipment_type'); } } diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php new file mode 100644 index 0000000..26e7771 --- /dev/null +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php @@ -0,0 +1,1731 @@ + + */ +class Mage_Usa_Model_Shipping_Carrier_Dhl_International + extends Mage_Usa_Model_Shipping_Carrier_Abstract + implements Mage_Shipping_Model_Carrier_Interface +{ + /** + * Carrier Product indicator + */ + const DHL_CONTENT_TYPE_DOC = 'D'; + const DHL_CONTENT_TYPE_NON_DOC = 'N'; + + /** + * Minimum allowed values for shipping package dimensions + */ + const DIMENSION_MIN_CM = 3; + const DIMENSION_MIN_IN = 1; + + /** + * Container types that could be customized + * + * @var array + */ + protected $_customizableContainerTypes = array(self::DHL_CONTENT_TYPE_NON_DOC); + + /** + * Code of the carrier + */ + const CODE = 'dhlint'; + + /** + * Rate request data + * + * @var Mage_Shipping_Model_Rate_Request|null + */ + protected $_request = null; + + /** + * Raw rate request data + * + * @var Varien_Object|null + */ + protected $_rawRequest = null; + + /** + * Rate result data + * + * @var Mage_Shipping_Model_Rate_Result|null + */ + protected $_result = null; + + /** + * Countries parameters data + * + * @var SimpleXMLElement|null + */ + protected $_countryParams = null; + + /** + * Errors placeholder + * + * @var array + */ + protected $_errors = array(); + + /** + * Dhl rates result + * + * @var array + */ + protected $_rates = array(); + + /** + * Carrier's code + * + * @var string + */ + protected $_code = self::CODE; + + /** + * Free Method config path + * + * @var string + */ + protected $_freeMethod = 'free_method_nondoc'; + + /** + * Max weight without fee + * + * @var int + */ + protected $_maxWeight = 70; + + /** + * Flag if response is for shipping label creating + * + * @var bool + */ + protected $_isShippingLabelFlag = false; + + /** + * Request variables array + * + * @var array + */ + protected $_requestVariables = array( + 'id' => array('code' => 'dhl_id', 'setCode' => 'id'), + 'password' => array('code' => 'dhl_password', 'setCode' => 'password'), + 'account' => array('code' => 'dhl_account', 'setCode' => 'account_nbr'), + 'shipping_key' => array('code' => 'dhl_shipping_key', 'setCode' => 'shipping_key'), + 'shipping_intlkey' => array('code' => 'dhl_shipping_intl_key', 'setCode' => 'shipping_intl_key'), + 'shipment_type' => array('code' => 'dhl_shipment_type', 'setCode' => 'shipment_type'), + 'dutiable' => array('code' => 'dhl_dutiable', 'setCode' => 'dutiable'), + 'dutypaymenttype' => array('code' => 'dhl_duty_payment_type', 'setCode' => 'duty_payment_type'), + 'contentdesc' => array('code' => 'dhl_content_desc', 'setCode' => 'content_desc') + ); + + /** + * Flag that shows if shipping is domestic + * + * @var bool + */ + protected $_isDomestic = false; + + /** + * Dhl International Class constructor + * + * Sets necessary data + */ + protected function _construct() + { + if ($this->getConfigData('content_type') == self::DHL_CONTENT_TYPE_DOC) { + $this->_freeMethod = 'free_method_doc'; + } + } + + /** + * Returns value of given variable + * + * @param mixed $origValue + * @param string $pathToValue + * @return mixed + */ + protected function _getDefaultValue($origValue, $pathToValue) + { + if (!$origValue) { + $origValue = Mage::getStoreConfig( + $pathToValue, + $this->getStore() + ); + } + + return $origValue; + } + + /** + * Collect and get rates + * + * @param Mage_Shipping_Model_Rate_Request $request + * @return bool|Mage_Shipping_Model_Rate_Result|null + */ + public function collectRates(Mage_Shipping_Model_Rate_Request $request) + { + if (!$this->getConfigFlag($this->_activeFlag)) { + return false; + } + + $requestDhl = clone $request; + $this->setStore($requestDhl->getStoreId()); + + $origCompanyName = $this->_getDefaultValue( + $requestDhl->getOrigCompanyName(), + Mage_Core_Model_Store::XML_PATH_STORE_STORE_NAME + ); + $origCountryId = $this->_getDefaultValue( + $requestDhl->getOrigCountryId(), + Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID + ); + $origState = $this->_getDefaultValue( + $requestDhl->getOrigState(), + Mage_Shipping_Model_Shipping::XML_PATH_STORE_REGION_ID + ); + $origCity = $this->_getDefaultValue( + $requestDhl->getOrigCity(), + Mage_Shipping_Model_Shipping::XML_PATH_STORE_CITY + ); + $origPostcode = $this->_getDefaultValue( + $requestDhl->getOrigPostcode(), + Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP + ); + + $requestDhl->setOrigCompanyName($origCompanyName) + ->setCountryId($origCountryId) + ->setOrigState($origState) + ->setOrigCity($origCity) + ->setOrigPostal($origPostcode); + $this->setRequest($requestDhl); + + $this->_result = $this->_getQuotes(); + + $this->_updateFreeMethodQuote($request); + + return $this->_result; + } + + /** + * Set Free Method Request + * + * @param string $freeMethod + * @return void + */ + protected function _setFreeMethodRequest($freeMethod) + { + $rawRequest = $this->_rawRequest; + + $rawRequest->setFreeMethodRequest(true); + $freeWeight = $this->getTotalNumOfBoxes($rawRequest->getFreeMethodWeight()); + $rawRequest->setWeight($freeWeight); + $rawRequest->setService($freeMethod); + } + + /** + * Returns request result + * + * @return Mage_Shipping_Model_Rate_Result|null + */ + public function getResult() + { + return $this->_result; + } + + protected function _addParams($requestObject) + { + $request = $this->_request; + foreach ($this->_requestVariables as $code => $objectCode) { + if ($request->getDhlId()) { + $value = $request->getData($objectCode['code']); + } else { + $value = $this->getConfigData($code); + } + $requestObject->setData($objectCode['setCode'], $value); + } + return $requestObject; + } + + /** + * Prepare and set request in property of current instance + * + * @param Varien_Object $request + * @return Mage_Usa_Model_Shipping_Carrier_Dhl + */ + public function setRequest(Varien_Object $request) + { + $this->_request = $request; + $this->setStore($request->getStoreId()); + + $requestObject = new Varien_Object(); + + $requestObject->setIsGenerateLabelReturn($request->getIsGenerateLabelReturn()); + + $requestObject->setStoreId($request->getStoreId()); + + if ($request->getLimitMethod()) { + $requestObject->setService($request->getLimitMethod()); + } + + $requestObject = $this->_addParams($requestObject); + + if ($request->getDestPostcode()) { + $requestObject->setDestPostal($request->getDestPostcode()); + } + + $requestObject->setOrigCountry( + $this->_getDefaultValue( + $request->getOrigCountry(), Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID) + ) + ->setOrigCountryId( + $this->_getDefaultValue( + $request->getOrigCountryId(), Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID) + ); + + $shippingWeight = $request->getPackageWeight(); + + $requestObject->setValue(round($request->getPackageValue(), 2)) + ->setValueWithDiscount($request->getPackageValueWithDiscount()) + ->setCustomsValue($request->getPackageCustomsValue()) + ->setDestStreet( + Mage::helper('core/string')->substr(str_replace("\n", '', $request->getDestStreet()), 0, 35)) + ->setDestStreetLine2($request->getDestStreetLine2()) + ->setDestCity($request->getDestCity()) + ->setOrigCompanyName($request->getOrigCompanyName()) + ->setOrigCity($request->getOrigCity()) + ->setOrigPhoneNumber($request->getOrigPhoneNumber()) + ->setOrigPersonName($request->getOrigPersonName()) + ->setOrigEmail(Mage::getStoreConfig('trans_email/ident_general/email', $requestObject->getStoreId())) + ->setOrigCity($request->getOrigCity()) + ->setOrigPostal($request->getOrigPostal()) + ->setOrigStreetLine2($request->getOrigStreetLine2()) + ->setDestPhoneNumber($request->getDestPhoneNumber()) + ->setDestPersonName($request->getDestPersonName()) + ->setDestCompanyName($request->getDestCompanyName()); + + $originStreet2 = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_ADDRESS2, $requestObject->getStoreId()); + + $requestObject->setOrigStreet($request->getOrigStreet() ? $request->getOrigStreet() : $originStreet2); + + if (is_numeric($request->getOrigState())) { + $requestObject->setOrigState(Mage::getModel('directory/region')->load($request->getOrigState())->getCode()); + } else { + $requestObject->setOrigState($request->getOrigState()); + } + + if ($request->getDestCountryId()) { + $destCountry = $request->getDestCountryId(); + } else { + $destCountry = self::USA_COUNTRY_ID; + } + + // for DHL, Puerto Rico state for US will assume as Puerto Rico country + // for Puerto Rico, dhl will ship as international + if ($destCountry == self::USA_COUNTRY_ID && ($request->getDestPostcode() == '00912' + || $request->getDestRegionCode() == self::PUERTORICO_COUNTRY_ID) + ) { + $destCountry = self::PUERTORICO_COUNTRY_ID; + } + + $requestObject->setDestCountryId($destCountry) + ->setDestState($request->getDestRegionCode()) + ->setWeight($shippingWeight) + ->setFreeMethodWeight($request->getFreeMethodWeight()) + ->setOrderShipment($request->getOrderShipment()); + + if ($request->getPackageId()) { + $requestObject->setPackageId($request->getPackageId()); + } + + $requestObject->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax()); + + $this->_rawRequest = $requestObject; + return $this; + } + + /** + * Get allowed shipping methods + * + * @return array + */ + public function getAllowedMethods() + { + $contentType = $this->getConfigData('content_type'); + $allowedMethods = array(); + if ($this->_isDomestic) { + $allowedMethods = array_merge(explode(',', $this->getConfigData('doc_methods')), + explode(',', $this->getConfigData('nondoc_methods')) + ); + } else { + switch ($contentType) { + case self::DHL_CONTENT_TYPE_DOC: + $allowedMethods = explode(',', $this->getConfigData('doc_methods')); + break; + case self::DHL_CONTENT_TYPE_NON_DOC: + $allowedMethods = explode(',', $this->getConfigData('nondoc_methods')); + break; + default: + Mage::throwException(Mage::helper('usa')->__('Wrong Content Type.')); + } + } + $methods = array(); + foreach ($allowedMethods as $method) { + $methods[$method] = $this->getDhlProductTitle($method); + } + return $methods; + } + + /** + * Get configuration data of carrier + * + * @param strin $type + * @param string $code + * @return array|bool + */ + public function getCode($type, $code = '') + { + $codes = array( + 'unit_of_measure' => array( + 'L' => Mage::helper('usa')->__('Pounds'), + 'K' => Mage::helper('usa')->__('Kilograms'), + ), + 'unit_of_dimension' => array( + 'I' => Mage::helper('usa')->__('Inches'), + 'C' => Mage::helper('usa')->__('Centimeters'), + ), + 'unit_of_dimension_cut' => array( + 'I' => Mage::helper('usa')->__('inch'), + 'C' => Mage::helper('usa')->__('cm'), + ), + 'dimensions' => array( + 'HEIGHT' => Mage::helper('usa')->__('Height'), + 'DEPTH' => Mage::helper('usa')->__('Depth'), + 'WIDTH' => Mage::helper('usa')->__('Width'), + ), + 'size' => array( + '0' => Mage::helper('usa')->__('Regular'), + '1' => Mage::helper('usa')->__('Specific'), + ), + 'dimensions_variables' => array( + 'L' => Zend_Measure_Weight::POUND, + 'LB' => Zend_Measure_Weight::POUND, + 'POUND' => Zend_Measure_Weight::POUND, + 'K' => Zend_Measure_Weight::KILOGRAM, + 'KG' => Zend_Measure_Weight::KILOGRAM, + 'KILOGRAM' => Zend_Measure_Weight::KILOGRAM, + 'I' => Zend_Measure_Length::INCH, + 'IN' => Zend_Measure_Length::INCH, + 'INCH' => Zend_Measure_Length::INCH, + 'C' => Zend_Measure_Length::CENTIMETER, + 'CM' => Zend_Measure_Length::CENTIMETER, + 'CENTIMETER'=> Zend_Measure_Length::CENTIMETER, + + ) + ); + + if (!isset($codes[$type])) { + return false; + } elseif ('' === $code) { + return $codes[$type]; + } + + $code = strtoupper($code); + if (!isset($codes[$type][$code])) { + return false; + } else { + return $codes[$type][$code]; + } + } + + /** + * Returns DHL shipment methods (depending on package content type, if necessary) + * + * @param string $doc Package content type (doc/non-doc) see DHL_CONTENT_TYPE_* constants + * @return array + */ + public function getDhlProducts($doc) + { + $docType = array( + '2' => Mage::helper('usa')->__('Easy shop'), + '5' => Mage::helper('usa')->__('Sprintline'), + '6' => Mage::helper('usa')->__('Secureline'), + '7' => Mage::helper('usa')->__('Express easy'), + '9' => Mage::helper('usa')->__('Europack'), + 'B' => Mage::helper('usa')->__('Break bulk express'), + 'C' => Mage::helper('usa')->__('Medical express'), + 'D' => Mage::helper('usa')->__('Express worldwide'), // product content code: DOX + 'U' => Mage::helper('usa')->__('Express worldwide'), // product content code: ECX + 'K' => Mage::helper('usa')->__('Express 9:00'), + 'L' => Mage::helper('usa')->__('Express 10:30'), + 'G' => Mage::helper('usa')->__('Domestic economy select'), + 'W' => Mage::helper('usa')->__('Economy select'), + 'I' => Mage::helper('usa')->__('Break bulk economy'), + 'N' => Mage::helper('usa')->__('Domestic express'), + 'O' => Mage::helper('usa')->__('Others'), + 'R' => Mage::helper('usa')->__('Globalmail business'), + 'S' => Mage::helper('usa')->__('Same day'), + 'T' => Mage::helper('usa')->__('Express 12:00'), + 'X' => Mage::helper('usa')->__('Express envelope'), + ); + + $nonDocType = array( + '1' => Mage::helper('usa')->__('Customer services'), + '3' => Mage::helper('usa')->__('Easy shop'), + '4' => Mage::helper('usa')->__('Jetline'), + '8' => Mage::helper('usa')->__('Express easy'), + 'P' => Mage::helper('usa')->__('Express worldwide'), + 'Q' => Mage::helper('usa')->__('Medical express'), + 'E' => Mage::helper('usa')->__('Express 9:00'), + 'F' => Mage::helper('usa')->__('Freight worldwide'), + 'H' => Mage::helper('usa')->__('Economy select'), + 'J' => Mage::helper('usa')->__('Jumbo box'), + 'M' => Mage::helper('usa')->__('Express 10:30'), + 'V' => Mage::helper('usa')->__('Europack'), + 'Y' => Mage::helper('usa')->__('Express 12:00'), + ); + + if ($this->_isDomestic) { + return $docType + $nonDocType; + } + if ($doc == self::DHL_CONTENT_TYPE_DOC) { + // Documents shipping + return $docType; + } else { + // Services for shipping non-documents cargo + return $nonDocType; + } + } + + /** + * Returns title of DHL shipping method by its code + * + * @param string $code One-symbol code (see getDhlProducts()) + * @return bool + */ + public function getDhlProductTitle($code) + { + $contentType = $this->getConfigData('content_type'); + $dhlProducts = $this->getDhlProducts($contentType); + return isset($dhlProducts[$code]) ? $dhlProducts[$code] : false; + } + + /** + * Convert item weight to needed weight based on config weight unit dimensions + * + * @param float $weight + * @param bool $maxWeight + * @param string|bool $configWeightUnit + * @return float + */ + protected function _getWeight($weight, $maxWeight = false, $configWeightUnit = false) + { + if ($maxWeight) { + $configWeightUnit = Zend_Measure_Weight::KILOGRAM; + } elseif ($configWeightUnit) { + $configWeightUnit = $this->getCode('dimensions_variables', $configWeightUnit); + } else { + $configWeightUnit = $this->getCode('dimensions_variables', (string)$this->getConfigData('unit_of_measure')); + } + + $countryWeightUnit = $this->getCode('dimensions_variables', $this->_getWeightUnit()); + + if ($configWeightUnit != $countryWeightUnit) { + $weight = Mage::helper('usa')->convertMeasureWeight( + round($weight,3), + $configWeightUnit, + $countryWeightUnit + ); + } + + return round($weight, 3); + } + + /** + * Prepare items to pieces + * + * @return array + */ + protected function _getAllItems() + { + $allItems = $this->_request->getAllItems(); + $fullItems = array(); + + foreach ($allItems as $item) { + if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE + && $item->getProduct()->getShipmentType() + ) { + continue; + } + + $qty = $item->getQty(); + $changeQty = true; + $checkWeight = true; + $decimalItems = array(); + + if ($item->getParentItem()) { + if (!$item->getParentItem()->getProduct()->getShipmentType()) { + continue; + } + $qty = $item->getIsQtyDecimal() + ? $item->getParentItem()->getQty() + : $item->getParentItem()->getQty() * $item->getQty(); + } + + $itemWeight = $item->getWeight(); + if ($item->getIsQtyDecimal() && $item->getProductType() != Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) { + $stockItem = $item->getProduct()->getStockItem(); + if ($stockItem->getIsDecimalDivided()) { + if ($stockItem->getEnableQtyIncrements() && $stockItem->getQtyIncrements()) { + $itemWeight = $itemWeight * $stockItem->getQtyIncrements(); + $qty = round(($item->getWeight() / $itemWeight) * $qty); + $changeQty = false; + } else { + $itemWeight = $this->_getWeight($itemWeight * $item->getQty()); + $maxWeight = $this->_getWeight($this->_maxWeight, true); + if ($itemWeight > $maxWeight) { + $qtyItem = floor($itemWeight / $maxWeight); + $decimalItems[] = array('weight' => $maxWeight, 'qty' => $qtyItem); + $weightItem = Mage::helper('core')->getExactDivision($itemWeight, $maxWeight); + if ($weightItem) { + $decimalItems[] = array('weight' => $weightItem, 'qty' => 1); + } + $checkWeight = false; + } else { + $itemWeight = $itemWeight * $item->getQty(); + } + } + } else { + $itemWeight = $itemWeight * $item->getQty(); + } + } + + if ($checkWeight && $this->_getWeight($itemWeight) > $this->_getWeight($this->_maxWeight, true)) { + return array(); + } + + if ($changeQty && !$item->getParentItem() && $item->getIsQtyDecimal() + && $item->getProductType() != Mage_Catalog_Model_Product_Type::TYPE_BUNDLE + ) { + $qty = 1; + } + + if (!empty($decimalItems)) { + foreach ($decimalItems as $decimalItem) { + $fullItems = array_merge($fullItems, + array_fill(0, $decimalItem['qty'] * $qty, $decimalItem['weight']) + ); + } + } else { + $fullItems = array_merge($fullItems, array_fill(0, $qty, $this->_getWeight($itemWeight))); + } + } + sort($fullItems); + + return $fullItems; + } + + /** + * Make pieces + * + * @param SimpleXMLElement $nodeBkgDetails + * @return void + */ + protected function _makePieces(SimpleXMLElement $nodeBkgDetails) + { + $divideOrderWeight = (string)$this->getConfigData('divide_order_weight'); + $nodePieces = $nodeBkgDetails->addChild('Pieces', '', ''); + $items = $this->_getAllItems(); + $numberOfPieces = 0; + + if ($divideOrderWeight && !empty($items)) { + $maxWeight = $this->_getWeight($this->_maxWeight, true); + $sumWeight = 0; + + $reverseOrderItems = $items; + arsort($reverseOrderItems); + + foreach ($reverseOrderItems as $key => $weight) { + if (!isset($items[$key])) { + continue; + } + unset($items[$key]); + $sumWeight = $weight; + foreach ($items as $key => $weight) { + if (($sumWeight + $weight) < $maxWeight) { + unset($items[$key]); + $sumWeight += $weight; + } elseif (($sumWeight + $weight) > $maxWeight) { + $numberOfPieces++; + $nodePiece = $nodePieces->addChild('Piece', '', ''); + $nodePiece->addChild('PieceID', $numberOfPieces); + $this->_addDimension($nodePiece); + $nodePiece->addChild('Weight', $sumWeight); + break; + } else { + unset($items[$key]); + $numberOfPieces++; + $sumWeight += $weight; + $nodePiece = $nodePieces->addChild('Piece', '', ''); + $nodePiece->addChild('PieceID', $numberOfPieces); + $this->_addDimension($nodePiece); + $nodePiece->addChild('Weight', $sumWeight); + $sumWeight = 0; + break; + } + } + } + if ($sumWeight > 0) { + $numberOfPieces++; + $nodePiece = $nodePieces->addChild('Piece', '', ''); + $nodePiece->addChild('PieceID', $numberOfPieces); + $this->_addDimension($nodePiece); + $nodePiece->addChild('Weight', $sumWeight); + } + } else { + $nodePiece = $nodePieces->addChild('Piece', '', ''); + $nodePiece->addChild('PieceID', 1); + $this->_addDimension($nodePiece); + $nodePiece->addChild('Weight', $this->_getWeight($this->_rawRequest->getWeight())); + } + + $handlingAction = $this->getConfigData('handling_action'); + if ($handlingAction == Mage_Shipping_Model_Carrier_Abstract::HANDLING_ACTION_PERORDER || !$numberOfPieces) { + $numberOfPieces = 1; + } + $this->_numBoxes = $numberOfPieces; + } + + /** + * Convert item dimension to needed dimension based on config dimension unit of measure + * + * @param float $dimension + * @param string|bool $configWeightUnit + * @return float + */ + protected function _getDimension($dimension, $configWeightUnit = false) + { + if (!$configWeightUnit) { + $configWeightUnit = $this->getCode('dimensions_variables', (string)$this->getConfigData('unit_of_measure')); + } else { + $configWeightUnit = $this->getCode('dimensions_variables', $configWeightUnit); + } + + if ($configWeightUnit == Zend_Measure_Weight::POUND) { + $configDimensionUnit = Zend_Measure_Length::INCH; + } else { + $configDimensionUnit = Zend_Measure_Length::CENTIMETER; + } + + $countryDimensionUnit = $this->getCode('dimensions_variables', $this->_getDimensionUnit()); + + if ($configDimensionUnit != $countryDimensionUnit) { + $dimension = Mage::helper('usa')->convertMeasureDimension( + round($dimension, 3), + $configDimensionUnit, + $countryDimensionUnit + ); + } + + return round($dimension, 3); + } + + /** + * Add dimension to piece + * + * @param SimpleXMLElement $nodePiece + * @return void + */ + protected function _addDimension($nodePiece) + { + $sizeChecker = (string)$this->getConfigData('size'); + + $height = $this->_getDimension((string)$this->getConfigData('height')); + $depth = $this->_getDimension((string)$this->getConfigData('depth')); + $width = $this->_getDimension((string)$this->getConfigData('width')); + + if ($sizeChecker && $height && $depth && $width) { + $nodePiece->addChild('Height', $height); + $nodePiece->addChild('Depth', $depth); + $nodePiece->addChild('Width', $width); + } + } + + /** + * Get shipping quotes + * + * @return Mage_Core_Model_Abstract|Mage_Shipping_Model_Rate_Result + */ + protected function _getQuotes() + { + $rawRequest = $this->_rawRequest; + $xmlStr = '' + . ''; + $xml = new SimpleXMLElement($xmlStr); + $nodeGetQuote = $xml->addChild('GetQuote', '', ''); + $nodeRequest = $nodeGetQuote->addChild('Request'); + + $nodeServiceHeader = $nodeRequest->addChild('ServiceHeader'); + $nodeServiceHeader->addChild('SiteID', (string)$this->getConfigData('id')); + $nodeServiceHeader->addChild('Password', (string)$this->getConfigData('password')); + + $nodeFrom = $nodeGetQuote->addChild('From'); + $nodeFrom->addChild('CountryCode', $rawRequest->getOrigCountryId()); + $nodeFrom->addChild('Postalcode', $rawRequest->getOrigPostal()); + $nodeFrom->addChild('City', $rawRequest->getOrigCity()); + + $nodeBkgDetails = $nodeGetQuote->addChild('BkgDetails'); + $nodeBkgDetails->addChild('PaymentCountryCode', $rawRequest->getOrigCountryId()); + $nodeBkgDetails->addChild('Date', Varien_Date::now(true)); + $nodeBkgDetails->addChild('ReadyTime', 'PT' . (int)(string)$this->getConfigData('ready_time') . 'H00M'); + + $nodeBkgDetails->addChild('DimensionUnit', $this->_getDimensionUnit()); + $nodeBkgDetails->addChild('WeightUnit', $this->_getWeightUnit()); + + $this->_makePieces($nodeBkgDetails); + + $nodeBkgDetails->addChild('PaymentAccountNumber', (string)$this->getConfigData('account')); + + $nodeTo = $nodeGetQuote->addChild('To'); + $nodeTo->addChild('CountryCode', $rawRequest->getDestCountryId()); + $nodeTo->addChild('Postalcode', $rawRequest->getDestPostal()); + $nodeTo->addChild('City', $rawRequest->getDestCity()); + + $this->_checkDomesticStatus($rawRequest->getOrigCountryId(), $rawRequest->getDestCountryId()); + + if ($this->getConfigData('content_type') == self::DHL_CONTENT_TYPE_NON_DOC && !$this->_isDomestic) { + // IsDutiable flag and Dutiable node indicates that cargo is not a documentation + $nodeBkgDetails->addChild('IsDutiable', 'Y'); + $nodeDutiable = $nodeGetQuote->addChild('Dutiable'); + $baseCurrencyCode = Mage::app()->getWebsite($this->_request->getWebsiteId())->getBaseCurrencyCode(); + $nodeDutiable->addChild('DeclaredCurrency', $baseCurrencyCode); + $nodeDutiable->addChild('DeclaredValue', sprintf("%.2F", $rawRequest->getValue())); + } + + $request = $xml->asXML(); + $request = utf8_encode($request); + $responseBody = $this->_getCachedQuotes($request); + if ($responseBody === null) { + $debugData = array('request' => $request); + try { + $client = new Varien_Http_Client(); + $client->setUri((string)$this->getConfigData('gateway_url')); + $client->setConfig(array('maxredirects' => 0, 'timeout' => 30)); + $client->setRawData($request); + $responseBody = $client->request(Varien_Http_Client::POST)->getBody(); + $debugData['result'] = $responseBody; + $this->_setCachedQuotes($request, $responseBody); + } catch (Exception $e) { + $this->_errors[$e->getCode()] = $e->getMessage(); + $responseBody = ''; + } + $this->_debug($debugData); + } + + return $this->_parseResponse($responseBody); + } + + /** + * Parse response from DHL web service + * + * @param string $response + * @return Mage_Shipping_Model_Rate_Result + */ + protected function _parseResponse($response) + { + $htmlTranslationTable = get_html_translation_table(HTML_ENTITIES); + unset($htmlTranslationTable['<'], $htmlTranslationTable['>'], $htmlTranslationTable['"']); + $response = str_replace(array_keys($htmlTranslationTable), array_values($htmlTranslationTable), $response); + + $responseError = Mage::helper('usa')->__('The response is in wrong format.'); + + if (strlen(trim($response)) > 0) { + if (strpos(trim($response), 'getName(), array('ErrorResponse', 'ShipmentValidateErrorResponse')) + || isset($xml->GetQuoteResponse->Note->Condition) + ) { + $code = null; + $data = null; + if (isset($xml->Response->Status->Condition)) { + $nodeCondition = $xml->Response->Status->Condition; + } else { + $nodeCondition = $xml->GetQuoteResponse->Note->Condition; + } + + if ($this->_isShippingLabelFlag) { + foreach ($nodeCondition as $condition) { + $code = isset($condition->ConditionCode) ? (string)$condition->ConditionCode : 0; + $data = isset($condition->ConditionData) ? (string)$condition->ConditionData : ''; + if (!empty($code) && !empty($data)) { + break; + } + } + Mage::throwException(Mage::helper('usa')->__('Error #%s : %s', trim($code), trim($data))); + } + + $code = isset($nodeCondition->ConditionCode) ? (string)$nodeCondition->ConditionCode : 0; + $data = isset($nodeCondition->ConditionData) ? (string)$nodeCondition->ConditionData : ''; + $this->_errors[$code] = Mage::helper('usa')->__('Error #%s : %s', trim($code), trim($data)); + } else { + if (isset($xml->GetQuoteResponse->BkgDetails->QtdShp)) { + foreach ($xml->GetQuoteResponse->BkgDetails->QtdShp as $quotedShipment) { + $this->_addRate($quotedShipment); + } + } elseif (isset($xml->AirwayBillNumber)) { + $result = new Varien_Object(); + $result->setTrackingNumber((string)$xml->AirwayBillNumber); + try { + /* @var $pdf Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf */ + $pdf = Mage::getModel( + 'usa/shipping_carrier_dhl_label_pdf', + array('info' => $xml, 'request' => $this->_request) + ); + $result->setShippingLabelContent($pdf->render()); + } catch (Exception $e) { + Mage::throwException(Mage::helper('usa')->__($e->getMessage())); + } + return $result; + } else { + $this->_errors[] = $responseError; + } + } + } + } else { + $this->_errors[] = $responseError; + } + } else { + $this->_errors[] = $responseError; + } + + /* @var $result Mage_Shipping_Model_Rate_Result */ + $result = Mage::getModel('shipping/rate_result'); + if ($this->_rates) { + foreach ($this->_rates as $rate) { + $method = $rate['service']; + $data = $rate['data']; + /* @var $rate Mage_Shipping_Model_Rate_Result_Method */ + $rate = Mage::getModel('shipping/rate_result_method'); + $rate->setCarrier(self::CODE); + $rate->setCarrierTitle($this->getConfigData('title')); + $rate->setMethod($method); + $rate->setMethodTitle($data['term']); + $rate->setCost($data['price_total']); + $rate->setPrice($data['price_total']); + $result->append($rate); + } + } else if (!empty($this->_errors)) { + if ($this->_isShippingLabelFlag) { + Mage::throwException($responseError); + } + return $this->_showError(); + } + return $result; + } + + /** + * Add rate to DHL rates array + * + * @param SimpleXMLElement $shipmentDetails + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_International + */ + protected function _addRate(SimpleXMLElement $shipmentDetails) + { + if (isset($shipmentDetails->ProductShortName) + && isset($shipmentDetails->ShippingCharge) + && isset($shipmentDetails->GlobalProductCode) + && isset($shipmentDetails->CurrencyCode) + && array_key_exists((string)$shipmentDetails->GlobalProductCode, $this->getAllowedMethods()) + ) { + // DHL product code, e.g. '3', 'A', 'Q', etc. + $dhlProduct = (string)$shipmentDetails->GlobalProductCode; + $totalEstimate = (float)(string)$shipmentDetails->ShippingCharge; + $currencyCode = (string)$shipmentDetails->CurrencyCode; + $baseCurrencyCode = Mage::app()->getWebsite($this->_request->getWebsiteId())->getBaseCurrencyCode(); + $dhlProductDescription = $this->getDhlProductTitle($dhlProduct); + + if ($currencyCode != $baseCurrencyCode) { + /* @var $currency Mage_Directory_Model_Currency */ + $currency = Mage::getModel('directory/currency'); + $rates = $currency->getCurrencyRates($currencyCode, array($baseCurrencyCode)); + if (!empty($rates) && isset($rates[$baseCurrencyCode])) { + // Convert to store display currency using store exchange rate + $totalEstimate = $totalEstimate * $rates[$baseCurrencyCode]; + } else { + $rates = $currency->getCurrencyRates($baseCurrencyCode, array($currencyCode)); + if (!empty($rates) && isset($rates[$currencyCode])) { + $totalEstimate = $totalEstimate/$rates[$currencyCode]; + } + if (!isset($rates[$currencyCode]) || !$totalEstimate) { + $totalEstimate = false; + $this->_errors[] = Mage::helper('usa')->__("Exchange rate %s (Base Currency) -> %s not found. DHL method %s skipped", $currencyCode, $baseCurrencyCode, $dhlProductDescription); + } + } + } + if ($totalEstimate) { + $data = array('term' => $dhlProductDescription, + 'price_total' => $this->getMethodPrice($totalEstimate, $dhlProduct)); + if (!empty($this->_rates)) { + foreach ($this->_rates as $product) { + if ($product['data']['term'] == $data['term'] + && $product['data']['price_total'] == $data['price_total'] + ) { + return $this; + } + } + } + $this->_rates[] = array('service' => $dhlProduct, 'data' => $data); + } else { + $this->_errors[] = Mage::helper('usa')->__("Zero shipping charge for '%s'", $dhlProductDescription); + } + } else { + $dhlProductDescription = false; + if (isset($shipmentDetails->GlobalProductCode)) { + $dhlProductDescription = $this->getDhlProductTitle((string)$shipmentDetails->GlobalProductCode); + } + $dhlProductDescription = $dhlProductDescription ? $dhlProductDescription : Mage::helper('usa')->__("DHL"); + $this->_errors[] = Mage::helper('usa')->__("Zero shipping charge for '%s'", $dhlProductDescription); + } + return $this; + } + + /** + * Returns dimension unit (cm or inch) + * + * @return string + */ + protected function _getDimensionUnit() + { + $countryId = $this->_rawRequest->getOrigCountryId(); + $measureUnit = $this->getCountryParams($countryId)->getMeasureUnit(); + if (empty($measureUnit)) { + Mage::throwException(Mage::helper('usa')->__("Cannot identify measure unit for %s", $countryId)); + } + return $measureUnit; + } + + /** + * Returns weight unit (kg or pound) + * + * @return string + */ + protected function _getWeightUnit() + { + $countryId = $this->_rawRequest->getOrigCountryId(); + $weightUnit = $this->getCountryParams($countryId)->getWeightUnit(); + if (empty($weightUnit)) { + Mage::throwException(Mage::helper('usa')->__("Cannot identify weight unit for %s", $countryId)); + } + return $weightUnit; + } + + /** + * Get Country Params by Country Code + * + * @param string $countryCode + * @return Varien_Object + * + * @see $countryCode ISO 3166 Codes (Countries) A2 + */ + protected function getCountryParams($countryCode) + { + if (empty($this->_countryParams)) { + $dhlConfigPath = Mage::getModuleDir('etc', 'Mage_Usa') . DS . 'dhl' . DS; + $countriesXml = file_get_contents($dhlConfigPath . 'international' . DS . 'countries.xml'); + $this->_countryParams = new Varien_Simplexml_Element($countriesXml); + } + if (isset($this->_countryParams->$countryCode)) { + $countryParams = new Varien_Object($this->_countryParams->$countryCode->asArray()); + } + return isset($countryParams) ? $countryParams : new Varien_Object(); + } + + /** + * Do shipment request to carrier web service, obtain Print Shipping Labels and process errors in response + * + * @param Varien_Object $request + * @return Varien_Object + */ + protected function _doShipmentRequest(Varien_Object $request) + { + $this->_prepareShipmentRequest($request); + $this->_mapRequestToShipment($request); + $this->setRequest($request); + + return $this->_doRequest(); + } + + /** + * Processing additional validation to check is carrier applicable. + * + * @param Mage_Shipping_Model_Rate_Request $request + * @return Mage_Shipping_Model_Carrier_Abstract|Mage_Shipping_Model_Rate_Result_Error|boolean + */ + public function proccessAdditionalValidation(Mage_Shipping_Model_Rate_Request $request) + { + //Skip by item validation if there is no items in request + if (!count($this->getAllItems($request))) { + $this->_errors[] = Mage::helper('usa')->__('There is no items in this order'); + } + + $countryParams = $this->getCountryParams( + Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $request->getStoreId()) + ); + if (!$countryParams->getData()) { + $this->_errors[] = Mage::helper('usa')->__('Please, specify origin country'); + } + + if (!empty($this->_errors)) { + return $this->_showError(); + } + + return $this; + } + + /** + * Show default error + * + * @return bool|Mage_Shipping_Model_Rate_Result_Error + */ + protected function _showError() + { + $showMethod = $this->getConfigData('showmethod'); + + if ($showMethod) { + /* @var $error Mage_Shipping_Model_Rate_Result_Error */ + $error = Mage::getModel('shipping/rate_result_error'); + $error->setCarrier(self::CODE); + $error->setCarrierTitle($this->getConfigData('title')); + $error->setErrorMessage($this->getConfigData('specificerrmsg')); + $this->_debug($this->_errors); + return $error; + } else { + return false; + } + } + + /** + * Return container types of carrier + * + * @param Varien_Object|null $params + * @return array + */ + public function getContainerTypes(Varien_Object $params = null) + { + return array( + self::DHL_CONTENT_TYPE_DOC => Mage::helper('usa')->__('Documents'), + self::DHL_CONTENT_TYPE_NON_DOC => Mage::helper('usa')->__('Non Documents') + ); + } + + /** + * Map request to shipment + * + * @param Varien_Object $request + * @return null + */ + protected function _mapRequestToShipment(Varien_Object $request) + { + + $request->setOrigCountryId($request->getShipperAddressCountryCode()); + $this->_rawRequest = $request; + $customsValue = 0; + $packageWeight = 0; + $packages = $request->getPackages(); + foreach ($packages as &$piece) { + $params = $piece['params']; + if ($params['width'] || $params['length'] || $params['height']) { + $minValue = $this->_getMinDimension($params['dimension_units']); + if ($params['width'] < $minValue || $params['length'] < $minValue || $params['height'] < $minValue) { + $message = Mage::helper('usa')->__('Height, width and length should be equal or greater than %s', $minValue); + Mage::throwException($message); + } + } + + $weightUnits = $piece['params']['weight_units']; + $piece['params']['height'] = $this->_getDimension($piece['params']['height'], $weightUnits); + $piece['params']['length'] = $this->_getDimension($piece['params']['length'], $weightUnits); + $piece['params']['width'] = $this->_getDimension($piece['params']['width'], $weightUnits); + $piece['params']['dimension_units'] = $this->_getDimensionUnit(); + $piece['params']['weight'] = $this->_getWeight($piece['params']['weight'], false, $weightUnits); + $piece['params']['weight_units'] = $this->_getWeightUnit(); + + $customsValue += $piece['params']['customs_value']; + $packageWeight += $piece['params']['weight']; + } + + $request->setPackages($packages) + ->setPackageWeight($packageWeight) + ->setPackageValue($customsValue) + ->setValueWithDiscount($customsValue) + ->setPackageCustomsValue($customsValue) + ->setFreeMethodWeight(0); + } + + /** + * Retrieve minimum allowed value for dimensions in given dimension unit + * + * @param string $dimensionUnit + * @return int + */ + protected function _getMinDimension($dimensionUnit) + { + return $dimensionUnit == "CENTIMETER" ? self::DIMENSION_MIN_CM : self::DIMENSION_MIN_IN; + } + + /** + * Do rate request and handle errors + * + * @return Mage_Shipping_Model_Rate_Result|Varien_Object + */ + protected function _doRequest() + { + $rawRequest = $this->_request; + + $originRegion = (string)$this->getCountryParams( + Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $this->getStore()) + )->region; + + if (!$originRegion) { + Mage::throwException(Mage::helper('usa')->__('Wrong Region.')); + } + + if ($originRegion == 'AM') { + $originRegion = ''; + } + + $xmlStr = '' + . ''; + $xml = new SimpleXMLElement($xmlStr); + + $nodeRequest = $xml->addChild('Request', '', ''); + $nodeServiceHeader = $nodeRequest->addChild('ServiceHeader'); + $nodeServiceHeader->addChild('SiteID', (string)$this->getConfigData('id')); + $nodeServiceHeader->addChild('Password', (string)$this->getConfigData('password')); + + if (!$originRegion) { + $xml->addChild('RequestedPickupTime', 'N', ''); + } + $xml->addChild('NewShipper', 'N', ''); + $xml->addChild('LanguageCode', 'EN', ''); + $xml->addChild('PiecesEnabled', 'Y', ''); + + /* Billing */ + $nodeBilling = $xml->addChild('Billing', '', ''); + $nodeBilling->addChild('ShipperAccountNumber', (string)$this->getConfigData('account')); + /* + * Method of Payment: + * S (Shipper) + * R (Receiver) + * T (Third Party) + */ + $nodeBilling->addChild('ShippingPaymentType', 'S'); + + /* + * Shipment bill to account – required if Shipping PaymentType is other than 'S' + */ + $nodeBilling->addChild('BillingAccountNumber', (string)$this->getConfigData('account')); + $nodeBilling->addChild('DutyPaymentType', 'S'); + $nodeBilling->addChild('DutyAccountNumber', (string)$this->getConfigData('account')); + + /* Receiver */ + $nodeConsignee = $xml->addChild('Consignee', '', ''); + + $companyName = ($rawRequest->getRecipientContactCompanyName()) + ? $rawRequest->getRecipientContactCompanyName() + : $rawRequest->getRecipientContactPersonName(); + + $nodeConsignee->addChild('CompanyName', substr($companyName, 0, 35)); + + $address = $rawRequest->getRecipientAddressStreet1(). ' ' . $rawRequest->getRecipientAddressStreet2(); + $address = Mage::helper('core/string')->str_split($address, 35, false, true); + if (is_array($address)) { + foreach ($address as $addressLine) { + $nodeConsignee->addChild('AddressLine', $addressLine); + } + } else { + $nodeConsignee->addChild('AddressLine', $address); + } + + $nodeConsignee->addChild('City', $rawRequest->getRecipientAddressCity()); + $nodeConsignee->addChild('Division', $rawRequest->getRecipientAddressStateOrProvinceCode()); + $nodeConsignee->addChild('PostalCode', $rawRequest->getRecipientAddressPostalCode()); + $nodeConsignee->addChild('CountryCode', $rawRequest->getRecipientAddressCountryCode()); + $nodeConsignee->addChild('CountryName', + (string)$this->getCountryParams($rawRequest->getRecipientAddressCountryCode())->name + ); + $nodeContact = $nodeConsignee->addChild('Contact'); + $nodeContact->addChild('PersonName', substr($rawRequest->getRecipientContactPersonName(), 0, 34)); + $nodeContact->addChild('PhoneNumber', substr($rawRequest->getRecipientContactPhoneNumber(), 0, 24)); + + /* Commodity + * The CommodityCode element contains commodity code for shipment contents. Its + * value should lie in between 1 to 9999.This field is mandatory. + */ + $nodeCommodity = $xml->addChild('Commodity', '', ''); + $nodeCommodity->addChild('CommodityCode', '1'); + + $this->_checkDomesticStatus($rawRequest->getShipperAddressCountryCode(), + $rawRequest->getRecipientAddressCountryCode() + ); + + /* Dutiable */ + if ($this->getConfigData('content_type') == self::DHL_CONTENT_TYPE_NON_DOC && !$this->_isDomestic) { + $nodeDutiable = $xml->addChild('Dutiable', '', ''); + $nodeDutiable->addChild('DeclaredValue', + sprintf("%.2F", $rawRequest->getOrderShipment()->getOrder()->getSubtotal()) + ); + $baseCurrencyCode = Mage::app()->getWebsite($rawRequest->getWebsiteId())->getBaseCurrencyCode(); + $nodeDutiable->addChild('DeclaredCurrency', $baseCurrencyCode); + } + + /* Reference + * This element identifies the reference information. It is an optional field in the + * shipment validation request. Only the first reference will be taken currently. + */ + $nodeReference = $xml->addChild('Reference', '', ''); + $nodeReference->addChild('ReferenceID', 'shipment reference'); + $nodeReference->addChild('ReferenceType', 'St'); + + /* Shipment Details */ + $this->_shipmentDetails($xml, $rawRequest, $originRegion); + + /* Shipper */ + $nodeShipper = $xml->addChild('Shipper', '', ''); + $nodeShipper->addChild('ShipperID', (string)$this->getConfigData('account')); + $nodeShipper->addChild('CompanyName', $rawRequest->getShipperContactCompanyName()); + $nodeShipper->addChild('RegisteredAccount', (string)$this->getConfigData('account')); + + $address = $rawRequest->getShipperAddressStreet1(). ' ' . $rawRequest->getShipperAddressStreet2(); + $address = Mage::helper('core/string')->str_split($address, 35, false, true); + if (is_array($address)) { + foreach ($address as $addressLine) { + $nodeShipper->addChild('AddressLine', $addressLine); + } + } else { + $nodeShipper->addChild('AddressLine', $address); + } + + $nodeShipper->addChild('City', $rawRequest->getShipperAddressCity()); + $nodeShipper->addChild('Division', $rawRequest->getShipperAddressStateOrProvinceCode()); + $nodeShipper->addChild('PostalCode', $rawRequest->getShipperAddressPostalCode()); + $nodeShipper->addChild('CountryCode', $rawRequest->getShipperAddressCountryCode()); + $nodeShipper->addChild('CountryName', + (string)$this->getCountryParams($rawRequest->getShipperAddressCountryCode())->name + ); + $nodeContact = $nodeShipper->addChild('Contact', '', ''); + $nodeContact->addChild('PersonName', substr($rawRequest->getShipperContactPersonName(), 0, 34)); + $nodeContact->addChild('PhoneNumber', substr($rawRequest->getShipperContactPhoneNumber(), 0, 24)); + + $request = $xml->asXML(); + $request = utf8_encode($request); + + $responseBody = $this->_getCachedQuotes($request); + if ($responseBody === null) { + $debugData = array('request' => $request); + try { + $client = new Varien_Http_Client(); + $client->setUri((string)$this->getConfigData('gateway_url')); + $client->setConfig(array('maxredirects' => 0, 'timeout' => 30)); + $client->setRawData($request); + $responseBody = $client->request(Varien_Http_Client::POST)->getBody(); + $debugData['result'] = $responseBody; + $this->_setCachedQuotes($request, $responseBody); + } catch (Exception $e) { + $this->_errors[$e->getCode()] = $e->getMessage(); + $responseBody = ''; + } + $this->_debug($debugData); + } + $this->_isShippingLabelFlag = true; + return $this->_parseResponse($responseBody); + } + + /** + * Generation Shipment Details Node according to origin region + * + * @param SimpleXMLElement $xml + * @param Mage_Shipping_Model_Rate_Request $rawRequest + * @param string $originRegion + * @return void + */ + protected function _shipmentDetails($xml, $rawRequest, $originRegion = '') + { + $nodeShipmentDetails = $xml->addChild('ShipmentDetails', '', ''); + $nodeShipmentDetails->addChild('NumberOfPieces', count($rawRequest->getPackages())); + + if ($originRegion) { + $nodeShipmentDetails->addChild('CurrencyCode', + Mage::app()->getWebsite($this->_request->getWebsiteId())->getBaseCurrencyCode() + ); + } + + $nodePieces = $nodeShipmentDetails->addChild('Pieces', '', ''); + + /* + * Package type + * EE (DHL Express Envelope), OD (Other DHL Packaging), CP (Custom Packaging) + * DC (Document), DM (Domestic), ED (Express Document), FR (Freight) + * BD (Jumbo Document), BP (Jumbo Parcel), JD (Jumbo Junior Document) + * JP (Jumbo Junior Parcel), PA (Parcel), DF (DHL Flyer) + */ + $i = 0; + foreach ($rawRequest->getPackages() as $package) { + $nodePiece = $nodePieces->addChild('Piece', '', ''); + $packageType = 'EE'; + if ($package['params']['container'] == self::DHL_CONTENT_TYPE_NON_DOC) { + $packageType = 'CP'; + } + $nodePiece->addChild('PieceID', ++$i); + $nodePiece->addChild('PackageType', $packageType); + $nodePiece->addChild('Weight', round($package['params']['weight'],1)); + $params = $package['params']; + if ($params['width'] && $params['length'] && $params['height']) { + if (!$originRegion) { + $nodePiece->addChild('Width', round($params['width'])); + $nodePiece->addChild('Height', round($params['height'])); + $nodePiece->addChild('Depth', round($params['length'])); + } else { + $nodePiece->addChild('Depth', round($params['length'])); + $nodePiece->addChild('Width', round($params['width'])); + $nodePiece->addChild('Height', round($params['height'])); + } + } + $content = array(); + foreach ($package['items'] as $item) { + $content[] = $item['name']; + } + $nodePiece->addChild('PieceContents', substr(implode(',', $content), 0, 34)); + } + + if (!$originRegion) { + $nodeShipmentDetails->addChild('Weight', round($rawRequest->getPackageWeight(),1)); + + $nodeShipmentDetails->addChild('WeightUnit', substr($this->_getWeightUnit(),0,1)); + + $nodeShipmentDetails->addChild('GlobalProductCode', $rawRequest->getShippingMethod()); + $nodeShipmentDetails->addChild('LocalProductCode', $rawRequest->getShippingMethod()); + + $nodeShipmentDetails->addChild('Date', Mage::getModel('core/date')->date('Y-m-d')); + $nodeShipmentDetails->addChild('Contents', 'DHL Parcel'); + /* + * The DoorTo Element defines the type of delivery service that applies to the shipment. + * The valid values are DD (Door to Door), DA (Door to Airport) , AA and DC (Door to + * Door non-compliant) + */ + $nodeShipmentDetails->addChild('DoorTo', 'DD'); + $nodeShipmentDetails->addChild('DimensionUnit', substr($this->_getDimensionUnit(),0,1)); + if ($package['params']['container'] == self::DHL_CONTENT_TYPE_NON_DOC) { + $packageType = 'CP'; + } + $nodeShipmentDetails->addChild('PackageType', $packageType); + if ($this->getConfigData('content_type') == self::DHL_CONTENT_TYPE_NON_DOC) { + $nodeShipmentDetails->addChild('IsDutiable', 'Y'); + } + $nodeShipmentDetails->addChild('CurrencyCode', + Mage::app()->getWebsite($this->_request->getWebsiteId())->getBaseCurrencyCode() + ); + } else { + if ($package['params']['container'] == self::DHL_CONTENT_TYPE_NON_DOC) { + $packageType = 'CP'; + } + $nodeShipmentDetails->addChild('PackageType', $packageType); + $nodeShipmentDetails->addChild('Weight', $rawRequest->getPackageWeight()); + + $nodeShipmentDetails->addChild('DimensionUnit', substr($this->_getDimensionUnit(),0,1)); + $nodeShipmentDetails->addChild('WeightUnit', substr($this->_getWeightUnit(),0,1)); + + $nodeShipmentDetails->addChild('GlobalProductCode', $rawRequest->getShippingMethod()); + $nodeShipmentDetails->addChild('LocalProductCode', $rawRequest->getShippingMethod()); + + /* + * The DoorTo Element defines the type of delivery service that applies to the shipment. + * The valid values are DD (Door to Door), DA (Door to Airport) , AA and DC (Door to + * Door non-compliant) + */ + $nodeShipmentDetails->addChild('DoorTo', 'DD'); + $nodeShipmentDetails->addChild('Date', Mage::getModel('core/date')->date('Y-m-d')); + $nodeShipmentDetails->addChild('Contents', 'DHL Parcel'); + } + } + + /** + * Get tracking + * + * @param mixed $trackings + * @return mixed + */ + public function getTracking($trackings) + { + if (!is_array($trackings)) { + $trackings = array($trackings); + } + $this->_getXMLTracking($trackings); + + return $this->_result; + } + + /** + * Send request for tracking + * + * @param array $trackings + * @return void + */ + protected function _getXMLTracking($trackings) + { + $xmlStr = '' + . ''; + + $xml = new SimpleXMLElement($xmlStr); + + $requestNode = $xml->addChild('Request', '', ''); + $serviceHeaderNode = $requestNode->addChild('ServiceHeader', '', ''); + $serviceHeaderNode->addChild('SiteID', (string)$this->getConfigData('id')); + $serviceHeaderNode->addChild('Password', (string)$this->getConfigData('password')); + + $xml->addChild('LanguageCode', 'EN', ''); + foreach ($trackings as $tracking) { + $xml->addChild('AWBNumber', $tracking, ''); + } + /* + * Checkpoint details selection flag + * LAST_CHECK_POINT_ONLY + * ALL_CHECK_POINTS + */ + $xml->addChild('LevelOfDetails', 'ALL_CHECK_POINTS', ''); + + /* + * Value that indicates for getting the tracking details with the additional + * piece details and its respective Piece Details, Piece checkpoints along with + * Shipment Details if queried. + * + * S-Only Shipment Details + * B-Both Shipment & Piece Details + * P-Only Piece Details + * Default is ‘S’ + */ + //$xml->addChild('PiecesEnabled', 'ALL_CHECK_POINTS'); + + $request = $xml->asXML(); + $request = utf8_encode($request); + + $responseBody = $this->_getCachedQuotes($request); + if ($responseBody === null) { + $debugData = array('request' => $request); + try { + $client = new Varien_Http_Client(); + $client->setUri((string)$this->getConfigData('gateway_url')); + $client->setConfig(array('maxredirects' => 0, 'timeout' => 30)); + $client->setRawData($request); + $responseBody = $client->request(Varien_Http_Client::POST)->getBody(); + $debugData['result'] = $responseBody; + $this->_setCachedQuotes($request, $responseBody); + } catch (Exception $e) { + $this->_errors[$e->getCode()] = $e->getMessage(); + $responseBody = ''; + } + $this->_debug($debugData); + } + + $this->_parseXmlTrackingResponse($trackings, $responseBody); + } + + /** + * Parse xml tracking response + * + * @param array $trackings + * @param string $response + * @return void + */ + protected function _parseXmlTrackingResponse($trackings, $response) + { + $errorTitle = Mage::helper('usa')->__('Unable to retrieve tracking'); + $resultArr = array(); + + $htmlTranslationTable = get_html_translation_table(HTML_ENTITIES); + unset($htmlTranslationTable['<'], $htmlTranslationTable['>'], $htmlTranslationTable['"']); + $response = str_replace(array_keys($htmlTranslationTable), array_values($htmlTranslationTable), $response); + + if (strlen(trim($response)) > 0) { + $xml = simplexml_load_string($response); + if (!is_object($xml)) { + $errorTitle = Mage::helper('usa')->__('Response is in the wrong format'); + } + if (is_object($xml) && ((isset($xml->Response->Status->ActionStatus) + && $xml->Response->Status->ActionStatus == 'Failure') + || isset($xml->GetQuoteResponse->Note->Condition)) + ) { + if (isset($xml->Response->Status->Condition)) { + $nodeCondition = $xml->Response->Status->Condition; + } + + $code = isset($nodeCondition->ConditionCode) ? (string)$nodeCondition->ConditionCode : 0; + $data = isset($nodeCondition->ConditionData) ? (string)$nodeCondition->ConditionData : ''; + $this->_errors[$code] = Mage::helper('usa')->__('Error #%s : %s', $code, $data); + } elseif (is_object($xml) && is_object($xml->AWBInfo)) { + foreach ($xml->AWBInfo as $awbinfo) { + $awbinfoData = array(); + $trackNum = isset($awbinfo->AWBNumber) ? (string)$awbinfo->AWBNumber : ''; + if (!is_object($awbinfo) || !$awbinfo->ShipmentInfo) { + $this->_errors[$trackNum] = Mage::helper('usa')->__('Unable to retrieve tracking'); + continue; + } + $shipmentInfo = $awbinfo->ShipmentInfo; + + if ($shipmentInfo->ShipmentDesc) { + $awbinfoData['service'] = (string)$shipmentInfo->ShipmentDesc; + } + + $awbinfoData['weight'] = (string)$shipmentInfo->Weight . ' ' . (string)$shipmentInfo->WeightUnit; + + $packageProgress = array(); + if (isset($shipmentInfo->ShipmentEvent)) { + foreach ($shipmentInfo->ShipmentEvent as $shipmentEvent) { + $shipmentEventArray = array(); + $shipmentEventArray['activity'] = (string)$shipmentEvent->ServiceEvent->EventCode + . ' ' . (string)$shipmentEvent->ServiceEvent->Description; + $shipmentEventArray['deliverydate'] = (string)$shipmentEvent->Date; + $shipmentEventArray['deliverytime'] = (string)$shipmentEvent->Time; + $shipmentEventArray['deliverylocation'] = (string)$shipmentEvent->ServiceArea->Description + . ' [' . (string)$shipmentEvent->ServiceArea->ServiceAreaCode . ']'; + $packageProgress[] = $shipmentEventArray; + } + $awbinfoData['progressdetail'] = $packageProgress; + } + $resultArr[$trackNum] = $awbinfoData; + } + } + } + + $result = Mage::getModel('shipping/tracking_result'); + + if (!empty($resultArr)) { + foreach ($resultArr as $trackNum => $data) { + $tracking = Mage::getModel('shipping/tracking_result_status'); + $tracking->setCarrier($this->_code); + $tracking->setCarrierTitle($this->getConfigData('title')); + $tracking->setTracking($trackNum); + $tracking->addData($data); + $result->append($tracking); + } + } + + if (!empty($this->_errors) || empty($resultArr)) { + $resultArr = !empty($this->_errors) ? $this->_errors : $trackings; + foreach ($resultArr as $trackNum => $err) { + $error = Mage::getModel('shipping/tracking_result_error'); + $error->setCarrier($this->_code); + $error->setCarrierTitle($this->getConfigData('title')); + $error->setTracking(!empty($this->_errors) ? $trackNum : $err); + $error->setErrorMessage(!empty($this->_errors) ? $err : $errorTitle); + $result->append($error); + } + } + + $this->_result = $result; + } + + /** + * Get final price for shipping method with handling fee per package + * + * @param float $cost + * @param string $handlingType + * @param float $handlingFee + * @return float + */ + protected function _getPerpackagePrice($cost, $handlingType, $handlingFee) + { + if ($handlingType == Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_PERCENT) { + return $cost + ($cost * $this->_numBoxes * $handlingFee / 100); + } + + return $cost + $this->_numBoxes * $handlingFee; + } + + /** + * Do request to shipment + * + * @param Mage_Shipping_Model_Shipment_Request $request + * @return Varien_Object + */ + public function requestToShipment(Mage_Shipping_Model_Shipment_Request $request) + { + $packages = $request->getPackages(); + if (!is_array($packages) || !$packages) { + Mage::throwException(Mage::helper('usa')->__('No packages for request')); + } + $result = $this->_doShipmentRequest($request); + + $response = new Varien_Object(array( + 'info' => array(array( + 'tracking_number' => $result->getTrackingNumber(), + 'label_content' => $result->getShippingLabelContent() + )) + )); + + $request->setMasterTrackingId($result->getTrackingNumber()); + + return $response; + } + + /** + * Check if shipping is domestic + * + * @param string $origCountryCode + * @param string $destCountryCode + * @return bool + */ + protected function _checkDomesticStatus($origCountryCode, $destCountryCode) + { + $this->_isDomestic = false; + + $origCountry = (string)$this->getCountryParams($origCountryCode)->name; + $destCountry = (string)$this->getCountryParams($destCountryCode)->name; + $isDomestic = (string)$this->getCountryParams($destCountryCode)->domestic; + + if ($origCountry == $destCountry && $isDomestic) { + $this->_isDomestic = true; + } + + return $this->_isDomestic; + } +} diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Contenttype.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Contenttype.php new file mode 100644 index 0000000..288bedd --- /dev/null +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Contenttype.php @@ -0,0 +1,50 @@ + + */ +class Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Contenttype +{ + /** + * Returns array to be used in multiselect on back-end + * + * @return array + */ + public function toOptionArray() + { + return array( + array('label' => Mage::helper('usa')->__('Documents'), + 'value' => Mage_Usa_Model_Shipping_Carrier_Dhl_International::DHL_CONTENT_TYPE_DOC), + array('label' => Mage::helper('usa')->__('Non documents'), + 'value' => Mage_Usa_Model_Shipping_Carrier_Dhl_International::DHL_CONTENT_TYPE_NON_DOC), + ); + } +} diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Abstract.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Abstract.php new file mode 100644 index 0000000..8fe3137 --- /dev/null +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Abstract.php @@ -0,0 +1,72 @@ + + */ +abstract class Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Abstract +{ + /** + * Carrier Product Type Indicator + * + * @var string $_contentType + */ + protected $_contentType; + + /** + * Show 'none' in methods list or not; + * + * @var bool + */ + protected $_noneMethod = false; + + /** + * Returns array to be used in multiselect on back-end + * + * @return array + */ + public function toOptionArray() + { + /* @var $carrierModel Mage_Usa_Model_Shipping_Carrier_Dhl_International */ + $carrierModel = Mage::getSingleton('usa/shipping_carrier_dhl_international'); + $dhlProducts = $carrierModel->getDhlProducts($this->_contentType); + + $options = array(); + foreach ($dhlProducts as $code => $title) { + $options[] = array('value' => $code, 'label' => $title); + } + + if ($this->_noneMethod) { + array_unshift($options, array('value' => '', 'label' => Mage::helper('usa')->__('None'))); + } + + return $options; + } +} diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Doc.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Doc.php new file mode 100644 index 0000000..2fc825d --- /dev/null +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Doc.php @@ -0,0 +1,43 @@ + + */ +class Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Doc + extends Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Abstract +{ + /** + * Carrier Product Type Indicator + * + * @var string $_contentType + */ + protected $_contentType = Mage_Usa_Model_Shipping_Carrier_Dhl_International::DHL_CONTENT_TYPE_DOC; +} diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freedoc.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freedoc.php new file mode 100644 index 0000000..577024e --- /dev/null +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freedoc.php @@ -0,0 +1,50 @@ + + */ +class Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Freedoc + extends Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Abstract +{ + /** + * Carrier Product Type Indicator + * + * @var string $_contentType + */ + protected $_contentType = Mage_Usa_Model_Shipping_Carrier_Dhl_International::DHL_CONTENT_TYPE_DOC; + + /** + * Show 'none' in methods list or not; + * + * @var bool + */ + protected $_noneMethod = true; +} diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freenondoc.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freenondoc.php new file mode 100644 index 0000000..10cffcf --- /dev/null +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freenondoc.php @@ -0,0 +1,50 @@ + + */ +class Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Freenondoc + extends Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Abstract +{ + /** + * Carrier Product Type Indicator + * + * @var string $_contentType + */ + protected $_contentType = Mage_Usa_Model_Shipping_Carrier_Dhl_International::DHL_CONTENT_TYPE_NON_DOC; + + /** + * Show 'none' in methods list or not; + * + * @var bool + */ + protected $_noneMethod = true; +} diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Nondoc.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Nondoc.php new file mode 100644 index 0000000..e370db4 --- /dev/null +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Nondoc.php @@ -0,0 +1,43 @@ + + */ +class Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Nondoc + extends Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Abstract +{ + /** + * Carrier Product Type Indicator + * + * @var string $_contentType + */ + protected $_contentType = Mage_Usa_Model_Shipping_Carrier_Dhl_International::DHL_CONTENT_TYPE_NON_DOC; +} diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Size.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Size.php new file mode 100644 index 0000000..88402b5 --- /dev/null +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Size.php @@ -0,0 +1,51 @@ + + */ +class Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Size +{ + /** + * Returns array to be used in multiselect on back-end + * + * @return array + */ + public function toOptionArray() + { + $unitArr = Mage::getSingleton('usa/shipping_carrier_dhl_international')->getCode('size'); + + $returnArr = array(); + foreach ($unitArr as $key => $val) { + $returnArr[] = array('value' => $key, 'label' => $val); + } + return $returnArr; + } +} diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Unitofmeasure.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Unitofmeasure.php new file mode 100644 index 0000000..b319955 --- /dev/null +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Unitofmeasure.php @@ -0,0 +1,51 @@ + + */ +class Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Unitofmeasure +{ + /** + * Returns array to be used in multiselect on back-end + * + * @return array + */ + public function toOptionArray() + { + $unitArr = Mage::getSingleton('usa/shipping_carrier_dhl_international')->getCode('unit_of_measure'); + + $returnArr = array(); + foreach ($unitArr as $key => $val) { + $returnArr[] = array('value' => $key, 'label' => $val); + } + return $returnArr; + } +} diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf.php new file mode 100644 index 0000000..be9fbcf --- /dev/null +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf.php @@ -0,0 +1,118 @@ + + */ +class Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf +{ + /** + * Label Information + * + * @var SimpleXMLElement + */ + protected $_info; + + /** + * Shipment Request + * + * @var Mage_Shipping_Model_Shipment_Request + */ + protected $_request; + + /** + * Dhl International Label Creation Class constructor + * + * @param array $arguments + */ + public function __construct(array $arguments) + { + $this->_info = $arguments['info']; + $this->_request = $arguments['request']; + } + + /** + * Create Label + * + * @return string + * @throws Zend_Pdf_Exception + * @throws InvalidArgumentException + */ + public function render() + { + $pdf = new Zend_Pdf(); + + $pdfBuilder = new Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder(); + + $template = new Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page(Zend_Pdf_Page::SIZE_A4_LANDSCAPE); + $pdfBuilder->setPage($template) + ->addProductName((string)$this->_info->ProductShortName) + ->addProductContentCode((string)$this->_info->ProductContentCode) + //->addUnitId({unitId}) + //->addReferenceData({referenceData}) + ->addSenderInfo($this->_info->Shipper) + ->addOriginInfo((string)$this->_info->OriginServiceArea->ServiceAreaCode) + ->addReceiveInfo($this->_info->Consignee) + ->addDestinationFacilityCode( + (string)$this->_info->Consignee->CountryCode, + (string)$this->_info->DestinationServiceArea->ServiceAreaCode, + (string)$this->_info->DestinationServiceArea->FacilityCode + ) + ->addServiceFeaturesCodes() + ->addDeliveryDateCode() + ->addShipmentInformation($this->_request->getOrderShipment()) + ->addDateInfo($this->_info->ShipmentDate) + ->addWeightInfo((string)$this->_info->ChargeableWeight, (string)$this->_info->WeightUnit) + ->addWaybillBarcode((string)$this->_info->AirwayBillNumber, (string)$this->_info->Barcodes->AWBBarCode) + ->addRoutingBarcode( + (string)$this->_info->DHLRoutingCode, + (string)$this->_info->DHLRoutingDataId, + (string)$this->_info->Barcodes->DHLRoutingBarCode + ) + ->addBorder(); + + $packages = array_values($this->_request->getPackages()); + $i = 0; + foreach ($this->_info->Pieces->Piece as $piece) { + $page = new Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page($template); + $pdfBuilder->setPage($page) + ->addPieceNumber((int)$piece->PieceNumber, (int)$this->_info->Piece) + ->addContentInfo($packages[$i]) + ->addPieceIdBarcode( + (string)$piece->DataIdentifier, + (string)$piece->LicensePlate, + (string)$piece->LicensePlateBarCode + ); + array_push($pdf->pages, $page); + $i++; + } + return $pdf->render(); + } +} diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/Page.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/Page.php new file mode 100644 index 0000000..254ae7b --- /dev/null +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/Page.php @@ -0,0 +1,150 @@ + + */ +class Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page extends Zend_Pdf_Page +{ + /** + * Text align constants + */ + const ALIGN_RIGHT = 'right'; + const ALIGN_LEFT = 'left'; + const ALIGN_CENTER = 'center'; + + /** + * Dhl International Label Creation Class Pdf Page constructor + * Create/Make a copy of pdf page + * + * @param Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page|string $param1 + * @param null $param2 + * @param null $param3 + */ + public function __construct($param1, $param2 = null, $param3 = null) + { + if ($param1 instanceof Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page + && $param2 === null && $param3 === null + ) { + $this->_contents = $param1->getContents(); + } + parent::__construct($param1, $param2, $param3); + } + + /** + * Get PDF Page contents + * + * @return string + */ + public function getContents() + { + return $this->_contents; + } + + /** + * Calculate the width of given text in points taking into account current font and font-size + * + * @param string $text + * @param Zend_Pdf_Resource_Font $font + * @param float $font_size + * @return float + */ + public function getTextWidth($text, Zend_Pdf_Resource_Font $font, $font_size) + { + $drawing_text = iconv('', 'UTF-16BE', $text); + $characters = array(); + for ($i = 0; $i < strlen($drawing_text); $i++) { + $characters[] = (ord($drawing_text[$i++]) << 8) | ord($drawing_text[$i]); + } + $glyphs = $font->glyphNumbersForCharacters($characters); + $widths = $font->widthsForGlyphs($glyphs); + $text_width = (array_sum($widths) / $font->getUnitsPerEm()) * $font_size; + return $text_width; + } + + /** + * Draw a line of text at the specified position. + * + * @param string $text + * @param float $x + * @param float $y + * @param string $charEncoding (optional) Character encoding of source text. + * Defaults to current locale. + * @param $align + * @throws Zend_Pdf_Exception + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page + */ + public function drawText($text, $x, $y, $charEncoding = '', $align = self::ALIGN_LEFT) + { + $left = null; + switch ($align) { + case self::ALIGN_LEFT: + $left = $x; + break; + + case self::ALIGN_CENTER: + $textWidth = $this->getTextWidth($text, $this->getFont(), $this->getFontSize()); + $left = $x - ($textWidth / 2); + break; + + case self::ALIGN_RIGHT: + $textWidth = $this->getTextWidth($text, $this->getFont(), $this->getFontSize()); + $left = $x - $textWidth; + break; + } + return parent::drawText($text, $left, $y, $charEncoding); + } + + /** + * Draw a text paragraph taking into account the maximum number of symbols in a row. + * If line is longer - spit it. + * + * @param array $lines + * @param int $x + * @param int $y + * @param int $maxWidth - number of symbols + * @param string $align + * @throws Zend_Pdf_Exception + * @return float + */ + public function drawLines($lines, $x, $y, $maxWidth, $align = self::ALIGN_LEFT) + { + foreach ($lines as $line) { + if (strlen($line) > $maxWidth) { + $subLines = Mage::helper('core/string')->str_split($line, $maxWidth, true, true); + $y = $this->drawLines(array_filter($subLines), $x, $y, $maxWidth, $align); + continue; + } + $this->drawText($line, $x, $y, null, $align); + $y -= ceil($this->getFontSize()); + } + return $y; + } +} diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/PageBuilder.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/PageBuilder.php new file mode 100644 index 0000000..0bf6537 --- /dev/null +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/PageBuilder.php @@ -0,0 +1,666 @@ + + */ +class Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder +{ + /** + * X coordinate of a block + */ + const X_INDENT = 60; + + /** + * Y coordinate of a block + */ + const Y_INDENT = 15; + + /** + * Pdf Page Instance + * + * @var Zend_Pdf_Page + */ + protected $_page; + + /** + * Create font instances + */ + public function __construct() + { + $this->_fontNormal = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA); + $this->_fontBold = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD); + } + + /** + * Get Page + * + * @return Zend_Pdf_Page + */ + public function getPage() + { + return $this->_page; + } + + /** + * Set Page + * + * @param Zend_Pdf_Page $page + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder + */ + public function setPage(Zend_Pdf_Page $page) + { + $this->_page = $page; + return $this; + } + + /** + * Calculate x coordinate with identation + * + * @param int $pt + * @return int + */ + protected function _x($pt) + { + return $pt + self::X_INDENT; + } + + /** + * Calculate y coordinate with identation + * + * @param int $pt + * @return int + */ + protected function _y($pt) + { + return 595 - self::Y_INDENT - $pt; + } + + /** + * Add Border + * + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page + * @throws Zend_Pdf_Exception + */ + public function addBorder() + { + $x = $this->_x(0); + $y = $this->_y(0); + + $image = new Zend_Pdf_Resource_Image_Jpeg(Mage::getBaseDir('media') . DS . 'dhl' . DS . 'logo.jpg'); + $this->_page->drawImage($image, $x + 191, $this->_y(27), $x + 287, $this->_y(1)); + + /* Vertical borders */ + $this->_page->drawLine($x, $y, $x, $this->_y(568)); + $this->_page->drawLine($x + 287.5, $y, $x + 287.5, $this->_y(568)); + $this->_page->drawLine($x + 139.5, $y, $x + 139.5, $this->_y(28)); + $this->_page->drawLine($x + 190.5, $y, $x + 190.5, $this->_y(28)); + + /* Horisontal borders */ + $this->_page->drawLine($x, $y, $x + 288, $y); + $this->_page->drawLine($x, $this->_y(28), $x + 288, $this->_y(28)); + $this->_page->drawLine($x, $this->_y(80.5), $x + 288, $this->_y(80.5)); + $this->_page->drawLine($x, $this->_y(164), $x + 288, $this->_y(164)); + $this->_page->drawLine($x, $this->_y(194), $x + 288, $this->_y(194)); + $this->_page->drawLine($x, $this->_y(217.5), $x + 288, $this->_y(217.5)); + $this->_page->drawLine($x, $this->_y(245.5), $x + 288, $this->_y(245.5)); + $this->_page->drawLine($x, $this->_y(568.5), $x + 288, $this->_y(568.5)); + + $this->_page->setLineWidth(0.3); + $x = $this->_x(3); + $y = $this->_y(83); + $this->_page->drawLine($x, $y, $x + 10, $y); + $this->_page->drawLine($x, $y, $x, $y - 10); + + $x = $this->_x(3); + $y = $this->_y(161); + $this->_page->drawLine($x, $y, $x + 10, $y); + $this->_page->drawLine($x, $y, $x, $y + 10); + + $x = $this->_x(285); + $y = $this->_y(83); + $this->_page->drawLine($x, $y, $x - 10, $y); + $this->_page->drawLine($x, $y, $x, $y - 10); + + $x = $this->_x(285); + $y = $this->_y(161); + $this->_page->drawLine($x, $y, $x - 10, $y); + $this->_page->drawLine($x, $y, $x, $y + 10); + + return $this; + } + + /** + * Add Product Name + * + * @param string $name + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder + * @throws InvalidArgumentException + * @throws Zend_Pdf_Exception + */ + public function addProductName($name) + { + $this->_page->saveGS(); + $this->_page->setFont($this->_fontBold, 9); + if (!strlen($name)) { + throw new InvalidArgumentException(Mage::helper('usa')->__('Product name is missing')); + } + $this->_page->drawText($name, $this->_x(8), $this->_y(12)); + $this->_page->restoreGS(); + return $this; + } + + /** + * Add Product Content Code + * + * @param string $code + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder + * @throws Zend_Pdf_Exception + * @throws InvalidArgumentException + */ + public function addProductContentCode($code) + { + $this->_page->saveGS(); + $codes = array( + 'TDK' => 0, 'TDE' => 1, 'TDL' => 0, 'TDM' => 1, 'TDT' => 0, + 'TDY' => 1, 'XPD' => 0, 'DOX' => 0, 'WPX' => 1, 'ECX' => 0, + 'DOM' => 0 + ); + if (!key_exists($code, $codes)) { + throw new InvalidArgumentException(Mage::helper('usa')->__('Product content code is invalid')); + } + $font = null; + if ($codes[$code]) { + $this->_page->drawRectangle( + $this->_x(140), + $this->_y(0), + $this->_x(190), + $this->_y(28), + Zend_Pdf_Page::SHAPE_DRAW_FILL + ); + $this->_page->setFillColor(new Zend_Pdf_Color_Html("#ffffff")); + $font = $this->_fontBold; + } else { + $font = $this->_fontNormal; + } + $this->_page->setFont($font, 17); + $this->_page->drawText($code, $this->_x(146), $this->_y(21)); + $this->_page->restoreGS(); + return $this; + } + + /** + * Add Unit Id + * + * @param int $id + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page + * @throws Zend_Pdf_Exception + */ + public function addUnitId($id) + { + $this->_page->saveGS(); + $this->_page->setFont($this->_fontNormal, 6); + + $this->_page->drawText('Unit ID', $this->_x(8), $this->_y(20)); + $this->_page->restoreGS(); + return $this; + } + + /** + * Add Reference Data + * + * @param $data + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page + * @throws Zend_Pdf_Exception + */ + public function addReferenceData($data) + { + $this->_page->saveGS(); + $this->_page->setFont($this->_fontNormal, 6); + $this->_page->drawText('GREF', $this->_x(80), $this->_y(20)); + //TODO: Add reference data rendering + $this->_page->restoreGS(); + return $this; + } + + /** + * Add Sender Info + * + * @param SimpleXMLElement $sender + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder + * @throws InvalidArgumentException + * @throws Zend_Pdf_Exception + */ + public function addSenderInfo(SimpleXMLElement $sender) + { + $this->_page->saveGS(); + $this->_page->setFont($this->_fontNormal, 6); + $this->_page->drawText('From:', $this->_x(8), $this->_y(36)); + $contactName = implode(' ', array_filter(array((string)$sender->CompanyName, + (string)$sender->Contact->PersonName)) + ); + if (!$contactName) { + throw new InvalidArgumentException(Mage::helper('usa')->__('Sender contact name is missing')); + } + $this->_page->drawText($contactName, $this->_x(25), $this->_y(36)); + + $phoneNumber = implode(' ', array_filter(array((string)$sender->Contact->PhoneNumber, + (string)$sender->Contact->PhoneExtension)) + ); + $phoneNumber = $phoneNumber ? "Phone: " . $phoneNumber : null; + $pageY = $this->_drawSenderAddress($sender->AddressLine, $phoneNumber); + + $divisionCode = (string)(strlen($sender->DivisionCode) ? $sender->DivisionCode . ' ' : null); + $cityInfo = implode(' ', array_filter(array($sender->City, $divisionCode, $sender->PostalCode))); + if (!strlen($cityInfo)) { + throw new InvalidArgumentException(Mage::helper('usa')->__('Sender city info is missing')); + } + $this->_page->drawText($cityInfo, $this->_x(25), $pageY); + + $this->_page->setFont($this->_fontBold, 6); + $countryInfo = (string)(($sender->CountryName) ? $sender->CountryName : $sender->CountryCode); + if (!strlen($countryInfo)) { + throw new InvalidArgumentException(Mage::helper('usa')->__('Sender country info is missing')); + } + $this->_page->drawText($countryInfo, $this->_x(25), $pageY - $this->_page->getFontSize()); + + $this->_page->restoreGS(); + return $this; + } + + /** + * Draw Sender Address + * + * @param SimpleXMLElement $addressLines + * @param string $phoneNumber + * @return float + * @throws Zend_Pdf_Exception + */ + protected function _drawSenderAddress(SimpleXMLElement $addressLines, $phoneNumber) + { + $lines = array(); + foreach ($addressLines as $line) { + $lines [] = $line; + } + + $pageY = 0; + if (strlen($lines[0]) > 28) { + $firstLine = array_shift($lines); + $pageY = $this->_page->drawLines(array($firstLine), $this->_x(25), $this->_y(42), 28); + $this->_page->drawText($phoneNumber, $this->_x(103), $this->_y(42)); + } else { + $pageY = $this->_y(42); + $lineLength = $this->_page->getTextWidth( + $lines[0] . ' ', $this->_page->getFont(), $this->_page->getFontSize() + ); + $this->_page->drawText($phoneNumber, $this->_x(25 + $lineLength), $this->_y(42)); + } + + return $this->_page->drawLines($lines, $this->_x(25), $pageY, 49); + } + + /** + * Add Origin Info + * + * @param string $serviceAreaCode + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder + * @throws InvalidArgumentException + * @throws Zend_Pdf_Exception + */ + public function addOriginInfo($serviceAreaCode) + { + if (strlen(!$serviceAreaCode)) { + throw new InvalidArgumentException(Mage::helper('usa')->__('Origin serviceAreaCode is missing')); + } + $this->_page->saveGS(); + $this->_page->setFont($this->_fontNormal, 6); + $this->_page->drawText("Origin:", $this->_x(260), $this->_y(36)); + $this->_page->setFont($this->_fontBold, 9); + $this->_page->drawText($serviceAreaCode, $this->_x(260), $this->_y(45)); + + $this->_page->restoreGS(); + return $this; + } + + /** + * Add Receive Info + * + * @param SimpleXMLElement $consignee + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder + * @throws Zend_Pdf_Exception + */ + public function addReceiveInfo(SimpleXMLElement $consignee) + { + $this->_page->saveGS(); + + $this->_page->setFont($this->_fontNormal, 9); + $this->_page->drawText("To:", $this->_x(5), $this->_y(92)); + $this->_page->drawText($consignee->CompanyName, $this->_x(20), $this->_y(90)); + $y = $this->_page->drawLines($consignee->AddressLine, $this->_x(19), $this->_y(100), 50); + + $this->_page->setFont($this->_fontBold, 11); + $cityInfo = implode(' ', array_filter(array($consignee->PostalCode, $consignee->City, + $consignee->DivisionCode)) + ); + $y = min($y - 3, 460); + $this->_page->drawLines(array($cityInfo, $consignee->CountryName), $this->_x(20), $y, 44); + + $this->_page->setFont($this->_fontNormal, 6); + $this->_page->drawText('Contact:', $this->_x(260), $this->_y(90)); + + $y = $this->_page->drawLines(array($consignee->Contact->PersonName), $this->_x(283), $this->_y(98), 25, + Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page::ALIGN_RIGHT + ); + $phoneNumber = implode(' ', array_filter(array($consignee->Contact->PhoneNumber, + $consignee->Contact->PhoneExtension)) + ); + $this->_page->drawText($phoneNumber, $this->_x(283), $y, null, + Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page::ALIGN_RIGHT + ); + + $this->_page->restoreGS(); + return $this; + } + + /** + * Add Destination Facility Code + * + * @param string $countryCode + * @param string $serviceAreaCode + * @param string $facilityCode + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder + * @throws InvalidArgumentException + * @throws Zend_Pdf_Exception + */ + public function addDestinationFacilityCode($countryCode, $serviceAreaCode, $facilityCode) + { + $this->_page->saveGS(); + $this->_page->setFont($this->_fontNormal, 20); + $code = implode('-', array_filter(array($countryCode, $serviceAreaCode, $facilityCode))); + + if (!strlen($code)) { + throw new InvalidArgumentException(Mage::helper('usa')->__('Destination facility code is empty')); + } + $this->_page->drawText($code, $this->_x(144), $this->_y(186), null, + Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page::ALIGN_CENTER + ); + + $this->_page->restoreGS(); + return $this; + } + + /** + * Add Service Features Codes + * + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder + * @throws Zend_Pdf_Exception + */ + public function addServiceFeaturesCodes() + { + $this->_page->saveGS(); + $this->_page->drawRectangle($this->_x(0), $this->_y(195), $this->_x(218), $this->_y(217), + Zend_Pdf_Page::SHAPE_DRAW_FILL + ); + $this->_page->restoreGS(); + return $this; + } + + /** + * Add Delivery Date Code + * + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder + * @throws Zend_Pdf_Exception + */ + public function addDeliveryDateCode() + { + $this->_page->saveGS(); + + $this->_page->setFont($this->_fontNormal, 6); + $this->_page->drawText('Day:', $this->_x(220), $this->_y(201)); + $this->_page->drawText('Time:', $this->_x(250), $this->_y(201)); + + $this->_page->setFont($this->_fontNormal, 20); + + $this->_page->restoreGS(); + return $this; + } + + /** + * Add Shipment Information + * + * @param Mage_Sales_Model_Order_Shipment $data + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page + * @throws Exception + */ + public function addShipmentInformation($data) + { + $this->_page->saveGS(); + $this->_page->setFont($this->_fontNormal, 6); + + $refCode = $data->getOrder()->getIncrementId(); + if (!$refCode) { + throw new InvalidArgumentException(Mage::helper('usa')->__('Reference code is missing')); + } + $this->_page->drawText('Ref Code: ' . Mage::helper('usa')->__('Order #%s', $refCode), $this->_x(8), + $this->_y(224) + ); + $this->_page->restoreGS(); + return $this; + } + + /** + * Add Date Info + * @param string $date + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder + * @throws Zend_Pdf_Exception + */ + public function addDateInfo($date) + { + $this->_page->saveGS(); + + $this->_page->setFont($this->_fontNormal, 6); + $this->_page->drawText('Date:', $this->_x(160), $this->_y(224)); + $this->_page->drawText($date, $this->_x(150), $this->_y(231)); + + $this->_page->restoreGS(); + return $this; + } + + /** + * Add Weight Info + * + * @param string $weight + * @param string $unit + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder + * @throws InvalidArgumentException + * @throws Zend_Pdf_Exception + */ + public function addWeightInfo($weight, $unit) + { + $this->_page->saveGS(); + + $units = array("K" => 'kg', "L" => 'lb'); + if (!isset($units[$unit])) { + throw new InvalidArgumentException(Mage::helper('usa')->__('Weight unit is invalid')); + } + $unit = $units[$unit]; + + $this->_page->setFont($this->_fontNormal, 6); + $this->_page->drawText('Shpt Weight:', $this->_x(196), $this->_y(224)); + $this->_page->setFont($this->_fontBold, 11); + $this->_page->drawText($weight . ' ' . $unit, $this->_x(195), $this->_y(234)); + + $this->_page->restoreGS(); + return $this; + } + + /** + * Add Content: Shipment Description + * + * @param array $package + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder + * @throws Exception + */ + public function addContentInfo($package) + { + $this->_page->saveGS(); + $this->_page->setFont($this->_fontNormal, 6); + if (empty($package)) { + throw new InvalidArgumentException(Mage::helper('usa')->__('Package content is missing')); + } + + $x = 225; + $y = 300; + $this->_page->drawText('Content: ', $this->_x($x), $this->_y($y)); + $i = 0; + foreach ($package['items'] as $item) { + $i++; + $this->_page->drawText(substr($item['name'], 0, 20), $this->_x($x), $this->_y($y += 6)); + if ($i == 12) { + break; + } + } + $this->_page->restoreGS(); + return $this; + } + + /** + * Add Waybill Barcode + * + * @param string $number + * @param string $barCode + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder + * @throws InvalidArgumentException + * @throws Zend_Pdf_Exception + */ + public function addWaybillBarcode($number, $barCode) + { + $this->_page->saveGS(); + + if(!strlen($number) || !strlen($barCode)) { + throw new InvalidArgumentException(Mage::helper('usa')->__('Waybill barcode information is missing')); + } + $image = new Zend_Pdf_Resource_Image_Png("data://image/png;base64," . $barCode); + $this->_page->drawImage($image, $this->_x(0), $this->_y(296), $this->_x(232), $this->_y(375)); + + $this->_page->setFont($this->_fontNormal, 9); + $number = substr($number, 0, 2) . ' ' . substr($number, 2, 4) . ' ' . substr($number, 6, 4); + $this->_page->drawText("WAYBILL " . $number, $this->_x(13.5), $this->_y(382)); + + $this->_page->restoreGS(); + return $this; + } + + /** + * Add Routing Barcode + * + * @param string $routingCode + * @param string $id + * @param string $barCode + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder + * @throws InvalidArgumentException + * @throws Zend_Pdf_Exception + */ + public function addRoutingBarcode($routingCode, $id, $barCode) + { + $this->_page->saveGS(); + + if(!$barCode) { + throw new InvalidArgumentException(Mage::helper('usa')->__('Routing barcode is missing')); + } + + $image = new Zend_Pdf_Resource_Image_Png("data://image/png;base64," . $barCode); + $this->_page->drawImage($image, $this->_x(0), $this->_y(386), $this->_x(232), $this->_y(465)); + + $this->_page->setFont($this->_fontNormal, 9); + $routingText = '(' . $id . ')' . $routingCode; + $this->_page->drawText($routingText, $this->_x(12), $this->_y(472)); + + $this->_page->restoreGS(); + return $this; + } + + /** + * Add Piece Id Barcode + * + * @param string $dataIdentifier + * @param string $licensePlate + * @param string $barCode + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder + * @throws InvalidArgumentException + * @throws Zend_Pdf_Exception + */ + public function addPieceIdBarcode($dataIdentifier, $licensePlate, $barCode) + { + $this->_page->saveGS(); + + if (!strlen($barCode)) { + throw new InvalidArgumentException(Mage::helper('usa')->__('Piece Id barcode is missing')); + } + + $image = new Zend_Pdf_Resource_Image_Png('data://image/png;base64,' . $barCode); + $this->_page->drawImage($image, $this->_x(29), $this->_y(476), $this->_x(261), $this->_y(555)); + + $this->_page->setFont($this->_fontNormal, 9); + $routingText = '(' . $dataIdentifier . ')' . $licensePlate; + $this->_page->drawText($routingText, $this->_x(144), $this->_y(563), '', + Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page::ALIGN_CENTER + ); + + $this->_page->restoreGS(); + return $this; + } + + /** + * Add Piece Number + * + * @param int $pieceNumber + * @param int $piecesTotal + * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder + * @throws InvalidArgumentException + * @throws Zend_Pdf_Exception + */ + public function addPieceNumber($pieceNumber, $piecesTotal) + { + $this->_page->saveGS(); + + if (!$pieceNumber || !$piecesTotal) { + throw new InvalidArgumentException(Mage::helper('usa')->__('Piece number information is missing')); + } + + $this->_page->setFont($this->_fontNormal, 6); + $this->_page->drawText('Piece:', $this->_x(256), $this->_y(224)); + $this->_page->setFont($this->_fontBold, 11); + $this->_page->drawText($pieceNumber . '/' . $piecesTotal, $this->_x(256), $this->_y(234)); + + $this->_page->restoreGS(); + return $this; + } +} diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Dutypaymenttype.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Dutypaymenttype.php index e6ddd65..2926728 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Dutypaymenttype.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Dutypaymenttype.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Freemethod.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Freemethod.php index 9454bc0..7817103 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Freemethod.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Freemethod.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Method.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Method.php index 94adc99..859066e 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Method.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Method.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Rounding.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Rounding.php index 35a0f71..c268165 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Rounding.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Rounding.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Value.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Value.php index 8429c6a..d906a8c 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Value.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Value.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Shipmenttype.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Shipmenttype.php index 8f039a0..e2f832c 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Shipmenttype.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Shipmenttype.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php index cfe341f..0025939 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php @@ -20,45 +20,182 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** - * Fedex shipping rates estimation + * Fedex shipping implementation * * @category Mage * @package Mage_Usa - * @author Magento Core Team + * @author Magento Core Team */ class Mage_Usa_Model_Shipping_Carrier_Fedex extends Mage_Usa_Model_Shipping_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface { - protected $_code = 'fedex'; + /** + * Code of the carrier + * + * @var string + */ + const CODE = 'fedex'; + + /** + * Purpose of rate request + * + * @var string + */ + const RATE_REQUEST_GENERAL = 'general'; + + /** + * Purpose of rate request + * + * @var string + */ + const RATE_REQUEST_SMARTPOST = 'SMART_POST'; + /** + * Code of the carrier + * + * @var string + */ + protected $_code = self::CODE; + + /** + * Rate request data + * + * @var Mage_Shipping_Model_Rate_Request|null + */ protected $_request = null; + /** + * Raw rate request data + * + * @var Varien_Object|null + */ + protected $_rawRequest = null; + + /** + * Rate result data + * + * @var Mage_Shipping_Model_Rate_Result|null + */ protected $_result = null; - protected $_gatewayUrl = 'https://gateway.fedex.com/GatewayDC'; + /** + * Path to wsdl file of rate service + * + * @var string + */ + protected $_rateServiceWsdl; + + /** + * Path to wsdl file of ship service + * + * @var string + */ + protected $_shipServiceWsdl = null; + + /** + * Path to wsdl file of track service + * + * @var string + */ + protected $_trackServiceWsdl = null; + + /** + * Container types that could be customized for FedEx carrier + * + * @var array + */ + protected $_customizableContainerTypes = array('YOUR_PACKAGING'); + + public function __construct() + { + parent::__construct(); + $wsdlBasePath = Mage::getModuleDir('etc', 'Mage_Usa') . DS . 'wsdl' . DS . 'FedEx' . DS; + $this->_shipServiceWsdl = $wsdlBasePath . 'ShipService_v10.wsdl'; + $this->_rateServiceWsdl = $wsdlBasePath . 'RateService_v10.wsdl'; + $this->_trackServiceWsdl = $wsdlBasePath . 'TrackService_v5.wsdl'; + } + /** + * Create soap client with selected wsdl + * + * @param string $wsdl + * @param bool|int $trace + * @return SoapClient + */ + protected function _createSoapClient($wsdl, $trace = false) + { + $client = new SoapClient($wsdl, array('trace' => $trace)); + $client->__setLocation($this->getConfigFlag('sandbox_mode') + ? 'https://wsbeta.fedex.com:443/web-services/rate' + : 'https://ws.fedex.com:443/web-services/rate' + ); + + return $client; + } + + /** + * Create rate soap client + * + * @return SoapClient + */ + protected function _createRateSoapClient() + { + return $this->_createSoapClient($this->_rateServiceWsdl); + } + + /** + * Create ship soap client + * + * @return SoapClient + */ + protected function _createShipSoapClient() + { + return $this->_createSoapClient($this->_shipServiceWsdl, 1); + } + + /** + * Create track soap client + * + * @return SoapClient + */ + protected function _createTrackSoapClient() + { + return $this->_createSoapClient($this->_trackServiceWsdl, 1); + } + + /** + * Collect and get rates + * + * @param Mage_Shipping_Model_Rate_Request $request + * @return Mage_Shipping_Model_Rate_Result|bool|null + */ public function collectRates(Mage_Shipping_Model_Rate_Request $request) { - if (!$this->getConfigFlag('active')) { + if (!$this->getConfigFlag($this->_activeFlag)) { return false; } - $this->setRequest($request); - $this->_result = $this->_getQuotes(); + $this->_getQuotes(); $this->_updateFreeMethodQuote($request); return $this->getResult(); } + /** + * Prepare and set request to this instance + * + * @param Mage_Shipping_Model_Rate_Request $request + * @return Mage_Usa_Model_Shipping_Carrier_Fedex + */ public function setRequest(Mage_Shipping_Model_Rate_Request $request) { $this->_request = $request; @@ -93,14 +230,20 @@ class Mage_Usa_Model_Shipping_Carrier_Fedex if ($request->getOrigCountry()) { $origCountry = $request->getOrigCountry(); } else { - $origCountry = Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_COUNTRY_ID, $this->getStore()); + $origCountry = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, + $request->getStoreId() + ); } $r->setOrigCountry(Mage::getModel('directory/country')->load($origCountry)->getIso2Code()); if ($request->getOrigPostcode()) { $r->setOrigPostal($request->getOrigPostcode()); } else { - $r->setOrigPostal(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_POSTCODE, $this->getStore())); + $r->setOrigPostal(Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP, + $request->getStoreId() + )); } if ($request->getDestCountryId()) { @@ -125,21 +268,300 @@ class Mage_Usa_Model_Shipping_Carrier_Fedex $r->setValue($request->getPackagePhysicalValue()); $r->setValueWithDiscount($request->getPackageValueWithDiscount()); + $r->setMeterNumber($this->getConfigData('meter_number')); + $r->setKey($this->getConfigData('key')); + $r->setPassword($this->getConfigData('password')); + + $r->setIsReturn($request->getIsReturn()); + + $r->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax()); + $this->_rawRequest = $r; return $this; } + /** + * Get result of request + * + * @return mixed + */ public function getResult() { return $this->_result; } + /** + * Get version of rates request + * + * @return array + */ + public function getVersionInfo() + { + return array( + 'ServiceId' => 'crs', + 'Major' => '10', + 'Intermediate' => '0', + 'Minor' => '0' + ); + } + + /** + * Forming request for rate estimation depending to the purpose + * + * @param string $purpose + * @return array + */ + protected function _formRateRequest($purpose) + { + $r = $this->_rawRequest; + $ratesRequest = array( + 'WebAuthenticationDetail' => array( + 'UserCredential' => array( + 'Key' => $r->getKey(), + 'Password' => $r->getPassword() + ) + ), + 'ClientDetail' => array( + 'AccountNumber' => $r->getAccount(), + 'MeterNumber' => $r->getMeterNumber() + ), + 'Version' => $this->getVersionInfo(), + 'RequestedShipment' => array( + 'DropoffType' => $r->getDropoffType(), + 'ShipTimestamp' => date('c'), + 'PackagingType' => $r->getPackaging(), + 'TotalInsuredValue' => array( + 'Amount' => $r->getValue(), + 'Currency' => $this->getCurrencyCode() + ), + 'Shipper' => array( + 'Address' => array( + 'PostalCode' => $r->getOrigPostal(), + 'CountryCode' => $r->getOrigCountry() + ) + ), + 'Recipient' => array( + 'Address' => array( + 'PostalCode' => $r->getDestPostal(), + 'CountryCode' => $r->getDestCountry(), + 'Residential' => (bool)$this->getConfigData('residence_delivery') + ) + ), + 'ShippingChargesPayment' => array( + 'PaymentType' => 'SENDER', + 'Payor' => array( + 'AccountNumber' => $r->getAccount(), + 'CountryCode' => $r->getOrigCountry() + ) + ), + 'CustomsClearanceDetail' => array( + 'CustomsValue' => array( + 'Amount' => $r->getValue(), + 'Currency' => $this->getCurrencyCode() + ) + ), + 'RateRequestTypes' => 'LIST', + 'PackageCount' => '1', + 'PackageDetail' => 'INDIVIDUAL_PACKAGES', + 'RequestedPackageLineItems' => array( + '0' => array( + 'Weight' => array( + 'Value' => (float)$r->getWeight(), + 'Units' => 'LB' + ), + 'GroupPackageCount' => 1, + ) + ) + ) + ); + + if ($purpose == self::RATE_REQUEST_GENERAL) { + $ratesRequest['RequestedShipment']['RequestedPackageLineItems'][0]['InsuredValue'] = array( + 'Amount' => $r->getValue(), + 'Currency' => $this->getCurrencyCode() + ); + } else if ($purpose == self::RATE_REQUEST_SMARTPOST) { + $ratesRequest['RequestedShipment']['ServiceType'] = self::RATE_REQUEST_SMARTPOST; + $ratesRequest['RequestedShipment']['SmartPostDetail'] = array( + 'Indicia' => ((float)$r->getWeight() >= 1) ? 'PARCEL_SELECT' : 'PRESORTED_STANDARD', + 'HubId' => $this->getConfigData('smartpost_hubid') + ); + } + + return $ratesRequest; + } + + /** + * Makes remote request to the carrier and returns a response + * + * @param string $purpose + * @return mixed + */ + protected function _doRatesRequest($purpose) + { + $ratesRequest = $this->_formRateRequest($purpose); + $requestString = serialize($ratesRequest); + $response = $this->_getCachedQuotes($requestString); + $debugData = array('request' => $ratesRequest); + if ($response === null) { + try { + $client = $this->_createRateSoapClient(); + $response = $client->getRates($ratesRequest); + $this->_setCachedQuotes($requestString, serialize($response)); + $debugData['result'] = $response; + } catch (Exception $e) { + $debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode()); + Mage::logException($e); + } + } else { + $response = unserialize($response); + $debugData['result'] = $response; + } + $this->_debug($debugData); + return $response; + } + + /** + * Do remote request for and handle errors + * + * @return Mage_Shipping_Model_Rate_Result + */ protected function _getQuotes() { - return $this->_getXmlQuotes(); + $this->_result = Mage::getModel('shipping/rate_result'); + // make separate request for Smart Post method + $allowedMethods = explode(',', $this->getConfigData('allowed_methods')); + if (in_array(self::RATE_REQUEST_SMARTPOST, $allowedMethods)) { + $response = $this->_doRatesRequest(self::RATE_REQUEST_SMARTPOST); + $preparedSmartpost = $this->_prepareRateResponse($response); + if (!$preparedSmartpost->getError()) { + $this->_result->append($preparedSmartpost); + } + } + // make general request for all methods + $response = $this->_doRatesRequest(self::RATE_REQUEST_GENERAL); + $preparedGeneral = $this->_prepareRateResponse($response); + if (!$preparedGeneral->getError() || ($this->_result->getError() && $preparedGeneral->getError())) { + $this->_result->append($preparedGeneral); + } + return $this->_result; } + /** + * Prepare shipping rate result based on response + * + * @param mixed $response + * @return Mage_Shipping_Model_Rate_Result + */ + protected function _prepareRateResponse($response) + { + $costArr = array(); + $priceArr = array(); + $errorTitle = 'Unable to retrieve tracking'; + + if (is_object($response)) { + if ($response->HighestSeverity == 'FAILURE' || $response->HighestSeverity == 'ERROR') { + $errorTitle = (string)$response->Notifications->Message; + } elseif (isset($response->RateReplyDetails)) { + $allowedMethods = explode(",", $this->getConfigData('allowed_methods')); + + if (is_array($response->RateReplyDetails)) { + foreach ($response->RateReplyDetails as $rate) { + $serviceName = (string)$rate->ServiceType; + if (in_array($serviceName, $allowedMethods)) { + $amount = $this->_getRateAmountOriginBased($rate); + $costArr[$serviceName] = $amount; + $priceArr[$serviceName] = $this->getMethodPrice($amount, $serviceName); + } + } + asort($priceArr); + } else { + $rate = $response->RateReplyDetails; + $serviceName = (string)$rate->ServiceType; + if (in_array($serviceName, $allowedMethods)) { + $amount = $this->_getRateAmountOriginBased($rate); + $costArr[$serviceName] = $amount; + $priceArr[$serviceName] = $this->getMethodPrice($amount, $serviceName); + } + } + } + } + + $result = Mage::getModel('shipping/rate_result'); + if (empty($priceArr)) { + $error = Mage::getModel('shipping/rate_result_error'); + $error->setCarrier($this->_code); + $error->setCarrierTitle($this->getConfigData('title')); + $error->setErrorMessage($errorTitle); + $error->setErrorMessage($this->getConfigData('specificerrmsg')); + $result->append($error); + } else { + foreach ($priceArr as $method=>$price) { + $rate = Mage::getModel('shipping/rate_result_method'); + $rate->setCarrier($this->_code); + $rate->setCarrierTitle($this->getConfigData('title')); + $rate->setMethod($method); + $rate->setMethodTitle($this->getCode('method', $method)); + $rate->setCost($costArr[$method]); + $rate->setPrice($price); + $result->append($rate); + } + } + return $result; + } + + /** + * Get origin based amount form response of rate estimation + * + * @param stdClass $rate + * @return null|float + */ + protected function _getRateAmountOriginBased($rate) + { + $amount = null; + $rateTypeAmounts = array(); + + if (is_object($rate)) { + // The "RATED..." rates are expressed in the currency of the origin country + foreach ($rate->RatedShipmentDetails as $ratedShipmentDetail) { + $netAmount = (string)$ratedShipmentDetail->ShipmentRateDetail->TotalNetCharge->Amount; + $rateType = (string)$ratedShipmentDetail->ShipmentRateDetail->RateType; + $rateTypeAmounts[$rateType] = $netAmount; + } + + // Order is important + $ratesOrder = array( + 'RATED_ACCOUNT_PACKAGE', + 'PAYOR_ACCOUNT_PACKAGE', + 'RATED_ACCOUNT_SHIPMENT', + 'PAYOR_ACCOUNT_SHIPMENT', + 'RATED_LIST_PACKAGE', + 'PAYOR_LIST_PACKAGE', + 'RATED_LIST_SHIPMENT', + 'PAYOR_LIST_SHIPMENT' + ); + foreach ($ratesOrder as $rateType) { + if (!empty($rateTypeAmounts[$rateType])) { + $amount = $rateTypeAmounts[$rateType]; + break; + } + } + + if (is_null($amount)) { + $amount = (string)$rate->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount; + } + } + + return $amount; + } + + /** + * Set free method request + * + * @param $freeMethod + * @return void + */ protected function _setFreeMethodRequest($freeMethod) { $r = $this->_rawRequest; @@ -148,6 +570,11 @@ class Mage_Usa_Model_Shipping_Carrier_Fedex $r->setService($freeMethod); } + /** + * Get xml quotes + * + * @return Mage_Shipping_Model_Rate_Result + */ protected function _getXmlQuotes() { $r = $this->_rawRequest; @@ -158,237 +585,37 @@ class Mage_Usa_Model_Shipping_Carrier_Fedex $xml->addAttribute('xsi:noNamespaceSchemaLocation', 'FDXRateAvailableServicesRequest.xsd'); $requestHeader = $xml->addChild('RequestHeader'); -// $requestHeader->addChild('CustomerTransactionIdentifier', 'CTIString'); - $requestHeader->addChild('AccountNumber', $r->getAccount()); -// $requestHeader->addChild('MeterNumber', '2436351'); -- my own meter number - $requestHeader->addChild('MeterNumber', '0'); -// $requestHeader->addChild('CarrierCode', 'FDXE'); -// $requestHeader->addChild('CarrierCode', 'FDXG'); - /** - * FDXE � FedEx Express - * FDXG � FedEx Ground - */ + $requestHeader->addChild('AccountNumber', $r->getAccount()); + $requestHeader->addChild('MeterNumber', '0'); $xml->addChild('ShipDate', date('Y-m-d')); -// $xml->addChild('ReturnShipmentIndicator', 'NONRETURN'); - /** - * � NONRETURN - * � PRINTRETURNLABEL - * � EMAILLABEL - */ $xml->addChild('DropoffType', $r->getDropoffType()); - /** - * � REGULARPICKUP - * � REQUESTCOURIER - * � DROPBOX - * � BUSINESSSERVICECENTER - * � STATION - * Only REGULARPICKUP, REQUESTCOURIER, and STATION are - * allowed with international freight shipping. - */ if ($r->hasService()) { $xml->addChild('Service', $r->getService()); } - /** - * One of the following FedEx Services is optional: - * � PRIORITYOVERNIGHT - * � STANDARDOVERNIGHT - * � FIRSTOVERNIGHT - * � FEDEX2DAY - * � FEDEXEXPRESSSAVER - * � INTERNATIONALPRIORITY - * � INTERNATIONALECONOMY - * � INTERNATIONALFIRST - * � FEDEX1DAYFREIGHT - * � FEDEX2DAYFREIGHT - * � FEDEX3DAYFREIGHT - * � FEDEXGROUND - * � GROUNDHOMEDELIVERY - * � INTERNATIONALPRIORITY FREIGHT - * � INTERNATIONALECONOMY FREIGHT - * � EUROPEFIRSTINTERNATIONALPRIORITY - * If provided, only that service�s estimated charges will be returned. - */ $xml->addChild('Packaging', $r->getPackaging()); - /** - * One of the following package types is required: - * � FEDEXENVELOPE - * � FEDEXPAK - * � FEDEXBOX - * � FEDEXTUBE - * � FEDEX10KGBOX - * � FEDEX25KGBOX - * � YOURPACKAGING - * If value entered is FEDEXENVELOPE, FEDEX10KGBOX, or - * FEDEX25KGBOX, an MPS rate quote is not allowed. - */ $xml->addChild('WeightUnits', 'LBS'); - /** - * � LBS - * � KGS - * LBS is required for a U.S. FedEx Express rate quote. - */ $xml->addChild('Weight', $r->getWeight()); -// $xml->addChild('ListRate', 'true'); - /** - * Optional. - * If = true or 1, list-rate courtesy quotes should be returned in addition to - * the discounted quote. - */ $originAddress = $xml->addChild('OriginAddress'); -// $originAddress->addChild('StateOrProvinceCode', 'GA'); -- ??? - $originAddress->addChild('PostalCode', $r->getOrigPostal()); - $originAddress->addChild('CountryCode', $r->getOrigCountry()); + $originAddress->addChild('PostalCode', $r->getOrigPostal()); + $originAddress->addChild('CountryCode', $r->getOrigCountry()); $destinationAddress = $xml->addChild('DestinationAddress'); -// $destinationAddress->addChild('StateOrProvinceCode', 'GA'); -- ??? - $destinationAddress->addChild('PostalCode', $r->getDestPostal()); - $destinationAddress->addChild('CountryCode', $r->getDestCountry()); + $destinationAddress->addChild('PostalCode', $r->getDestPostal()); + $destinationAddress->addChild('CountryCode', $r->getDestCountry()); $payment = $xml->addChild('Payment'); - $payment->addChild('PayorType', 'SENDER'); - /** - * Optional. - * Defaults to SENDER. - * If value other than SENDER is used, no rates will still be returned. - */ - - /** - * DIMENSIONS - * - * Dimensions / Length - * Optional. - * Only applicable if the package type is YOURPACKAGING. - * The length of a package. - * Format: Numeric, whole number - * - * Dimensions / Width - * Optional. - * Only applicable if the package type is YOURPACKAGING. - * The width of a package. - * Format: Numeric, whole number - * - * Dimensions / Height - * Optional. - * Only applicable if the package type is YOURPACKAGING. - * The height of a package. - * Format: Numeric, whole number - * - * Dimensions / Units - * Required if dimensions are entered. - * Only applicable if the package type is YOURPACKAGING. - * The valid unit of measure codes for the package dimensions are: - * IN � Inches - * CM � Centimeters - * U.S. FedEx Express must be in inches. - */ + $payment->addChild('PayorType', 'SENDER'); $declaredValue = $xml->addChild('DeclaredValue'); - $declaredValue->addChild('Value', $r->getValue()); -// $declaredValue->addChild('CurrencyCode', 'USD'); - $declaredValue->addChild('CurrencyCode', $this->getCurrencyCode()); + $declaredValue->addChild('Value', $r->getValue()); + $declaredValue->addChild('CurrencyCode', $this->getCurrencyCode()); if ($this->getConfigData('residence_delivery')) { $specialServices = $xml->addChild('SpecialServices'); - $specialServices->addChild('ResidentialDelivery', 'true'); - } - -// $specialServices = $xml->addChild('SpecialServices'); -// $specialServices->addChild('Alcohol', 'true'); -// $specialServices->addChild('DangerousGoods', 'true')->addChild('Accessibility', 'ACCESSIBLE'); - /** - * Valid values: - * ACCESSIBLE � accessible DG - * INACCESSIBLE � inaccessible DG - */ -// $specialServices->addChild('DryIce', 'true'); -// $specialServices->addChild('ResidentialDelivery', 'true'); - /** - * If = true or 1, the shipment is Residential Delivery. If Recipient Address - * is in a rural area (defined by table lookup), additional charge will be - * applied. This element is not applicable to the FedEx Home Delivery - * service. - */ -// $specialServices->addChild('InsidePickup', 'true'); -// $specialServices->addChild('InsideDelivery', 'true'); -// $specialServices->addChild('SaturdayPickup', 'true'); -// $specialServices->addChild('SaturdayDelivery', 'true'); -// $specialServices->addChild('NonstandardContainer', 'true'); -// $specialServices->addChild('SignatureOption', 'true'); - /** - * Optional. - * Specifies the Delivery Signature Option requested for the shipment. - * Valid values: - * � DELIVERWITHOUTSIGNATURE - * � INDIRECT - * � DIRECT - * � ADULT - * For FedEx Express shipments, the DELIVERWITHOUTSIGNATURE - * option will not be allowed when the following special services are - * requested: - * � Alcohol - * � Hold at Location - * � Dangerous Goods - * � Declared Value greater than $500 - */ - - /** - * HOMEDELIVERY - * - * HomeDelivery / Type - * One of the following values are required for FedEx Home Delivery - * shipments: - * � DATECERTAIN - * � EVENING - * � APPOINTMENT - * - * PackageCount - * Required for multiple-piece shipments (MPS). - * For MPS shipments, 1 piece = 1 box. - * For international Freight MPS shipments, this is the total number of - * "units." Units are the skids, pallets, or boxes that make up a freight - * shipment. - * Each unit within a shipment should have its own label. - * FDXE only applies to COD, MPS, and international. - * Valid values: 1 to 999 - */ - - /** - * VARIABLEHANDLINGCHARGES - * - * VariableHandlingCharges / Level - * Optional. - * Only applicable if valid Variable Handling Type is present. - * Apply fixed or variable handling charges at package or shipment level. - * Valid values: - * � PACKAGE - * � SHIPMENT - * The value "SHIPMENT" is applicable only on last piece of FedEx - * Ground or FedEx Express MPS shipment only. - * Note: Value "SHIPMENT" = shipment level affects the entire shipment. - * Anything else sent in Child will be ignored. - * - * VariableHandlingCharges / Type - * Optional. - * If valid value is present, a valid Variable Handling Charge is required. - * Specifies what type of Variable Handling charges to assess and on - * which amount. - * Valid values: - * � FIXED_AMOUNT - * � PERCENTAGE_OF_BASE - * � PERCENTAGE_OF_NET - * � PERCENTAGE_OF_NET_ EXCL_TAXES - * - * VariableHandlingCharges / AmountOrPercentage - * Optional. - * Required in conjunction with Variable Handling Type. - * Contains the dollar or percentage amount to be added to the Freight - * charges. Whether the amount is a dollar or percentage is based on the - * Variable Handling Type value that is included in this Request. - * Format: Two explicit decimal positions (e.g. 1.00); 10 total length - * including decimal place. - */ + $specialServices->addChild('ResidentialDelivery', 'true'); + } $xml->addChild('PackageCount', '1'); @@ -397,15 +624,6 @@ class Mage_Usa_Model_Shipping_Carrier_Fedex $responseBody = $this->_getCachedQuotes($request); if ($responseBody === null) { $debugData = array('request' => $request); - /* - $client = new Zend_Http_Client(); - $client->setUri($this->getConfigData('gateway_url')); - $client->setConfig(array('maxredirects'=>0, 'timeout'=>30)); - $client->setParameterPost($request); - $response = $client->request(); - $responseBody = $response->getBody(); - */ - try { $url = $this->getConfigData('gateway_url'); if (!$url) { @@ -432,6 +650,12 @@ class Mage_Usa_Model_Shipping_Carrier_Fedex return $this->_parseXmlResponse($responseBody); } + /** + * Prepare shipping rate result based on response + * + * @param mixed $response + * @return Mage_Shipping_Model_Rate_Result + */ protected function _parseXmlResponse($response) { $costArr = array(); @@ -452,8 +676,12 @@ class Mage_Usa_Model_Shipping_Carrier_Fedex foreach ($xml->Entry as $entry) { if (in_array((string)$entry->Service, $allowedMethods)) { - $costArr[(string)$entry->Service] = (string)$entry->EstimatedCharges->DiscountedCharges->NetCharge; - $priceArr[(string)$entry->Service] = $this->getMethodPrice((string)$entry->EstimatedCharges->DiscountedCharges->NetCharge, (string)$entry->Service); + $costArr[(string)$entry->Service] = + (string)$entry->EstimatedCharges->DiscountedCharges->NetCharge; + $priceArr[(string)$entry->Service] = $this->getMethodPrice( + (string)$entry->EstimatedCharges->DiscountedCharges->NetCharge, + (string)$entry->Service + ); } } @@ -467,12 +695,10 @@ class Mage_Usa_Model_Shipping_Carrier_Fedex } $result = Mage::getModel('shipping/rate_result'); - $defaults = $this->getDefaults(); if (empty($priceArr)) { $error = Mage::getModel('shipping/rate_result_error'); $error->setCarrier('fedex'); $error->setCarrierTitle($this->getConfigData('title')); - //$error->setErrorMessage($errorTitle); $error->setErrorMessage($this->getConfigData('specificerrmsg')); $result->append($error); } else { @@ -510,65 +736,166 @@ class Mage_Usa_Model_Shipping_Carrier_Fedex } } -/* - public function isEligibleForFree($method) - { - return $method=='FEDEXGROUND'; - } -*/ - + /** + * Get configuration data of carrier + * + * @param string $type + * @param string $code + * @return array|bool + */ public function getCode($type, $code='') { $codes = array( - - 'method'=>array( - 'PRIORITYOVERNIGHT' => Mage::helper('usa')->__('Priority Overnight'), - 'STANDARDOVERNIGHT' => Mage::helper('usa')->__('Standard Overnight'), - 'FIRSTOVERNIGHT' => Mage::helper('usa')->__('First Overnight'), - 'FEDEX2DAY' => Mage::helper('usa')->__('2Day'), - 'FEDEXEXPRESSSAVER' => Mage::helper('usa')->__('Express Saver'), - 'INTERNATIONALPRIORITY' => Mage::helper('usa')->__('International Priority'), - 'INTERNATIONALECONOMY' => Mage::helper('usa')->__('International Economy'), - 'INTERNATIONALFIRST' => Mage::helper('usa')->__('International First'), - 'FEDEX1DAYFREIGHT' => Mage::helper('usa')->__('1 Day Freight'), - 'FEDEX2DAYFREIGHT' => Mage::helper('usa')->__('2 Day Freight'), - 'FEDEX3DAYFREIGHT' => Mage::helper('usa')->__('3 Day Freight'), - 'FEDEXGROUND' => Mage::helper('usa')->__('Ground'), - 'GROUNDHOMEDELIVERY' => Mage::helper('usa')->__('Home Delivery'), - 'INTERNATIONALPRIORITY FREIGHT' => Mage::helper('usa')->__('Intl Priority Freight'), - 'INTERNATIONALECONOMY FREIGHT' => Mage::helper('usa')->__('Intl Economy Freight'), - 'EUROPEFIRSTINTERNATIONALPRIORITY' => Mage::helper('usa')->__('Europe First Priority'), + 'method' => array( + 'EUROPE_FIRST_INTERNATIONAL_PRIORITY' => Mage::helper('usa')->__('Europe First Priority'), + 'FEDEX_1_DAY_FREIGHT' => Mage::helper('usa')->__('1 Day Freight'), + 'FEDEX_2_DAY_FREIGHT' => Mage::helper('usa')->__('2 Day Freight'), + 'FEDEX_2_DAY' => Mage::helper('usa')->__('2 Day'), + 'FEDEX_2_DAY_AM' => Mage::helper('usa')->__('2 Day AM'), + 'FEDEX_3_DAY_FREIGHT' => Mage::helper('usa')->__('3 Day Freight'), + 'FEDEX_EXPRESS_SAVER' => Mage::helper('usa')->__('Express Saver'), + 'FEDEX_GROUND' => Mage::helper('usa')->__('Ground'), + 'FIRST_OVERNIGHT' => Mage::helper('usa')->__('First Overnight'), + 'GROUND_HOME_DELIVERY' => Mage::helper('usa')->__('Home Delivery'), + 'INTERNATIONAL_ECONOMY' => Mage::helper('usa')->__('International Economy'), + 'INTERNATIONAL_ECONOMY_FREIGHT' => Mage::helper('usa')->__('Intl Economy Freight'), + 'INTERNATIONAL_FIRST' => Mage::helper('usa')->__('International First'), + 'INTERNATIONAL_GROUND' => Mage::helper('usa')->__('International Ground'), + 'INTERNATIONAL_PRIORITY' => Mage::helper('usa')->__('International Priority'), + 'INTERNATIONAL_PRIORITY_FREIGHT' => Mage::helper('usa')->__('Intl Priority Freight'), + 'PRIORITY_OVERNIGHT' => Mage::helper('usa')->__('Priority Overnight'), + 'SMART_POST' => Mage::helper('usa')->__('Smart Post'), + 'STANDARD_OVERNIGHT' => Mage::helper('usa')->__('Standard Overnight'), + 'FEDEX_FREIGHT' => Mage::helper('usa')->__('Freight'), + 'FEDEX_NATIONAL_FREIGHT' => Mage::helper('usa')->__('National Freight'), ), - - 'dropoff'=>array( - 'REGULARPICKUP' => Mage::helper('usa')->__('Regular Pickup'), - 'REQUESTCOURIER' => Mage::helper('usa')->__('Request Courier'), - 'DROPBOX' => Mage::helper('usa')->__('Drop Box'), - 'BUSINESSSERVICECENTER' => Mage::helper('usa')->__('Business Service Center'), - 'STATION' => Mage::helper('usa')->__('Station'), + 'dropoff' => array( + 'REGULAR_PICKUP' => Mage::helper('usa')->__('Regular Pickup'), + 'REQUEST_COURIER' => Mage::helper('usa')->__('Request Courier'), + 'DROP_BOX' => Mage::helper('usa')->__('Drop Box'), + 'BUSINESS_SERVICE_CENTER' => Mage::helper('usa')->__('Business Service Center'), + 'STATION' => Mage::helper('usa')->__('Station') ), - - 'packaging'=>array( - 'FEDEXENVELOPE' => Mage::helper('usa')->__('FedEx Envelope'), - 'FEDEXPAK' => Mage::helper('usa')->__('FedEx Pak'), - 'FEDEXBOX' => Mage::helper('usa')->__('FedEx Box'), - 'FEDEXTUBE' => Mage::helper('usa')->__('FedEx Tube'), - 'FEDEX10KGBOX' => Mage::helper('usa')->__('FedEx 10kg Box'), - 'FEDEX25KGBOX' => Mage::helper('usa')->__('FedEx 25kg Box'), - 'YOURPACKAGING' => Mage::helper('usa')->__('Your Packaging'), + 'packaging' => array( + 'FEDEX_ENVELOPE' => Mage::helper('usa')->__('FedEx Envelope'), + 'FEDEX_PAK' => Mage::helper('usa')->__('FedEx Pak'), + 'FEDEX_BOX' => Mage::helper('usa')->__('FedEx Box'), + 'FEDEX_TUBE' => Mage::helper('usa')->__('FedEx Tube'), + 'FEDEX_10KG_BOX' => Mage::helper('usa')->__('FedEx 10kg Box'), + 'FEDEX_25KG_BOX' => Mage::helper('usa')->__('FedEx 25kg Box'), + 'YOUR_PACKAGING' => Mage::helper('usa')->__('Your Packaging') + ), + 'containers_filter' => array( + array( + 'containers' => array('FEDEX_ENVELOPE', 'FEDEX_PAK'), + 'filters' => array( + 'within_us' => array( + 'method' => array( + 'FEDEX_EXPRESS_SAVER', + 'FEDEX_2_DAY', + 'FEDEX_2_DAY_AM', + 'STANDARD_OVERNIGHT', + 'PRIORITY_OVERNIGHT', + 'FIRST_OVERNIGHT', + ) + ), + 'from_us' => array( + 'method' => array( + 'INTERNATIONAL_FIRST', + 'INTERNATIONAL_ECONOMY', + 'INTERNATIONAL_PRIORITY', + ) + ) + ) + ), + array( + 'containers' => array('FEDEX_BOX', 'FEDEX_TUBE'), + 'filters' => array( + 'within_us' => array( + 'method' => array( + 'FEDEX_2_DAY', + 'FEDEX_2_DAY_AM', + 'STANDARD_OVERNIGHT', + 'PRIORITY_OVERNIGHT', + 'FIRST_OVERNIGHT', + 'FEDEX_FREIGHT', + 'FEDEX_1_DAY_FREIGHT', + 'FEDEX_2_DAY_FREIGHT', + 'FEDEX_3_DAY_FREIGHT', + 'FEDEX_NATIONAL_FREIGHT', + ) + ), + 'from_us' => array( + 'method' => array( + 'INTERNATIONAL_FIRST', + 'INTERNATIONAL_ECONOMY', + 'INTERNATIONAL_PRIORITY', + ) + ) + ) + ), + array( + 'containers' => array('FEDEX_10KG_BOX', 'FEDEX_25KG_BOX'), + 'filters' => array( + 'within_us' => array(), + 'from_us' => array('method' => array('INTERNATIONAL_PRIORITY')) + ) + ), + array( + 'containers' => array('YOUR_PACKAGING'), + 'filters' => array( + 'within_us' => array( + 'method' =>array( + 'FEDEX_GROUND', + 'GROUND_HOME_DELIVERY', + 'SMART_POST', + 'FEDEX_EXPRESS_SAVER', + 'FEDEX_2_DAY', + 'FEDEX_2_DAY_AM', + 'STANDARD_OVERNIGHT', + 'PRIORITY_OVERNIGHT', + 'FIRST_OVERNIGHT', + 'FEDEX_FREIGHT', + 'FEDEX_1_DAY_FREIGHT', + 'FEDEX_2_DAY_FREIGHT', + 'FEDEX_3_DAY_FREIGHT', + 'FEDEX_NATIONAL_FREIGHT', + ) + ), + 'from_us' => array( + 'method' =>array( + 'INTERNATIONAL_FIRST', + 'INTERNATIONAL_ECONOMY', + 'INTERNATIONAL_PRIORITY', + 'INTERNATIONAL_GROUND', + 'FEDEX_FREIGHT', + 'FEDEX_1_DAY_FREIGHT', + 'FEDEX_2_DAY_FREIGHT', + 'FEDEX_3_DAY_FREIGHT', + 'FEDEX_NATIONAL_FREIGHT', + 'INTERNATIONAL_ECONOMY_FREIGHT', + 'INTERNATIONAL_PRIORITY_FREIGHT', + ) + ) + ) + ) ), + 'delivery_confirmation_types' => array( + 'NO_SIGNATURE_REQUIRED' => Mage::helper('usa')->__('Not Required'), + 'ADULT' => Mage::helper('usa')->__('Adult'), + 'DIRECT' => Mage::helper('usa')->__('Direct'), + 'INDIRECT' => Mage::helper('usa')->__('Indirect'), + ), ); if (!isset($codes[$type])) { -// throw Mage::exception('Mage_Shipping', Mage::helper('usa')->__('Invalid FedEx XML code type: %s', $type)); return false; - } elseif (''===$code) { + } elseif ('' === $code) { return $codes[$type]; } if (!isset($codes[$type][$code])) { -// throw Mage::exception('Mage_Shipping', Mage::helper('usa')->__('Invalid FedEx XML code for type %s: %s', $type, $code)); return false; } else { return $codes[$type][$code]; @@ -578,7 +905,7 @@ class Mage_Usa_Model_Shipping_Carrier_Fedex /** * Return FeDex currency ISO code by Magento Base Currency Code * - * @return string 3-digit currency code + * @return string 3-digit currency code */ public function getCurrencyCode () { @@ -603,7 +930,12 @@ class Mage_Usa_Model_Shipping_Carrier_Fedex return isset($codes[$currencyCode]) ? $codes[$currencyCode] : $currencyCode; } - + /** + * Get tracking + * + * @param mixed $trackings + * @return mixed + */ public function getTracking($trackings) { $this->setTrackingReqeust(); @@ -619,6 +951,11 @@ class Mage_Usa_Model_Shipping_Carrier_Fedex return $this->_result; } + /** + * Set tracking request + * + * @return void + */ protected function setTrackingReqeust() { $r = new Varien_Object(); @@ -627,61 +964,180 @@ class Mage_Usa_Model_Shipping_Carrier_Fedex $r->setAccount($account); $this->_rawTrackingRequest = $r; - } + + /** + * Send request for tracking + * + * @param array $tracking + * @return void + */ protected function _getXMLTracking($tracking) { - $r = $this->_rawTrackingRequest; - - $xml = new SimpleXMLElement(''); - $xml->addAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); - $xml->addAttribute('xsi:noNamespaceSchemaLocation', 'FDXTrack2Request.xsd'); + $trackRequest = array( + 'WebAuthenticationDetail' => array( + 'UserCredential' => array( + 'Key' => $this->getConfigData('key'), + 'Password' => $this->getConfigData('password') + ) + ), + 'ClientDetail' => array( + 'AccountNumber' => $this->getConfigData('account'), + 'MeterNumber' => $this->getConfigData('meter_number') + ), + 'Version' => array( + 'ServiceId' => 'trck', + 'Major' => '5', + 'Intermediate' => '0', + 'Minor' => '0' + ), + 'PackageIdentifier' => array( + 'Type' => 'TRACKING_NUMBER_OR_DOORTAG', + 'Value' => $tracking, + ), + /* + * 0 = summary data, one signle scan structure with the most recent scan + * 1 = multiple sacn activity for each package + */ + 'IncludeDetailedScans' => 1, + ); + $requestString = serialize($trackRequest); + $response = $this->_getCachedQuotes($requestString); + $debugData = array('request' => $trackRequest); + if ($response === null) { + try { + $client = $this->_createTrackSoapClient(); + $response = $client->track($trackRequest); + $this->_setCachedQuotes($requestString, serialize($response)); + $debugData['result'] = $response; + } catch (Exception $e) { + $debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode()); + Mage::logException($e); + } + } else { + $response = unserialize($response); + $debugData['result'] = $response; + } + $this->_debug($debugData); - $requestHeader = $xml->addChild('RequestHeader'); - $requestHeader->addChild('AccountNumber', $r->getAccount()); + $this->_parseTrackingResponse($tracking, $response); + } - /* - * for tracking result, actual meter number is not needed - */ - $requestHeader->addChild('MeterNumber', '0'); + /** + * Parse tracking response + * + * @param array $trackingValue + * @param stdClass $response + */ + protected function _parseTrackingResponse($trackingValue, $response) + { + if (is_object($response)) { + if ($response->HighestSeverity == 'FAILURE' || $response->HighestSeverity == 'ERROR') { + $errorTitle = (string)$response->Notifications->Message; + } elseif (isset($response->TrackDetails)) { + $trackInfo = $response->TrackDetails; + $resultArray['status'] = (string)$trackInfo->StatusDescription; + $resultArray['service'] = (string)$trackInfo->ServiceInfo; + $timestamp = isset($trackInfo->EstimatedDeliveryTimestamp) ? + $trackInfo->EstimatedDeliveryTimestamp : $trackInfo->ActualDeliveryTimestamp; + $timestamp = strtotime((string)$timestamp); + if ($timestamp) { + $resultArray['deliverydate'] = date('Y-m-d', $timestamp); + $resultArray['deliverytime'] = date('H:i:s', $timestamp); + } - $packageIdentifier = $xml->addChild('PackageIdentifier'); - $packageIdentifier->addChild('Value', $tracking); + $deliveryLocation = isset($trackInfo->EstimatedDeliveryAddress) ? + $trackInfo->EstimatedDeliveryAddress : $trackInfo->ActualDeliveryAddress; + $deliveryLocationArray = array(); + if (isset($deliveryLocation->City)) { + $deliveryLocationArray[] = (string)$deliveryLocation->City; + } + if (isset($deliveryLocation->StateOrProvinceCode)) { + $deliveryLocationArray[] = (string)$deliveryLocation->StateOrProvinceCode; + } + if (isset($deliveryLocation->CountryCode)) { + $deliveryLocationArray[] = (string)$deliveryLocation->CountryCode; + } + if ($deliveryLocationArray) { + $resultArray['deliverylocation'] = implode(', ', $deliveryLocationArray); + } - /* - * 0 = summary data, one signle scan structure with the most recent scan - * 1 = multiple sacn activity for each package - */ - $xml->addChild('DetailScans', '1'); + $resultArray['signedby'] = (string)$trackInfo->DeliverySignatureName; + $resultArray['shippeddate'] = date('Y-m-d', (int)$trackInfo->ShipTimestamp); + if (isset($trackInfo->PackageWeight) && isset($trackInfo->Units)) { + $weight = (string)$trackInfo->PackageWeight; + $unit = (string)$trackInfo->Units; + $resultArray['weight'] = "{$weight} {$unit}"; + } - $request = $xml->asXML(); - $debugData = array('request' => $request); + $packageProgress = array(); + if (isset($trackInfo->Events)) { + $events = $trackInfo->Events; + if (isset($events->Address)) { + $events = array($events); + } + foreach ($events as $event) { + $tempArray = array(); + $tempArray['activity'] = (string)$event->EventDescription; + $timestamp = strtotime((string)$event->Timestamp); + if ($timestamp) { + $tempArray['deliverydate'] = date('Y-m-d', $timestamp); + $tempArray['deliverytime'] = date('H:i:s', $timestamp); + } + if (isset($event->Address)) { + $addressArray = array(); + $address = $event->Address; + if (isset($address->City)) { + $addressArray[] = (string)$address->City; + } + if (isset($address->StateOrProvinceCode)) { + $addressArray[] = (string)$address->StateOrProvinceCode; + } + if (isset($address->CountryCode)) { + $addressArray[] = (string)$address->CountryCode; + } + if ($addressArray) { + $tempArray['deliverylocation'] = implode(', ', $addressArray); + } + } + $packageProgress[] = $tempArray; + } + } - try { - $url = $this->getConfigData('gateway_url'); - if (!$url) { - $url = $this->_defaultGatewayUrl; + $resultArray['progressdetail'] = $packageProgress; } - $ch = curl_init(); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($ch, CURLOPT_POSTFIELDS, $request); - $responseBody = curl_exec($ch); - $debugData['result'] = $responseBody; - curl_close ($ch); - } - catch (Exception $e) { - $debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode()); - $responseBody = ''; } - $this->_debug($debugData); - #echo "".$responseBody.""; - $this->_parseXmlTrackingResponse($tracking, $responseBody); + + if (!$this->_result) { + $this->_result = Mage::getModel('shipping/tracking_result'); + } + + if (isset($resultArray)) { + $tracking = Mage::getModel('shipping/tracking_result_status'); + $tracking->setCarrier('fedex'); + $tracking->setCarrierTitle($this->getConfigData('title')); + $tracking->setTracking($trackingValue); + $tracking->addData($resultArray); + $this->_result->append($tracking); + } else { + $error = Mage::getModel('shipping/tracking_result_error'); + $error->setCarrier('fedex'); + $error->setCarrierTitle($this->getConfigData('title')); + $error->setTracking($trackingValue); + $error->setErrorMessage($errorTitle ? $errorTitle : Mage::helper('usa')->__('Unable to retrieve tracking')); + $this->_result->append($error); + } } - protected function _parseXmlTrackingResponse($trackingvalue,$response) + /** + * Parse xml tracking response + * + * @deprecated after 1.6.0.0 see _parseTrackingResponse() + * @param array $trackingvalue + * @param string $response + * @return void + */ + protected function _parseXmlTrackingResponse($trackingvalue, $response) { $resultArr=array(); if (strlen(trim($response))>0) { @@ -738,19 +1194,18 @@ class Mage_Usa_Model_Shipping_Carrier_Fedex $errorTitle = false; } - if(!$this->_result){ + if (!$this->_result) { $this->_result = Mage::getModel('shipping/tracking_result'); } - $defaults = $this->getDefaults(); - if($resultArr){ + if ($resultArr) { $tracking = Mage::getModel('shipping/tracking_result_status'); $tracking->setCarrier('fedex'); $tracking->setCarrierTitle($this->getConfigData('title')); $tracking->setTracking($trackingvalue); $tracking->addData($resultArr); $this->_result->append($tracking); - }else{ + } else { $error = Mage::getModel('shipping/tracking_result_error'); $error->setCarrier('fedex'); $error->setCarrierTitle($this->getConfigData('title')); @@ -760,17 +1215,22 @@ class Mage_Usa_Model_Shipping_Carrier_Fedex } } + /** + * Get tracking response + * + * @return string + */ public function getResponse() { $statuses = ''; - if ($this->_result instanceof Mage_Shipping_Model_Tracking_Result){ + if ($this->_result instanceof Mage_Shipping_Model_Tracking_Result) { if ($trackings = $this->_result->getAllTrackings()) { foreach ($trackings as $tracking){ if($data = $tracking->getAllData()){ if (!empty($data['status'])) { - $statuses .= Mage::helper('usa')->__($data['status'])."\n
"; + $statuses .= Mage::helper('usa')->__($data['status']) . "\n
"; } else { - $statuses .= Mage::helper('usa')->__('Empty response')."\n
"; + $statuses .= Mage::helper('usa')->__('Empty response') . "\n
"; } } } @@ -797,4 +1257,345 @@ class Mage_Usa_Model_Shipping_Carrier_Fedex return $arr; } + /** + * Return array of authenticated information + * + * @return array + */ + protected function _getAuthDetails() + { + return array( + 'WebAuthenticationDetail' => array( + 'UserCredential' => array( + 'Key' => $this->getConfigData('key'), + 'Password' => $this->getConfigData('password') + ) + ), + 'ClientDetail' => array( + 'AccountNumber' => $this->getConfigData('account'), + 'MeterNumber' => $this->getConfigData('meter_number') + ), + 'TransactionDetail' => array( + 'CustomerTransactionId' => '*** Express Domestic Shipping Request v9 using PHP ***' + ), + 'Version' => array( + 'ServiceId' => 'ship', + 'Major' => '10', + 'Intermediate' => '0', + 'Minor' => '0' + ) + ); + } + + /** + * Form array with appropriate structure for shipment request + * + * @param Varien_Object $request + * @return array + */ + protected function _formShipmentRequest(Varien_Object $request) + { + if ($request->getReferenceData()) { + $referenceData = $request->getReferenceData() . $request->getPackageId(); + } else { + $referenceData = 'Order #' + . $request->getOrderShipment()->getOrder()->getIncrementId() + . ' P' + . $request->getPackageId(); + } + $packageParams = $request->getPackageParams(); + $customsValue = $packageParams->getCustomsValue(); + $height = $packageParams->getHeight(); + $width = $packageParams->getWidth(); + $length = $packageParams->getLength(); + $weightUnits = $packageParams->getWeightUnits() == Zend_Measure_Weight::POUND ? 'LB' : 'KG'; + $dimensionsUnits = $packageParams->getDimensionUnits() == Zend_Measure_Length::INCH ? 'IN' : 'CM'; + $unitPrice = 0; + $itemsQty = 0; + $itemsDesc = array(); + $countriesOfManufacture = array(); + $productIds = array(); + $packageItems = $request->getPackageItems(); + foreach ($packageItems as $itemShipment) { + $item = new Varien_Object(); + $item->setData($itemShipment); + + $unitPrice += $item->getPrice(); + $itemsQty += $item->getQty(); + + $itemsDesc[] = $item->getName(); + $productIds[] = $item->getProductId(); + } + + // get countries of manufacture + $productCollection = Mage::getResourceModel('catalog/product_collection') + ->addStoreFilter($request->getStoreId()) + ->addFieldToFilter('entity_id', array('in' => $productIds)) + ->addAttributeToSelect('country_of_manufacture'); + foreach ($productCollection as $product) { + $countriesOfManufacture[] = $product->getCountryOfManufacture(); + } + + $paymentType = $request->getIsReturn() ? 'RECIPIENT' : 'SENDER'; + $requestClient = array( + 'RequestedShipment' => array( + 'ShipTimestamp' => time(), + 'DropoffType' => $this->getConfigData('dropoff'), + 'PackagingType' => $request->getPackagingType(), + 'ServiceType' => $request->getShippingMethod(), + 'Shipper' => array( + 'Contact' => array( + 'PersonName' => $request->getShipperContactPersonName(), + 'CompanyName' => $request->getShipperContactCompanyName(), + 'PhoneNumber' => $request->getShipperContactPhoneNumber() + ), + 'Address' => array( + 'StreetLines' => array($request->getShipperAddressStreet()), + 'City' => $request->getShipperAddressCity(), + 'StateOrProvinceCode' => $request->getShipperAddressStateOrProvinceCode(), + 'PostalCode' => $request->getShipperAddressPostalCode(), + 'CountryCode' => $request->getShipperAddressCountryCode() + ) + ), + 'Recipient' => array( + 'Contact' => array( + 'PersonName' => $request->getRecipientContactPersonName(), + 'CompanyName' => $request->getRecipientContactCompanyName(), + 'PhoneNumber' => $request->getRecipientContactPhoneNumber() + ), + 'Address' => array( + 'StreetLines' => array($request->getRecipientAddressStreet()), + 'City' => $request->getRecipientAddressCity(), + 'StateOrProvinceCode' => $request->getRecipientAddressStateOrProvinceCode(), + 'PostalCode' => $request->getRecipientAddressPostalCode(), + 'CountryCode' => $request->getRecipientAddressCountryCode(), + 'Residential' => (bool)$this->getConfigData('residence_delivery') + ), + ), + 'ShippingChargesPayment' => array( + 'PaymentType' => $paymentType, + 'Payor' => array( + 'AccountNumber' => $this->getConfigData('account'), + 'CountryCode' => Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, + $request->getStoreId() + ) + ) + ), + 'LabelSpecification' =>array( + 'LabelFormatType' => 'COMMON2D', + 'ImageType' => 'PNG', + 'LabelStockType' => 'PAPER_8.5X11_TOP_HALF_LABEL', + ), + 'RateRequestTypes' => array('ACCOUNT'), + 'PackageCount' => 1, + 'RequestedPackageLineItems' => array( + 'SequenceNumber' => '1', + 'Weight' => array( + 'Units' => $weightUnits, + 'Value' => $request->getPackageWeight() + ), + 'CustomerReferences' => array( + 'CustomerReferenceType' => 'CUSTOMER_REFERENCE', + 'Value' => $referenceData + ), + 'SpecialServicesRequested' => array( + 'SpecialServiceTypes' => 'SIGNATURE_OPTION', + 'SignatureOptionDetail' => array('OptionType' => $packageParams->getDeliveryConfirmation()) + ), + ) + ) + ); + + // for international shipping + if ($request->getShipperAddressCountryCode() != $request->getRecipientAddressCountryCode()) { + $requestClient['RequestedShipment']['CustomsClearanceDetail'] = + array( + 'CustomsValue' => + array( + 'Currency' => $request->getBaseCurrencyCode(), + 'Amount' => $customsValue, + ), + 'DutiesPayment' => array( + 'PaymentType' => $paymentType, + 'Payor' => array( + 'AccountNumber' => $this->getConfigData('account'), + 'CountryCode' => Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, + $request->getStoreId() + ) + ) + ), + 'Commodities' => array( + 'Weight' => array( + 'Units' => $weightUnits, + 'Value' => $request->getPackageWeight() + ), + 'NumberOfPieces' => 1, + 'CountryOfManufacture' => implode(',', array_unique($countriesOfManufacture)), + 'Description' => implode(', ', $itemsDesc), + 'Quantity' => ceil($itemsQty), + 'QuantityUnits' => 'pcs', + 'UnitPrice' => array( + 'Currency' => $request->getBaseCurrencyCode(), + 'Amount' => $unitPrice + ), + 'CustomsValue' => array( + 'Currency' => $request->getBaseCurrencyCode(), + 'Amount' => $customsValue + ), + ) + ); + } + + if ($request->getMasterTrackingId()) { + $requestClient['RequestedShipment']['MasterTrackingId'] = $request->getMasterTrackingId(); + } + + // set dimensions + if ($length || $width || $height) { + $requestClient['RequestedShipment']['RequestedPackageLineItems']['Dimensions'] = array(); + $dimenssions = &$requestClient['RequestedShipment']['RequestedPackageLineItems']['Dimensions']; + $dimenssions['Length'] = $length; + $dimenssions['Width'] = $width; + $dimenssions['Height'] = $height; + $dimenssions['Units'] = $dimensionsUnits; + } + + return $this->_getAuthDetails() + $requestClient; + } + + /** + * Do shipment request to carrier web service, obtain Print Shipping Labels and process errors in response + * + * @param Varien_Object $request + * @return Varien_Object + */ + protected function _doShipmentRequest(Varien_Object $request) + { + $this->_prepareShipmentRequest($request); + $result = new Varien_Object(); + $client = $this->_createShipSoapClient(); + $requestClient = $this->_formShipmentRequest($request); + $response = $client->processShipment($requestClient); + + if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR') { + $shippingLabelContent = $response->CompletedShipmentDetail->CompletedPackageDetails->Label->Parts->Image; + $trackingNumber = $response->CompletedShipmentDetail->CompletedPackageDetails->TrackingIds->TrackingNumber; + $result->setShippingLabelContent($shippingLabelContent); + $result->setTrackingNumber($trackingNumber); + $debugData = array('request' => $client->__getLastRequest(), 'result' => $client->__getLastResponse()); + $this->_debug($debugData); + } else { + $debugData = array( + 'request' => $client->__getLastRequest(), + 'result' => array( + 'error' => '', + 'code' => '', + 'xml' => $client->__getLastResponse() + ) + ); + if (is_array($response->Notifications)) { + foreach ($response->Notifications as $notification) { + $debugData['result']['code'] .= $notification->Code . '; '; + $debugData['result']['error'] .= $notification->Message . '; '; + } + } else { + $debugData['result']['code'] = $response->Notifications->Code . ' '; + $debugData['result']['error'] = $response->Notifications->Message . ' '; + } + $this->_debug($debugData); + $result->setErrors($debugData['result']['error']); + } + $result->setGatewayResponse($client->__getLastResponse()); + + return $result; + } + + /** + * For multi package shipments. Delete requested shipments if the current shipment + * request is failed + * + * @param array $data + * @return bool + */ + public function rollBack($data) + { + $requestData = $this->_getAuthDetails(); + $requestData['DeletionControl'] = 'DELETE_ONE_PACKAGE'; + foreach ($data as &$item) { + $requestData['TrackingId'] = $item['tracking_number']; + $client = $this->_createShipSoapClient(); + $client->deleteShipment($requestData); + } + return true; + } + + /** + * Return container types of carrier + * + * @param Varien_Object|null $params + * @return array|bool + */ + public function getContainerTypes(Varien_Object $params = null) + { + if ($params == null) { + return $this->_getAllowedContainers($params); + } + $method = $params->getMethod(); + $countryShipper = $params->getCountryShipper(); + $countryRecipient = $params->getCountryRecipient(); + + if (($countryShipper == self::USA_COUNTRY_ID && $countryRecipient == self::CANADA_COUNTRY_ID + || $countryShipper == self::CANADA_COUNTRY_ID && $countryRecipient == self::USA_COUNTRY_ID) + && $method == 'FEDEX_GROUND' + ) { + return array('YOUR_PACKAGING' => Mage::helper('usa')->__('Your Packaging')); + } else if ($method == 'INTERNATIONAL_ECONOMY' || $method == 'INTERNATIONAL_FIRST') { + $allTypes = $this->getContainerTypesAll(); + $exclude = array('FEDEX_10KG_BOX' => '', 'FEDEX_25KG_BOX' => ''); + return array_diff_key($allTypes, $exclude); + } else if ($method == 'EUROPE_FIRST_INTERNATIONAL_PRIORITY') { + $allTypes = $this->getContainerTypesAll(); + $exclude = array('FEDEX_BOX' => '', 'FEDEX_TUBE' => ''); + return array_diff_key($allTypes, $exclude); + } else if ($countryShipper == self::CANADA_COUNTRY_ID && $countryRecipient == self::CANADA_COUNTRY_ID) { + // hack for Canada domestic. Apply the same filter rules as for US domestic + $params->setCountryShipper(self::USA_COUNTRY_ID); + $params->setCountryRecipient(self::USA_COUNTRY_ID); + } + + return $this->_getAllowedContainers($params); + } + + /** + * Return all container types of carrier + * + * @return array|bool + */ + public function getContainerTypesAll() + { + return $this->getCode('packaging'); + } + + /** + * Return structured data of containers witch related with shipping methods + * + * @return array|bool + */ + public function getContainerTypesFilter() + { + return $this->getCode('containers_filter'); + } + + /** + * Return delivery confirmation types of carrier + * + * @param Varien_Object|null $params + * @return array + */ + public function getDeliveryConfirmationTypes(Varien_Object $params = null) + { + return $this->getCode('delivery_confirmation_types'); + } } diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Dropoff.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Dropoff.php index 0a5f2be..7c15c34 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Dropoff.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Dropoff.php @@ -20,19 +20,25 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +/** + * Fedex dropoff source implementation + * + * @category Mage + * @package Mage_Usa + * @author Magento Core Team + */ class Mage_Usa_Model_Shipping_Carrier_Fedex_Source_Dropoff { public function toOptionArray() { $fedex = Mage::getSingleton('usa/shipping_carrier_fedex'); $arr = array(); - foreach ($fedex->getCode('dropoff') as $k=>$v) { - $arr[] = array('value'=>$k, 'label'=>$v); + foreach ($fedex->getCode('dropoff') as $k => $v) { + $arr[] = array('value' => $k, 'label' => $v); } return $arr; } diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Freemethod.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Freemethod.php index 83f0040..e5d26d4 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Freemethod.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Freemethod.php @@ -20,17 +20,24 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - -class Mage_Usa_Model_Shipping_Carrier_Fedex_Source_Freemethod extends Mage_Usa_Model_Shipping_Carrier_Fedex_Source_Method +/** + * Fedex freemethod source implementation + * + * @category Mage + * @package Mage_Usa + * @author Magento Core Team + */ +class Mage_Usa_Model_Shipping_Carrier_Fedex_Source_Freemethod + extends Mage_Usa_Model_Shipping_Carrier_Fedex_Source_Method { public function toOptionArray() { $arr = parent::toOptionArray(); - array_unshift($arr, array('value'=>'', 'label'=>Mage::helper('shipping')->__('None'))); + array_unshift($arr, array('value' => '', 'label' => Mage::helper('shipping')->__('None'))); return $arr; } } diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Method.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Method.php index f93b3d9..7e7716c 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Method.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Method.php @@ -20,19 +20,25 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +/** + * Fedex method source implementation + * + * @category Mage + * @package Mage_Usa + * @author Magento Core Team + */ class Mage_Usa_Model_Shipping_Carrier_Fedex_Source_Method { public function toOptionArray() { $fedex = Mage::getSingleton('usa/shipping_carrier_fedex'); $arr = array(); - foreach ($fedex->getCode('method') as $k=>$v) { - $arr[] = array('value'=>$k, 'label'=>$v); + foreach ($fedex->getCode('method') as $k => $v) { + $arr[] = array('value' => $k, 'label' => $v); } return $arr; } diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Packaging.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Packaging.php index d4a8acf..e77d0af 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Packaging.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Packaging.php @@ -20,19 +20,25 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +/** + * Fedex packaging source implementation + * + * @category Mage + * @package Mage_Usa + * @author Magento Core Team + */ class Mage_Usa_Model_Shipping_Carrier_Fedex_Source_Packaging { public function toOptionArray() { $fedex = Mage::getSingleton('usa/shipping_carrier_fedex'); $arr = array(); - foreach ($fedex->getCode('packaging') as $k=>$v) { - $arr[] = array('value'=>$k, 'label'=>$v); + foreach ($fedex->getCode('packaging') as $k => $v) { + $arr[] = array('value' => $k, 'label' => $v); } return $arr; } diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php index 1b1811f..c324af8 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php @@ -20,13 +20,13 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** - * UPS shipping rates estimation + * UPS shipping implementation * * @category Mage * @package Mage_Usa @@ -37,26 +37,97 @@ class Mage_Usa_Model_Shipping_Carrier_Ups implements Mage_Shipping_Model_Carrier_Interface { - protected $_code = 'ups'; + /** + * Code of the carrier + * + * @var string + */ + const CODE = 'ups'; + + /** + * Delivery Confirmation level based on origin/destination + * + * @var int + */ + const DELIVERY_CONFIRMATION_SHIPMENT = 1; + const DELIVERY_CONFIRMATION_PACKAGE = 2; + + /** + * Code of the carrier + * + * @var string + */ + protected $_code = self::CODE; + /** + * Rate request data + * + * @var Mage_Shipping_Model_Rate_Request|null + */ protected $_request = null; + /** + * Raw rate request data + * + * @var Varien_Object|null + */ + protected $_rawRequest = null; + + /** + * Rate result data + * + * @var Mage_Shipping_Model_Rate_Result|null + */ protected $_result = null; + /** + * Base currency rate + * + * @var double + */ + protected $_baseCurrencyRate; + + /** + * Xml access request + * + * @var string + */ protected $_xmlAccessRequest = null; + /** + * Default cgi gateway url + * + * @var string + */ protected $_defaultCgiGatewayUrl = 'http://www.ups.com:80/using/services/rave/qcostcgi.cgi'; /** - * Base currency rate + * Default urls for shipment * - * @var double + * @var array + */ + protected $_defaultUrls = array( + 'ShipConfirm' => 'https://wwwcie.ups.com/ups.app/xml/ShipConfirm', + 'ShipAccept' => 'https://wwwcie.ups.com/ups.app/xml/ShipAccept', + ); + + /** + * Container types that could be customized for UPS carrier + * + * @var array + */ + protected $_customizableContainerTypes = array('CP', 'CSP'); + + /** + * Collect and get rates + * + * @param Mage_Shipping_Model_Rate_Request $request + * @return Mage_Shipping_Model_Rate_Result|bool|null */ - protected $_baseCurrencyRate; public function collectRates(Mage_Shipping_Model_Rate_Request $request) { - if (!$this->getConfigFlag('active')) { + if (!$this->getConfigFlag($this->_activeFlag)) { return false; } @@ -68,6 +139,12 @@ class Mage_Usa_Model_Shipping_Carrier_Ups return $this->getResult(); } + /** + * Prepare and set request to this instance + * + * @param Mage_Shipping_Model_Rate_Request $request + * @return Mage_Usa_Model_Shipping_Carrier_Ups + */ public function setRequest(Mage_Shipping_Model_Rate_Request $request) { $this->_request = $request; @@ -106,7 +183,10 @@ class Mage_Usa_Model_Shipping_Carrier_Ups if ($request->getOrigCountry()) { $origCountry = $request->getOrigCountry(); } else { - $origCountry = Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_COUNTRY_ID, $this->getStore()); + $origCountry = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, + $request->getStoreId() + ); } $r->setOrigCountry(Mage::getModel('directory/country')->load($origCountry)->getIso2Code()); @@ -114,23 +194,32 @@ class Mage_Usa_Model_Shipping_Carrier_Ups if ($request->getOrigRegionCode()) { $origRegionCode = $request->getOrigRegionCode(); } else { - $origRegionCode = Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_REGION_ID, $this->getStore()); - if (is_numeric($origRegionCode)) { - $origRegionCode = Mage::getModel('directory/region')->load($origRegionCode)->getCode(); - } + $origRegionCode = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_REGION_ID, + $request->getStoreId() + ); + } + if (is_numeric($origRegionCode)) { + $origRegionCode = Mage::getModel('directory/region')->load($origRegionCode)->getCode(); } $r->setOrigRegionCode($origRegionCode); if ($request->getOrigPostcode()) { $r->setOrigPostal($request->getOrigPostcode()); } else { - $r->setOrigPostal(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_POSTCODE, $this->getStore())); + $r->setOrigPostal(Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP, + $request->getStoreId() + )); } if ($request->getOrigCity()) { $r->setOrigCity($request->getOrigCity()); } else { - $r->setOrigCity(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_CITY, $this->getStore())); + $r->setOrigCity(Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_CITY, + $request->getStoreId() + )); } @@ -141,7 +230,9 @@ class Mage_Usa_Model_Shipping_Carrier_Ups } //for UPS, puero rico state for US will assume as puerto rico country - if ($destCountry==self::USA_COUNTRY_ID && ($request->getDestPostcode()=='00912' || $request->getDestRegionCode()==self::PUERTORICO_COUNTRY_ID)) { + if ($destCountry == self::USA_COUNTRY_ID + && ($request->getDestPostcode()=='00912' || $request->getDestRegionCode()==self::PUERTORICO_COUNTRY_ID) + ) { $destCountry = self::PUERTORICO_COUNTRY_ID; } @@ -179,6 +270,10 @@ class Mage_Usa_Model_Shipping_Carrier_Ups } $r->setUnitMeasure($unit); + $r->setIsReturn($request->getIsReturn()); + + $r->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax()); + $this->_rawRequest = $r; return $this; @@ -208,11 +303,21 @@ class Mage_Usa_Model_Shipping_Carrier_Ups return $weight; } + /** + * Get result of request + * + * @return mixed + */ public function getResult() { return $this->_result; } + /** + * Do remote request for and handle errors + * + * @return Mage_Shipping_Model_Rate_Result + */ protected function _getQuotes() { switch ($this->getConfigData('type')) { @@ -225,6 +330,12 @@ class Mage_Usa_Model_Shipping_Carrier_Ups return null; } + /** + * Set free method request + * + * @param string $freeMethod + * @return null + */ protected function _setFreeMethodRequest($freeMethod) { $r = $this->_rawRequest; @@ -236,6 +347,11 @@ class Mage_Usa_Model_Shipping_Carrier_Ups $r->setProduct($freeMethod); } + /** + * Get cgi rates + * + * @return Mage_Shipping_Model_Rate_Result + */ protected function _getCgiQuotes() { $r = $this->_rawRequest; @@ -247,7 +363,9 @@ class Mage_Usa_Model_Shipping_Carrier_Ups '14_origCountry' => $r->getOrigCountry(), '15_origPostal' => $r->getOrigPostal(), 'origCity' => $r->getOrigCity(), - '19_destPostal' => 'US' == $r->getDestCountry() ? substr($r->getDestPostal(), 0, 5) : $r->getDestPostal(), // UPS returns error for zip+4 US codes + '19_destPostal' => Mage_Usa_Model_Shipping_Carrier_Abstract::USA_COUNTRY_ID == $r->getDestCountry() ? + substr($r->getDestPostal(), 0, 5) : + $r->getDestPostal(), '22_destCountry' => $r->getDestCountry(), '23_weight' => $r->getWeight(), '47_rate_chart' => $r->getPickup(), @@ -285,7 +403,14 @@ class Mage_Usa_Model_Shipping_Carrier_Ups return $this->_parseCgiResponse($responseBody); } - public function getShipmentByCode($code,$origin = null){ + /** + * Get shipment by code + * + * @param string $code + * @param string $origin + * @return array|bool + */ + public function getShipmentByCode($code, $origin = null){ if($origin===null){ $origin = $this->getConfigData('origin_shipment'); } @@ -297,6 +422,12 @@ class Mage_Usa_Model_Shipping_Carrier_Ups } + /** + * Prepare shipping rate result based on response + * + * @param mixed $response + * @return Mage_Shipping_Model_Rate_Result + */ protected function _parseCgiResponse($response) { $costArr = array(); @@ -336,7 +467,6 @@ class Mage_Usa_Model_Shipping_Carrier_Ups $error = Mage::getModel('shipping/rate_result_error'); $error->setCarrier('ups'); $error->setCarrierTitle($this->getConfigData('title')); - //$error->setErrorMessage($errorTitle); $error->setErrorMessage($this->getConfigData('specificerrmsg')); $result->append($error); } else { @@ -352,17 +482,17 @@ class Mage_Usa_Model_Shipping_Carrier_Ups $result->append($rate); } } -#echo "
".print_r($result,1)."
"; - return $result; - } -/* - public function isEligibleForFree($method) - { - return $method=='GND' || $method=='GNDCOM' || $method=='GNDRES'; + return $result; } -*/ + /** + * Get configuration data of carrier + * + * @param string $type + * @param string $code + * @return array|bool + */ public function getCode($type, $code='') { $codes = array( @@ -399,7 +529,7 @@ class Mage_Usa_Model_Shipping_Carrier_Ups '14' => Mage::helper('usa')->__('UPS Next Day Air Early A.M.'), '54' => Mage::helper('usa')->__('UPS Worldwide Express Plus'), '59' => Mage::helper('usa')->__('UPS Second Day Air A.M.'), - '65' => Mage::helper('usa')->__('UPS Saver'), + '65' => Mage::helper('usa')->__('UPS Worldwide Saver'), ), // Shipments Originating in Canada 'Shipments Originating in Canada' => array( @@ -497,19 +627,31 @@ class Mage_Usa_Model_Shipping_Carrier_Ups 'container'=>array( 'CP' => '00', // Customer Packaging 'ULE' => '01', // UPS Letter Envelope + 'CSP' => '02', // Customer Supplied Package 'UT' => '03', // UPS Tube + 'PAK' => '04', // PAK 'UEB' => '21', // UPS Express Box 'UW25' => '24', // UPS Worldwide 25 kilo 'UW10' => '25', // UPS Worldwide 10 kilo + 'PLT' => '30', // Pallet + 'SEB' => '2a', // Small Express Box + 'MEB' => '2b', // Medium Express Box + 'LEB' => '2c', // Large Express Box ), 'container_description'=>array( 'CP' => Mage::helper('usa')->__('Customer Packaging'), 'ULE' => Mage::helper('usa')->__('UPS Letter Envelope'), + 'CSP' => Mage::helper('usa')->__('Customer Supplied Package'), 'UT' => Mage::helper('usa')->__('UPS Tube'), + 'PAK' => Mage::helper('usa')->__('PAK'), 'UEB' => Mage::helper('usa')->__('UPS Express Box'), 'UW25' => Mage::helper('usa')->__('UPS Worldwide 25 kilo'), 'UW10' => Mage::helper('usa')->__('UPS Worldwide 10 kilo'), + 'PLT' => Mage::helper('usa')->__('Pallet'), + 'SEB' => Mage::helper('usa')->__('Small Express Box'), + 'MEB' => Mage::helper('usa')->__('Medium Express Box'), + 'LEB' => Mage::helper('usa')->__('Large Express Box'), ), 'dest_type'=>array( @@ -526,24 +668,126 @@ class Mage_Usa_Model_Shipping_Carrier_Ups 'LBS' => Mage::helper('usa')->__('Pounds'), 'KGS' => Mage::helper('usa')->__('Kilograms'), ), - + 'containers_filter' => array( + array( + 'containers' => array('00'), // Customer Packaging + 'filters' => array( + 'within_us' => array( + 'method' => array( + '01', // Next Day Air + '13', // Next Day Air Saver + '12', // 3 Day Select + '59', // 2nd Day Air AM + '03', // Ground + '14', // Next Day Air Early AM + '02', // 2nd Day Air + ) + ), + 'from_us' => array( + 'method' => array( + '07', // Worldwide Express + '54', // Worldwide Express Plus + '08', // Worldwide Expedited + '65', // Worldwide Saver + '11', // Standard + ) + ) + ) + ), + array( + // Small Express Box, Medium Express Box, Large Express Box, UPS Tube + 'containers' => array('2a', '2b', '2c', '03'), + 'filters' => array( + 'within_us' => array( + 'method' => array( + '01', // Next Day Air + '13', // Next Day Air Saver + '14', // Next Day Air Early AM + '02', // 2nd Day Air + '59', // 2nd Day Air AM + '13', // Next Day Air Saver + ) + ), + 'from_us' => array( + 'method' => array( + '07', // Worldwide Express + '54', // Worldwide Express Plus + '08', // Worldwide Expedited + '65', // Worldwide Saver + ) + ) + ) + ), + array( + 'containers' => array('24', '25'), // UPS Worldwide 25 kilo, UPS Worldwide 10 kilo + 'filters' => array( + 'within_us' => array( + 'method' => array() + ), + 'from_us' => array( + 'method' => array( + '07', // Worldwide Express + '54', // Worldwide Express Plus + '65', // Worldwide Saver + ) + ) + ) + ), + array( + 'containers' => array('01', '04'), // UPS Letter, UPS PAK + 'filters' => array( + 'within_us' => array( + 'method' => array( + '01', // Next Day Air + '14', // Next Day Air Early AM + '02', // 2nd Day Air + '59', // 2nd Day Air AM + '13', // Next Day Air Saver + ) + ), + 'from_us' => array( + 'method' => array( + '07', // Worldwide Express + '54', // Worldwide Express Plus + '65', // Worldwide Saver + ) + ) + ) + ), + array( + 'containers' => array('04'), // UPS PAK + 'filters' => array( + 'within_us' => array( + 'method' => array() + ), + 'from_us' => array( + 'method' => array( + '08', // Worldwide Expedited + ) + ) + ) + ), + ) ); if (!isset($codes[$type])) { -// throw Mage::exception('Mage_Shipping', Mage::helper('usa')->__('Invalid UPS CGI code type: %s', $type)); return false; } elseif (''===$code) { return $codes[$type]; } if (!isset($codes[$type][$code])) { -// throw Mage::exception('Mage_Shipping', Mage::helper('usa')->__('Invalid UPS CGI code for type %s: %s', $type, $code)); return false; } else { return $codes[$type][$code]; } } + /** + * Get xml rates + * + * @return Mage_Shipping_Model_Rate_Result + */ protected function _getXmlQuotes() { $url = $this->getConfigData('gateway_xml_url'); @@ -560,7 +804,9 @@ class Mage_Usa_Model_Shipping_Carrier_Ups '15_origPostal' => $r->getOrigPostal(), 'origCity' => $r->getOrigCity(), 'origRegionCode' => $r->getOrigRegionCode(), - '19_destPostal' => 'US' == $r->getDestCountry() ? substr($r->getDestPostal(), 0, 5) : $r->getDestPostal(), // UPS returns error for zip+4 US codes + '19_destPostal' => Mage_Usa_Model_Shipping_Carrier_Abstract::USA_COUNTRY_ID == $r->getDestCountry() ? + substr($r->getDestPostal(), 0, 5) : + $r->getDestPostal(), '22_destCountry' => $r->getDestCountry(), 'destRegionCode' => $r->getDestRegionCode(), '23_weight' => $r->getWeight(), @@ -612,12 +858,24 @@ XMLRequest; $xmlRequest .= "{$shipper}"; } + if ($r->getIsReturn()) { + $shipperCity = ''; + $shipperPostalCode = $params['19_destPostal']; + $shipperCountryCode = $params['22_destCountry']; + $shipperStateProvince = $params['destRegionCode']; + } else { + $shipperCity = $params['origCity']; + $shipperPostalCode = $params['15_origPostal']; + $shipperCountryCode = $params['14_origCountry']; + $shipperStateProvince = $params['origRegionCode']; + } + $xmlRequest .= <<< XMLRequest
- {$params['origCity']} - {$params['15_origPostal']} - {$params['14_origCountry']} - {$params['origRegionCode']} + {$shipperCity} + {$shipperPostalCode} + {$shipperCountryCode} + {$shipperStateProvince}
@@ -628,7 +886,10 @@ $xmlRequest .= <<< XMLRequest {$params['destRegionCode']} XMLRequest; - $xmlRequest .= ($params['49_residential']==='01' ? "{$params['49_residential']}" : ''); + $xmlRequest .= ($params['49_residential']==='01' + ? "{$params['49_residential']}" + : '' + ); $xmlRequest .= <<< XMLRequest @@ -660,7 +921,6 @@ $xmlRequest .= <<< XMLRequest XMLRequest; - $xmlResponse = $this->_getCachedQuotes($xmlRequest); if ($xmlResponse === null) { $debugData = array('request' => $xmlRequest); @@ -705,6 +965,12 @@ XMLRequest; return $this->_baseCurrencyRate; } + /** + * Prepare shipping rate result based on response + * + * @param mixed $response + * @return Mage_Shipping_Model_Rate_Result + */ protected function _parseXmlResponse($xmlResponse) { $costArr = array(); @@ -728,7 +994,6 @@ XMLRequest; foreach ($arr as $shipElement){ $code = (string)$shipElement->Service->Code; - #$shipment = $this->getShipmentByCode($code); if (in_array($code, $allowedMethods)) { if ($negotiatedActive) { @@ -742,12 +1007,9 @@ XMLRequest; $responseCurrencyCode = (string) $shipElement->TotalCharges->CurrencyCode; if ($responseCurrencyCode) { if (in_array($responseCurrencyCode, $allowedCurrencies)) { - $cost *= $this->_getBaseCurrencyRate($responseCurrencyCode); + $cost = (float) $cost * $this->_getBaseCurrencyRate($responseCurrencyCode); } else { - $errorTitle = Mage::helper('directory') - ->__('Can\'t convert rate from "%s-%s".', - $responseCurrencyCode, - $this->_request->getPackageCurrency()->getCode()); + $errorTitle = Mage::helper('directory')->__('Can\'t convert rate from "%s-%s".', $responseCurrencyCode, $this->_request->getPackageCurrency()->getCode()); $error = Mage::getModel('shipping/rate_result_error'); $error->setCarrier('ups'); $error->setCarrierTitle($this->getConfigData('title')); @@ -768,7 +1030,6 @@ XMLRequest; $error = Mage::getModel('shipping/rate_result_error'); $error->setCarrier('ups'); $error->setCarrierTitle($this->getConfigData('title')); - Mage::log($errorTitle); $error->setErrorMessage($this->getConfigData('specificerrmsg')); } } @@ -782,7 +1043,6 @@ XMLRequest; if(!isset($errorTitle)){ $errorTitle = Mage::helper('usa')->__('Cannot retrieve shipping rates'); } - Mage::log($errorTitle); $error->setErrorMessage($this->getConfigData('specificerrmsg')); $result->append($error); } else { @@ -801,6 +1061,12 @@ XMLRequest; return $result; } + /** + * Get tracking + * + * @param mixed $trackings + * @return mixed + */ public function getTracking($trackings) { $return = array(); @@ -819,6 +1085,11 @@ XMLRequest; return $this->_result; } + /** + * Set xml access request + * + * @return null + */ protected function setXMLAccessRequest() { $userid = $this->getConfigData('username'); @@ -835,6 +1106,12 @@ XMLRequest; XMLAuth; } + /** + * Get cgi tracking + * + * @param mixed $trackings + * @return mixed + */ protected function _getCgiTracking($trackings) { //ups no longer support tracking for data streaming version @@ -847,7 +1124,10 @@ XMLAuth; $status->setCarrierTitle($this->getConfigData('title')); $status->setTracking($tracking); $status->setPopup(1); - $status->setUrl("http://wwwapps.ups.com/WebTracking/processInputRequest?HTMLVersion=5.0&error_carried=true&tracknums_displayed=5&TypeOfInquiryNumber=T&loc=en_US&InquiryNumber1=$tracking&AgreeToTermsAndConditions=yes"); + $status->setUrl("http://wwwapps.ups.com/WebTracking/processInputRequest?HTMLVersion=5.0&error_carried=true" + . "&tracknums_displayed=5&TypeOfInquiryNumber=T&loc=en_US&InquiryNumber1=$tracking" + . "&AgreeToTermsAndConditions=yes" + ); $result->append($status); } @@ -855,6 +1135,12 @@ XMLAuth; return $result; } + /** + * Get xml tracking + * + * @param mixed $trackings + * @return mixed + */ protected function _getXmlTracking($trackings) { $url = $this->getConfigData('tracking_xml_url'); @@ -902,6 +1188,13 @@ XMLAuth; return $this->_result; } + /** + * Parse xml tracking response + * + * @param string $trackingvalue + * @param string $response + * @return null + */ protected function _parseXmlTrackingResponse($trackingvalue, $xmlResponse) { $errorTitle = 'Unable to retrieve tracking'; @@ -1008,6 +1301,11 @@ XMLAuth; return $this->_result; } + /** + * Get tracking response + * + * @return string + */ public function getResponse() { $statuses = ''; @@ -1045,4 +1343,467 @@ XMLAuth; } return $arr; } + + /** + * Form XML for shipment request + * + * @param Varien_Object $request + * @return string + */ + protected function _formShipmentRequest(Varien_Object $request) + { + $packageParams = $request->getPackageParams(); + $height = $packageParams->getHeight(); + $width = $packageParams->getWidth(); + $length = $packageParams->getLength(); + $weightUnits = $packageParams->getWeightUnits() == Zend_Measure_Weight::POUND ? 'LBS' : 'KGS'; + $dimensionsUnits = $packageParams->getDimensionUnits() == Zend_Measure_Length::INCH ? 'IN' : 'CM'; + + $itemsDesc = array(); + $itemsShipment = $request->getPackageItems(); + foreach ($itemsShipment as $itemShipment) { + $item = new Varien_Object(); + $item->setData($itemShipment); + $itemsDesc[] = $item->getName(); + } + + $xmlRequest = new SimpleXMLElement(''); + $requestPart = $xmlRequest->addChild('Request'); + $requestPart->addChild('RequestAction', 'ShipConfirm'); + $requestPart->addChild('RequestOption', 'nonvalidate'); + + $shipmentPart = $xmlRequest->addChild('Shipment'); + if ($request->getIsReturn()) { + $returnPart = $shipmentPart->addChild('ReturnService'); + // UPS Print Return Label + $returnPart->addChild('Code', '9'); + } + $shipmentPart->addChild('Description', substr(implode(' ', $itemsDesc), 0, 35));//empirical + + $shipperPart = $shipmentPart->addChild('Shipper'); + if ($request->getIsReturn()) { + $shipperPart->addChild('Name', $request->getRecipientContactCompanyName()); + $shipperPart->addChild('AttentionName', $request->getRecipientContactPersonName()); + $shipperPart->addChild('ShipperNumber', $this->getConfigData('shipper_number')); + $shipperPart->addChild('PhoneNumber', $request->getRecipientContactPhoneNumber()); + + $addressPart = $shipperPart->addChild('Address'); + $addressPart->addChild('AddressLine1', $request->getRecipientAddressStreet()); + $addressPart->addChild('AddressLine2', $request->getRecipientAddressStreet2()); + $addressPart->addChild('City', $request->getRecipientAddressCity()); + $addressPart->addChild('CountryCode', $request->getRecipientAddressCountryCode()); + $addressPart->addChild('PostalCode', $request->getRecipientAddressPostalCode()); + if ($request->getRecipientAddressStateOrProvinceCode()) { + $addressPart->addChild('StateProvinceCode', $request->getRecipientAddressStateOrProvinceCode()); + } + } else { + $shipperPart->addChild('Name', $request->getShipperContactCompanyName()); + $shipperPart->addChild('AttentionName', $request->getShipperContactPersonName()); + $shipperPart->addChild('ShipperNumber', $this->getConfigData('shipper_number')); + $shipperPart->addChild('PhoneNumber', $request->getShipperContactPhoneNumber()); + + $addressPart = $shipperPart->addChild('Address'); + $addressPart->addChild('AddressLine1', $request->getShipperAddressStreet()); + $addressPart->addChild('AddressLine2', $request->getShipperAddressStreet2()); + $addressPart->addChild('City', $request->getShipperAddressCity()); + $addressPart->addChild('CountryCode', $request->getShipperAddressCountryCode()); + $addressPart->addChild('PostalCode', $request->getShipperAddressPostalCode()); + if ($request->getShipperAddressStateOrProvinceCode()) { + $addressPart->addChild('StateProvinceCode', $request->getShipperAddressStateOrProvinceCode()); + } + } + + $shipToPart = $shipmentPart->addChild('ShipTo'); + $shipToPart->addChild('AttentionName', $request->getRecipientContactPersonName()); + $shipToPart->addChild('CompanyName', $request->getRecipientContactCompanyName() + ? $request->getRecipientContactCompanyName() + : 'N/A'); + $shipToPart->addChild('PhoneNumber', $request->getRecipientContactPhoneNumber()); + + $addressPart = $shipToPart->addChild('Address'); + $addressPart->addChild('AddressLine1', $request->getRecipientAddressStreet1()); + $addressPart->addChild('AddressLine2', $request->getRecipientAddressStreet2()); + $addressPart->addChild('City', $request->getRecipientAddressCity()); + $addressPart->addChild('CountryCode', $request->getRecipientAddressCountryCode()); + $addressPart->addChild('PostalCode', $request->getRecipientAddressPostalCode()); + if ($request->getRecipientAddressStateOrProvinceCode()) { + $addressPart->addChild('StateProvinceCode', $request->getRecipientAddressRegionCode()); + } + if ($this->getConfigData('dest_type') == 'RES') { + $addressPart->addChild('ResidentialAddress'); + } + + if ($request->getIsReturn()) { + $shipFromPart = $shipmentPart->addChild('ShipFrom'); + $shipFromPart->addChild('AttentionName', $request->getShipperContactPersonName()); + $shipFromPart->addChild('CompanyName', $request->getShipperContactCompanyName() + ? $request->getShipperContactCompanyName() + : $request->getShipperContactPersonName()); + $shipFromAddress = $shipFromPart->addChild('Address'); + $shipFromAddress->addChild('AddressLine1', $request->getShipperAddressStreet1()); + $shipFromAddress->addChild('AddressLine2', $request->getShipperAddressStreet2()); + $shipFromAddress->addChild('City', $request->getShipperAddressCity()); + $shipFromAddress->addChild('CountryCode', $request->getShipperAddressCountryCode()); + $shipFromAddress->addChild('PostalCode', $request->getShipperAddressPostalCode()); + if ($request->getShipperAddressStateOrProvinceCode()) { + $shipFromAddress->addChild('StateProvinceCode', $request->getShipperAddressStateOrProvinceCode()); + } + + $addressPart = $shipToPart->addChild('Address'); + $addressPart->addChild('AddressLine1', $request->getShipperAddressStreet1()); + $addressPart->addChild('AddressLine2', $request->getShipperAddressStreet2()); + $addressPart->addChild('City', $request->getShipperAddressCity()); + $addressPart->addChild('CountryCode', $request->getShipperAddressCountryCode()); + $addressPart->addChild('PostalCode', $request->getShipperAddressPostalCode()); + if ($request->getShipperAddressStateOrProvinceCode()) { + $addressPart->addChild('StateProvinceCode', $request->getShipperAddressStateOrProvinceCode()); + } + if ($this->getConfigData('dest_type') == 'RES') { + $addressPart->addChild('ResidentialAddress'); + } + } + + $servicePart = $shipmentPart->addChild('Service'); + $servicePart->addChild('Code', $request->getShippingMethod()); + $packagePart = $shipmentPart->addChild('Package'); + $packagePart->addChild('Description', substr(implode(' ', $itemsDesc), 0, 35));//empirical + $packagePart->addChild('PackagingType') + ->addChild('Code', $request->getPackagingType()); + $packageWeight = $packagePart->addChild('PackageWeight'); + $packageWeight->addChild('Weight', $request->getPackageWeight()); + $packageWeight->addChild('UnitOfMeasurement')->addChild('Code', $weightUnits); + + // set dimensions + if ($length || $width || $height) { + $packageDimensions = $packagePart->addChild('Dimensions'); + $packageDimensions->addChild('UnitOfMeasurement')->addChild('Code', $dimensionsUnits); + $packageDimensions->addChild('Length', $length); + $packageDimensions->addChild('Width', $width); + $packageDimensions->addChild('Height', $height); + } + + // ups support reference number only for domestic service + if ($this->_isUSCountry($request->getRecipientAddressCountryCode()) + && $this->_isUSCountry($request->getShipperAddressCountryCode()) + ) { + if ($request->getReferenceData()) { + $referenceData = $request->getReferenceData() . $request->getPackageId(); + } else { + $referenceData = 'Order #' + . $request->getOrderShipment()->getOrder()->getIncrementId() + . ' P' + . $request->getPackageId(); + } + $referencePart = $packagePart->addChild('ReferenceNumber'); + $referencePart->addChild('Code', '02'); + $referencePart->addChild('Value', $referenceData); + } + + $deliveryConfirmation = $packageParams->getDeliveryConfirmation(); + if ($deliveryConfirmation) { + /** @var $serviceOptionsNode SimpleXMLElement */ + $serviceOptionsNode = null; + switch ($this->_getDeliveryConfirmationLevel($request->getRecipientAddressCountryCode())) { + case self::DELIVERY_CONFIRMATION_PACKAGE: + $serviceOptionsNode = $packagePart->addChild('PackageServiceOptions'); + break; + case self::DELIVERY_CONFIRMATION_SHIPMENT: + $serviceOptionsNode = $shipmentPart->addChild('ShipmentServiceOptions'); + break; + } + if (!is_null($serviceOptionsNode)) { + $serviceOptionsNode + ->addChild('DeliveryConfirmation') + ->addChild('DCISType', $packageParams->getDeliveryConfirmation()); + } + } + + $shipmentPart->addChild('PaymentInformation') + ->addChild('Prepaid') + ->addChild('BillShipper') + ->addChild('AccountNumber', $this->getConfigData('shipper_number')); + + if ($request->getPackagingType() != $this->getCode('container', 'ULE') + && $request->getShipperAddressCountryCode() == Mage_Usa_Model_Shipping_Carrier_Abstract::USA_COUNTRY_ID + && ($request->getRecipientAddressCountryCode() == 'CA' //Canada + || $request->getRecipientAddressCountryCode() == 'PR' //Puerto Rico + )) { + $invoiceLineTotalPart = $shipmentPart->addChild('InvoiceLineTotal'); + $invoiceLineTotalPart->addChild('CurrencyCode', $request->getBaseCurrencyCode()); + $invoiceLineTotalPart->addChild('MonetaryValue', ceil($packageParams->getCustomsValue())); + } + + $labelPart = $xmlRequest->addChild('LabelSpecification'); + $labelPart->addChild('LabelPrintMethod') + ->addChild('Code', 'GIF'); + $labelPart->addChild('LabelImageFormat') + ->addChild('Code', 'GIF'); + + $this->setXMLAccessRequest(); + $xmlRequest = $this->_xmlAccessRequest . $xmlRequest->asXml(); + return $xmlRequest; + } + + /** + * Send and process shipment accept request + * + * @param SimpleXMLElement + * @return Varien_Object + */ + protected function _sendShipmentAcceptRequest(SimpleXMLElement $shipmentConfirmResponse) + { + $xmlRequest = new SimpleXMLElement(''); + $request = $xmlRequest->addChild('Request'); + $request->addChild('RequestAction', 'ShipAccept'); + $xmlRequest->addChild('ShipmentDigest', $shipmentConfirmResponse->ShipmentDigest); + + $debugData = array('request' => $xmlRequest->asXML()); + try { + $url = $this->_defaultUrls['ShipAccept']; + + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_xmlAccessRequest . $xmlRequest->asXML()); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (boolean)$this->getConfigFlag('mode_xml')); + $xmlResponse = curl_exec ($ch); + + $debugData['result'] = $xmlResponse; + $this->_setCachedQuotes($xmlRequest, $xmlResponse); + } catch (Exception $e) { + $debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode()); + $xmlResponse = ''; + } + + try { + $response = new SimpleXMLElement($xmlResponse); + } catch (Exception $e) { + $debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode()); + } + + $result = new Varien_Object(); + if (isset($response->Error)) { + $result->setErrors((string)$response->Error->ErrorDescription); + } else { + $shippingLabelContent = (string)$response->ShipmentResults->PackageResults->LabelImage->GraphicImage; + $trackingNumber = (string)$response->ShipmentResults->PackageResults->TrackingNumber; + + $result->setShippingLabelContent(base64_decode($shippingLabelContent)); + $result->setTrackingNumber($trackingNumber); + } + + $this->_debug($debugData); + return $result; + } + + /** + * Do shipment request to carrier web service, obtain Print Shipping Labels and process errors in response + * + * @param Varien_Object $request + * @return Varien_Object + */ + protected function _doShipmentRequest(Varien_Object $request) + { + $this->_prepareShipmentRequest($request); + $result = new Varien_Object(); + $xmlRequest = $this->_formShipmentRequest($request); + $xmlResponse = $this->_getCachedQuotes($xmlRequest); + + if ($xmlResponse === null) { + $url = $this->getConfigData('url'); + if (!$url) { + $url = $this->_defaultUrls['ShipConfirm']; + } + + $debugData = array('request' => $xmlRequest); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (boolean)$this->getConfigFlag('mode_xml')); + $xmlResponse = curl_exec($ch); + if ($xmlResponse === false) { + throw new Exception(curl_error($ch)); + } else { + $debugData['result'] = $xmlResponse; + $this->_setCachedQuotes($xmlRequest, $xmlResponse); + } + } + + try { + $response = new SimpleXMLElement($xmlResponse); + } catch (Exception $e) { + $debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode()); + $result->setErrors($e->getMessage()); + } + + if (isset($response->Response->Error) + && in_array($response->Response->Error->ErrorSeverity, array('Hard', 'Transient')) + ) { + $result->setErrors((string)$response->Response->Error->ErrorDescription); + } + + $this->_debug($debugData); + + if ($result->hasErrors() || empty($response)) { + return $result; + } else { + return $this->_sendShipmentAcceptRequest($response); + } + } + + /** + * Return container types of carrier + * + * @param Varien_Object|null $params + * @return array|bool + */ + public function getContainerTypes(Varien_Object $params = null) + { + if ($params == null) { + return $this->_getAllowedContainers($params); + } + $method = $params->getMethod(); + $countryShipper = $params->getCountryShipper(); + $countryRecipient = $params->getCountryRecipient(); + + if (($countryShipper == self::USA_COUNTRY_ID + && $countryRecipient == self::CANADA_COUNTRY_ID) + || ($countryShipper == self::CANADA_COUNTRY_ID + && $countryRecipient == self::USA_COUNTRY_ID) + || ($countryShipper == self::MEXICO_COUNTRY_ID + && $countryRecipient == self::USA_COUNTRY_ID) + && $method == '11' // UPS Standard + ) { + $containerTypes = array(); + if ($method == '07' // Worldwide Express + || $method == '08' // Worldwide Expedited + || $method == '65' // Worldwide Saver + + ) { + // Worldwide Expedited + if ($method != '08') { + $containerTypes = array( + '01' => Mage::helper('usa')->__('UPS Letter Envelope'), + '24' => Mage::helper('usa')->__('UPS Worldwide 25 kilo'), + '25' => Mage::helper('usa')->__('UPS Worldwide 10 kilo'), + ); + } + $containerTypes = $containerTypes + array( + '03' => Mage::helper('usa')->__('UPS Tube'), + '04' => Mage::helper('usa')->__('PAK'), + '2a' => Mage::helper('usa')->__('Small Express Box'), + '2b' => Mage::helper('usa')->__('Medium Express Box'), + '2c' => Mage::helper('usa')->__('Large Express Box'), + ); + } + return array('00' => Mage::helper('usa')->__('Customer Packaging')) + $containerTypes; + } elseif ($countryShipper == self::USA_COUNTRY_ID && $countryRecipient == self::PUERTORICO_COUNTRY_ID + && ($method == '03' // UPS Ground + || $method == '02' // UPS Second Day Air + || $method == '01' // UPS Next Day Air + )) { + // Container types should be the same as for domestic + $params->setCountryRecipient(self::USA_COUNTRY_ID); + $containerTypes = $this->_getAllowedContainers($params); + $params->setCountryRecipient($countryRecipient); + return $containerTypes; + } + return $this->_getAllowedContainers($params); + } + + /** + * Return all container types of carrier + * + * @return array|bool + */ + public function getContainerTypesAll() + { + $codes = $this->getCode('container'); + $descriptions = $this->getCode('container_description'); + $result = array(); + foreach ($codes as $key => &$code) { + $result[$code] = $descriptions[$key]; + } + return $result; + + } + + /** + * Return structured data of containers witch related with shipping methods + * + * @return array|bool + */ + public function getContainerTypesFilter() + { + return $this->getCode('containers_filter'); + } + + /** + * Return delivery confirmation types of carrier + * + * @param Varien_Object|null $params + * @return array|bool + */ + public function getDeliveryConfirmationTypes(Varien_Object $params = null) + { + $countryRecipient = $params != null ? $params->getCountryRecipient() : null; + $deliveryConfirmationTypes = array(); + switch ($this->_getDeliveryConfirmationLevel($countryRecipient)) { + case self::DELIVERY_CONFIRMATION_PACKAGE: + $deliveryConfirmationTypes = array( + 1 => Mage::helper('usa')->__('Delivery Confirmation'), + 2 => Mage::helper('usa')->__('Signature Required'), + 3 => Mage::helper('usa')->__('Adult Signature Required'), + ); + break; + case self::DELIVERY_CONFIRMATION_SHIPMENT: + $deliveryConfirmationTypes = array( + 1 => Mage::helper('usa')->__('Signature Required'), + 2 => Mage::helper('usa')->__('Adult Signature Required'), + ); + } + array_unshift($deliveryConfirmationTypes, Mage::helper('usa')->__('Not Required')); + + return $deliveryConfirmationTypes; + } + + /** + * Get Container Types, that could be customized for UPS carrier + * + * @return array + */ + public function getCustomizableContainerTypes() + { + $result = array(); + $containerTypes = $this->getCode('container'); + foreach (parent::getCustomizableContainerTypes() as $containerType) { + $result[$containerType] = $containerTypes[$containerType]; + } + return $result; + } + + /** + * Get delivery confirmation level based on origin/destination + * Return null if delivery confirmation is not acceptable + * + * @var string $countyDest + * @return int|null + */ + protected function _getDeliveryConfirmationLevel($countyDest = null) { + if (is_null($countyDest)) { + return null; + } + + if ($countyDest == Mage_Usa_Model_Shipping_Carrier_Abstract::USA_COUNTRY_ID) { + return self::DELIVERY_CONFIRMATION_PACKAGE; + } + + return self::DELIVERY_CONFIRMATION_SHIPMENT; + } } diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Container.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Container.php index c39e59f..3c52bf0 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Container.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Container.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/DestType.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/DestType.php index 8afafe2..ba066fd 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/DestType.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/DestType.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Freemethod.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Freemethod.php index 824bd83..43c5fed 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Freemethod.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Freemethod.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Method.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Method.php index 3bc8086..f4da816 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Method.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Method.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Mode.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Mode.php index b5469d9..1c2c0e5 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Mode.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Mode.php @@ -20,15 +20,16 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** - * UPS (UPS XML) Modesource model + * UPS (UPS XML) mode source model * - * @category Mage - * @package Mage_Usa + * @deprecated since 1.7.0.0 + * @category Mage + * @package Mage_Usa * @author Magento Core Team */ class Mage_Usa_Model_Shipping_Carrier_Ups_Source_Mode diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/OriginShipment.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/OriginShipment.php index 3c5dd6c..874176d 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/OriginShipment.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/OriginShipment.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Pickup.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Pickup.php index 97fdfd6..ca574fe 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Pickup.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Pickup.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Type.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Type.php index be1b75e..8813e97 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Type.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Type.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Unitofmeasure.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Unitofmeasure.php index 3c760db..6814edf 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Unitofmeasure.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Unitofmeasure.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php index 9b2d24d..62173e8 100644 --- app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php +++ app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -38,51 +38,98 @@ class Mage_Usa_Model_Shipping_Carrier_Usps implements Mage_Shipping_Model_Carrier_Interface { /** + * USPS containers + */ + const CONTAINER_VARIABLE = 'VARIABLE'; + const CONTAINER_FLAT_RATE_BOX = 'FLAT RATE BOX'; + const CONTAINER_FLAT_RATE_ENVELOPE = 'FLAT RATE ENVELOPE'; + const CONTAINER_RECTANGULAR = 'RECTANGULAR'; + const CONTAINER_NONRECTANGULAR = 'NONRECTANGULAR'; + + /** + * USPS size + */ + const SIZE_REGULAR = 'REGULAR'; + const SIZE_LARGE = 'LARGE'; + + /** + * Default api revision + * + * @var int + */ + const DEFAULT_REVISION = 2; + + /** + * Code of the carrier + * + * @var string + */ + const CODE = 'usps'; + + /** + * Ounces in one pound for conversion + */ + const OUNCES_POUND = 16; + + /** + * Code of the carrier + * + * @var string + */ + protected $_code = self::CODE; + + /** * Destination Zip Code required flag * * @var boolean + * @deprecated since 1.7.0 functionality implemented in Mage_Usa_Model_Shipping_Carrier_Abstract */ protected $_isZipCodeRequired; - protected $_code = 'usps'; - + /** + * Rate request data + * + * @var Mage_Shipping_Model_Rate_Request|null + */ protected $_request = null; + /** + * Raw rate request data + * + * @var Varien_Object|null + */ + protected $_rawRequest = null; + + /** + * Rate result data + * + * @var Mage_Shipping_Model_Rate_Result|null + */ protected $_result = null; + /** + * Default cgi gateway url + * + * @var string + */ protected $_defaultGatewayUrl = 'http://production.shippingapis.com/ShippingAPI.dll'; /** - * Check is Zip Code Required + * Container types that could be customized for USPS carrier * - * @return boolean + * @var array */ - public function isZipCodeRequired() - { - if (!is_null($this->_isZipCodeRequired)) { - return $this->_isZipCodeRequired; - } - - return parent::isZipCodeRequired(); - } + protected $_customizableContainerTypes = array('VARIABLE', 'RECTANGULAR', 'NONRECTANGULAR'); /** - * Processing additional validation to check is carrier applicable. + * Collect and get rates * * @param Mage_Shipping_Model_Rate_Request $request - * @return Mage_Shipping_Model_Carrier_Abstract|Mage_Shipping_Model_Rate_Result_Error|boolean + * @return Mage_Shipping_Model_Rate_Result|bool|null */ - public function proccessAdditionalValidation(Mage_Shipping_Model_Rate_Request $request) - { - // zip code required for US - $this->_isZipCodeRequired = $this->_isUSCountry($request->getDestCountryId()); - - return parent::proccessAdditionalValidation($request); - } - public function collectRates(Mage_Shipping_Model_Rate_Request $request) { - if (!$this->getConfigFlag('active')) { + if (!$this->getConfigFlag($this->_activeFlag)) { return false; } @@ -95,6 +142,12 @@ class Mage_Usa_Model_Shipping_Carrier_Usps return $this->getResult(); } + /** + * Prepare and set request to this instance + * + * @param Mage_Shipping_Model_Rate_Request $request + * @return Mage_Usa_Model_Shipping_Carrier_Usps + */ public function setRequest(Mage_Shipping_Model_Rate_Request $request) { $this->_request = $request; @@ -128,6 +181,34 @@ class Mage_Usa_Model_Shipping_Carrier_Usps } $r->setSize($size); + if ($request->getGirth()) { + $girth = $request->getGirth(); + } else { + $girth = $this->getConfigData('girth'); + } + $r->setGirth($girth); + + if ($request->getHeight()) { + $height = $request->getHeight(); + } else { + $height = $this->getConfigData('height'); + } + $r->setHeight($height); + + if ($request->getLength()) { + $length = $request->getLength(); + } else { + $length = $this->getConfigData('length'); + } + $r->setLength($length); + + if ($request->getWidth()) { + $width = $request->getWidth(); + } else { + $width = $this->getConfigData('width'); + } + $r->setWidth($width); + if ($request->getUspsMachinable()) { $machinable = $request->getUspsMachinable(); } else { @@ -138,7 +219,19 @@ class Mage_Usa_Model_Shipping_Carrier_Usps if ($request->getOrigPostcode()) { $r->setOrigPostal($request->getOrigPostcode()); } else { - $r->setOrigPostal(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_POSTCODE, $this->getStore())); + $r->setOrigPostal(Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP, + $request->getStoreId() + )); + } + + if ($request->getOrigCountryId()) { + $r->setOrigCountryId($request->getOrigCountryId()); + } else { + $r->setOrigCountryId(Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, + $request->getStoreId() + )); } if ($request->getDestCountryId()) { @@ -159,7 +252,7 @@ class Mage_Usa_Model_Shipping_Carrier_Usps $weight = $this->getTotalNumOfBoxes($request->getPackageWeight()); $r->setWeightPounds(floor($weight)); - $r->setWeightOunces(round(($weight-floor($weight)) * 16, 1)); + $r->setWeightOunces(round(($weight-floor($weight)) * self::OUNCES_POUND, 1)); if ($request->getFreeMethodWeight()!=$request->getPackageWeight()) { $r->setFreeMethodWeight($request->getFreeMethodWeight()); } @@ -167,28 +260,46 @@ class Mage_Usa_Model_Shipping_Carrier_Usps $r->setValue($request->getPackageValue()); $r->setValueWithDiscount($request->getPackageValueWithDiscount()); + $r->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax()); + $this->_rawRequest = $r; return $this; } + /** + * Get result of request + * + * @return mixed + */ public function getResult() { return $this->_result; } + /** + * Get quotes + * + * @return Mage_Shipping_Model_Rate_Result + */ protected function _getQuotes() { return $this->_getXmlQuotes(); } + /** + * Set free method request + * + * @param $freeMethod + * @return void + */ protected function _setFreeMethodRequest($freeMethod) { $r = $this->_rawRequest; $weight = $this->getTotalNumOfBoxes($r->getFreeMethodWeight()); $r->setWeightPounds(floor($weight)); - $r->setWeightOunces(round(($weight-floor($weight)) * 16, 1)); + $r->setWeightOunces(round(($weight-floor($weight)) * self::OUNCES_POUND, 1)); $r->setService($freeMethod); } @@ -201,57 +312,86 @@ class Mage_Usa_Model_Shipping_Carrier_Usps protected function _getXmlQuotes() { $r = $this->_rawRequest; - if ($this->_isUSCountry($r->getDestCountryId())) { - $xml = new SimpleXMLElement(''); + // The origin address(shipper) must be only in USA + if(!$this->_isUSCountry($r->getOrigCountryId())){ + $responseBody = ''; + return $this->_parseXmlResponse($responseBody); + } + + if ($this->_isUSCountry($r->getDestCountryId())) { + $xml = new SimpleXMLElement(''); $xml->addAttribute('USERID', $r->getUserId()); + // according to usps v4 documentation + $xml->addChild('Revision', '2'); + $package = $xml->addChild('Package'); - $package->addAttribute('ID', 0); - $service = $this->getCode('service_to_code', $r->getService()); - if (!$service) { - $service = $r->getService(); - } - $package->addChild('Service', $service); + $package->addAttribute('ID', 0); + $service = $this->getCode('service_to_code', $r->getService()); + if (!$service) { + $service = $r->getService(); + } + if ($r->getContainer() == 'FLAT RATE BOX' || $r->getContainer() == 'FLAT RATE ENVELOPE') { + $service = 'PRIORITY'; + } + $package->addChild('Service', $service); - // no matter Letter, Flat or Parcel, use Parcel - if ($r->getService() == 'FIRST CLASS') { - $package->addChild('FirstClassMailType', 'PARCEL'); - } - $package->addChild('ZipOrigination', $r->getOrigPostal()); - //only 5 chars avaialble - $package->addChild('ZipDestination', substr($r->getDestPostal(),0,5)); - $package->addChild('Pounds', $r->getWeightPounds()); - $package->addChild('Ounces', $r->getWeightOunces()); -// $package->addChild('Pounds', '0'); -// $package->addChild('Ounces', '3'); - - // Because some methods don't accept VARIABLE and (NON)RECTANGULAR containers - if (strtoupper($r->getContainer()) == 'FLAT RATE ENVELOPE' || strtoupper($r->getContainer()) == 'FLAT RATE BOX') { - $package->addChild('Container', $r->getContainer()); + // no matter Letter, Flat or Parcel, use Parcel + if ($r->getService() == 'FIRST CLASS' || $r->getService() == 'FIRST CLASS HFP COMMERCIAL') { + $package->addChild('FirstClassMailType', 'PARCEL'); + } + $package->addChild('ZipOrigination', $r->getOrigPostal()); + //only 5 chars avaialble + $package->addChild('ZipDestination', substr($r->getDestPostal(), 0, 5)); + $package->addChild('Pounds', $r->getWeightPounds()); + $package->addChild('Ounces', $r->getWeightOunces()); + // Because some methods don't accept VARIABLE and (NON)RECTANGULAR containers + $package->addChild('Container', $r->getContainer()); + $package->addChild('Size', $r->getSize()); + if ($r->getSize() == 'LARGE') { + $package->addChild('Width', $r->getWidth()); + $package->addChild('Length', $r->getLength()); + $package->addChild('Height', $r->getHeight()); + if ($r->getContainer() == 'NONRECTANGULAR' || $r->getContainer() == 'VARIABLE') { + $package->addChild('Girth', $r->getGirth()); } + } + $package->addChild('Machinable', $r->getMachinable()); - $package->addChild('Size', $r->getSize()); - $package->addChild('Machinable', $r->getMachinable()); - - $api = 'RateV3'; - $request = $xml->asXML(); - + $api = 'RateV4'; } else { - $xml = new SimpleXMLElement(''); - + $xml = new SimpleXMLElement(''); $xml->addAttribute('USERID', $r->getUserId()); + // according to usps v4 documentation + $xml->addChild('Revision', '2'); $package = $xml->addChild('Package'); - $package->addAttribute('ID', 0); - $package->addChild('Pounds', $r->getWeightPounds()); - $package->addChild('Ounces', $r->getWeightOunces()); - $package->addChild('MailType', 'Package'); - $package->addChild('ValueOfContents', $r->getValue()); - $package->addChild('Country', $r->getDestCountryName()); + $package->addAttribute('ID', 0); + $package->addChild('Pounds', $r->getWeightPounds()); + $package->addChild('Ounces', $r->getWeightOunces()); + $package->addChild('MailType', 'All'); + $package->addChild('ValueOfContents', $r->getValue()); + $package->addChild('Country', $r->getDestCountryName()); + $package->addChild('Container', $r->getContainer()); + $package->addChild('Size', $r->getSize()); + $width = $length = $height = $girth = ''; + if ($r->getSize() == 'LARGE') { + $width = $r->getWidth(); + $length = $r->getLength(); + $height = $r->getHeight(); + if ($r->getContainer() == 'NONRECTANGULAR') { + $girth = $r->getGirth(); + } + } + $package->addChild('Width', $width); + $package->addChild('Length', $length); + $package->addChild('Height', $height); + $package->addChild('Girth', $girth); + - $api = 'IntlRate'; - $request = $xml->asXML(); + $api = 'IntlRateV2'; } + $request = $xml->asXML(); $responseBody = $this->_getCachedQuotes($request); if ($responseBody === null) { @@ -271,8 +411,7 @@ class Mage_Usa_Model_Shipping_Carrier_Usps $debugData['result'] = $responseBody; $this->_setCachedQuotes($request, $responseBody); - } - catch (Exception $e) { + } catch (Exception $e) { $debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode()); $responseBody = ''; } @@ -294,18 +433,32 @@ class Mage_Usa_Model_Shipping_Carrier_Usps $priceArr = array(); if (strlen(trim($response)) > 0) { if (strpos(trim($response), '#', $response)) { - $response = str_replace('', '', $response); + if (strpos($response, '') !== false) { + $response = str_replace( + '', + '', + $response + ); } $xml = simplexml_load_string($response); + if (is_object($xml)) { + if (is_object($xml->Number) && is_object($xml->Description) && (string)$xml->Description!='') { + $errorTitle = (string)$xml->Description; + } elseif (is_object($xml->Package) + && is_object($xml->Package->Error) + && is_object($xml->Package->Error->Description) + && (string)$xml->Package->Error->Description!='' + ) { + $errorTitle = (string)$xml->Package->Error->Description; + } else { + $errorTitle = 'Unknown error'; + } $r = $this->_rawRequest; $allowedMethods = explode(",", $this->getConfigData('allowed_methods')); - - /* - * US Domestic Rates - */ + $allMethods = $this->getCode('method'); + $newMethod = false; if ($this->_isUSCountry($r->getDestCountryId())) { if (is_object($xml->Package) && is_object($xml->Package->Postage)) { foreach ($xml->Package->Postage as $postage) { @@ -313,7 +466,13 @@ class Mage_Usa_Model_Shipping_Carrier_Usps $postage->MailService = $serviceName; if (in_array($serviceName, $allowedMethods)) { $costArr[$serviceName] = (string)$postage->Rate; - $priceArr[$serviceName] = $this->getMethodPrice((string)$postage->Rate, $serviceName); + $priceArr[$serviceName] = $this->getMethodPrice( + (string)$postage->Rate, + $serviceName + ); + } elseif (!in_array($serviceName, $allMethods)) { + $allMethods[] = $serviceName; + $newMethod = true; } } asort($priceArr); @@ -328,13 +487,30 @@ class Mage_Usa_Model_Shipping_Carrier_Usps $service->SvcDescription = $serviceName; if (in_array($serviceName, $allowedMethods)) { $costArr[$serviceName] = (string)$service->Postage; - $priceArr[$serviceName] = $this->getMethodPrice((string)$service->Postage, $serviceName); + $priceArr[$serviceName] = $this->getMethodPrice( + (string)$service->Postage, + $serviceName + ); + } elseif (!in_array($serviceName, $allMethods)) { + $allMethods[] = $serviceName; + $newMethod = true; } } asort($priceArr); } } + /** + * following if statement is obsolete + * we don't have adminhtml/config resoure model + */ + if (false && $newMethod) { + sort($allMethods); + $insert['usps']['fields']['methods']['value'] = $allMethods; + Mage::getResourceModel('adminhtml/config')->saveSectionPost('carriers','','',$insert); + } } + } else { + $errorTitle = 'Response is in the wrong format'; } } @@ -357,10 +533,17 @@ class Mage_Usa_Model_Shipping_Carrier_Usps $result->append($rate); } } - + return $result; } + /** + * Get configuration data of carrier + * + * @param string $type + * @param string $code + * @return array|bool + */ public function getCode($type, $code='') { $codes = array( @@ -373,37 +556,14 @@ class Mage_Usa_Model_Shipping_Carrier_Usps 'PARCEL' => Mage::helper('usa')->__('Parcel Post'), 'MEDIA' => Mage::helper('usa')->__('Media Mail'), 'LIBRARY' => Mage::helper('usa')->__('Library'), -// 'ALL' => Mage::helper('usa')->__('All Services'), ), -/* - 'method'=>array( - 'First-Class', - 'Express Mail', - 'Express Mail PO to PO', - 'Priority Mail', - 'Parcel Post', - 'Express Mail Flat-Rate Envelope', - 'Priority Mail Flat-Rate Box', - 'Bound Printed Matter', - 'Media Mail', - 'Library Mail', - 'Priority Mail Flat-Rate Envelope', - 'Global Express Guaranteed', - 'Global Express Guaranteed Non-Document Rectangular', - 'Global Express Guaranteed Non-Document Non-Rectangular', - 'Express Mail International (EMS)', - 'Express Mail International (EMS) Flat Rate Envelope', - 'Priority Mail International', - 'Priority Mail International Flat Rate Box', - ), -*/ - 'service_to_code'=>array( 'First-Class' => 'FIRST CLASS', 'First-Class Mail International Large Envelope' => 'FIRST CLASS', 'First-Class Mail International Letter' => 'FIRST CLASS', 'First-Class Mail International Package' => 'FIRST CLASS', + 'First-Class Mail International Parcel' => 'FIRST CLASS', 'First-Class Mail' => 'FIRST CLASS', 'First-Class Mail Flat' => 'FIRST CLASS', 'First-Class Mail Large Envelope' => 'FIRST CLASS', @@ -418,10 +578,14 @@ class Mage_Usa_Model_Shipping_Carrier_Usps 'Express Mail' => 'EXPRESS', 'Express Mail PO to PO' => 'EXPRESS', 'Express Mail Flat Rate Envelope' => 'EXPRESS', + 'Express Mail Flat-Rate Envelope Sunday/Holiday Guarantee' => 'EXPRESS', + 'Express Mail Sunday/Holiday Guarantee' => 'EXPRESS', 'Express Mail Flat Rate Envelope Hold For Pickup' => 'EXPRESS', + 'Express Mail Hold For Pickup' => 'EXPRESS', 'Global Express Guaranteed (GXG)' => 'EXPRESS', 'Global Express Guaranteed Non-Document Rectangular' => 'EXPRESS', 'Global Express Guaranteed Non-Document Non-Rectangular' => 'EXPRESS', + 'USPS GXG Envelopes' => 'EXPRESS', 'Express Mail International' => 'EXPRESS', 'Express Mail International Flat Rate Envelope' => 'EXPRESS', 'Priority Mail' => 'PRIORITY', @@ -452,10 +616,130 @@ class Mage_Usa_Model_Shipping_Carrier_Usps 'NONRECTANGULAR' => Mage::helper('usa')->__('Non-rectangular'), ), + 'containers_filter' => array( + array( + 'containers' => array('VARIABLE'), + 'filters' => array( + 'within_us' => array( + 'method' => array( + 'Express Mail Flat Rate Envelope', + 'Express Mail Flat Rate Envelope Hold For Pickup', + 'Priority Mail Flat Rate Envelope', + 'Priority Mail Large Flat Rate Box', + 'Priority Mail Medium Flat Rate Box', + 'Priority Mail Small Flat Rate Box', + 'Express Mail', + 'Priority Mail', + 'Parcel Post', + 'Media Mail', + 'First-Class Mail Large Envelope', + ) + ), + 'from_us' => array( + 'method' => array( + 'Express Mail International Flat Rate Envelope', + 'Priority Mail International Flat Rate Envelope', + 'Priority Mail International Large Flat Rate Box', + 'Priority Mail International Medium Flat Rate Box', + 'Priority Mail International Small Flat Rate Box', + 'Global Express Guaranteed (GXG)', + 'USPS GXG Envelopes', + 'Express Mail International', + 'Priority Mail International', + 'First-Class Mail International Package', + 'First-Class Mail International Large Envelope', + 'First-Class Mail International Parcel', + ) + ) + ) + ), + array( + 'containers' => array('FLAT RATE BOX'), + 'filters' => array( + 'within_us' => array( + 'method' => array( + 'Priority Mail Large Flat Rate Box', + 'Priority Mail Medium Flat Rate Box', + 'Priority Mail Small Flat Rate Box', + ) + ), + 'from_us' => array( + 'method' => array( + 'Priority Mail International Large Flat Rate Box', + 'Priority Mail International Medium Flat Rate Box', + 'Priority Mail International Small Flat Rate Box', + ) + ) + ) + ), + array( + 'containers' => array('FLAT RATE ENVELOPE'), + 'filters' => array( + 'within_us' => array( + 'method' => array( + 'Express Mail Flat Rate Envelope', + 'Express Mail Flat Rate Envelope Hold For Pickup', + 'Priority Mail Flat Rate Envelope', + ) + ), + 'from_us' => array( + 'method' => array( + 'Express Mail International Flat Rate Envelope', + 'Priority Mail International Flat Rate Envelope', + ) + ) + ) + ), + array( + 'containers' => array('RECTANGULAR'), + 'filters' => array( + 'within_us' => array( + 'method' => array( + 'Express Mail', + 'Priority Mail', + 'Parcel Post', + 'Media Mail', + ) + ), + 'from_us' => array( + 'method' => array( + 'USPS GXG Envelopes', + 'Express Mail International', + 'Priority Mail International', + 'First-Class Mail International Package', + 'First-Class Mail International Parcel', + ) + ) + ) + ), + array( + 'containers' => array('NONRECTANGULAR'), + 'filters' => array( + 'within_us' => array( + 'method' => array( + 'Express Mail', + 'Priority Mail', + 'Parcel Post', + 'Media Mail', + ) + ), + 'from_us' => array( + 'method' => array( + 'Global Express Guaranteed (GXG)', + 'USPS GXG Envelopes', + 'Express Mail International', + 'Priority Mail International', + 'First-Class Mail International Package', + 'First-Class Mail International Parcel', + ) + ) + ) + ), + ), + 'size'=>array( 'REGULAR' => Mage::helper('usa')->__('Regular'), 'LARGE' => Mage::helper('usa')->__('Large'), - 'OVERSIZE' => Mage::helper('usa')->__('Oversize'), ), 'machinable'=>array( @@ -463,6 +747,10 @@ class Mage_Usa_Model_Shipping_Carrier_Usps 'false' => Mage::helper('usa')->__('No'), ), + 'delivery_confirmation_types' => array( + 'True' => Mage::helper('usa')->__('Not Required'), + 'False' => Mage::helper('usa')->__('Required'), + ), ); $methods = $this->getConfigData('methods'); @@ -485,6 +773,12 @@ class Mage_Usa_Model_Shipping_Carrier_Usps } } + /** + * Get tracking + * + * @param mixed $trackings + * @return mixed + */ public function getTracking($trackings) { $this->setTrackingReqeust(); @@ -498,6 +792,11 @@ class Mage_Usa_Model_Shipping_Carrier_Usps return $this->_result; } + /** + * Set tracking request + * + * @return null + */ protected function setTrackingReqeust() { $r = new Varien_Object(); @@ -506,9 +805,14 @@ class Mage_Usa_Model_Shipping_Carrier_Usps $r->setUserId($userId); $this->_rawTrackRequest = $r; - } + /** + * Send request for tracking + * + * @param array $tracking + * @return null + */ protected function _getXmlTracking($trackings) { $r = $this->_rawTrackRequest; @@ -517,7 +821,6 @@ class Mage_Usa_Model_Shipping_Carrier_Usps $xml = new SimpleXMLElement(''); $xml->addAttribute('USERID', $r->getUserId()); - $trackid = $xml->addChild('TrackID'); $trackid->addAttribute('ID',$tracking); @@ -549,6 +852,13 @@ class Mage_Usa_Model_Shipping_Carrier_Usps } } + /** + * Parse xml tracking response + * + * @param array $trackingvalue + * @param string $response + * @return null + */ protected function _parseXmlTrackingResponse($trackingvalue, $response) { $errorTitle = Mage::helper('usa')->__('Unable to retrieve tracking'); @@ -559,7 +869,11 @@ class Mage_Usa_Model_Shipping_Carrier_Usps if (is_object($xml)) { if (isset($xml->Number) && isset($xml->Description) && (string)$xml->Description!='') { $errorTitle = (string)$xml->Description; - } elseif (isset($xml->TrackInfo) && isset($xml->TrackInfo->Error) && isset($xml->TrackInfo->Error->Description) && (string)$xml->TrackInfo->Error->Description!='') { + } elseif (isset($xml->TrackInfo) + && isset($xml->TrackInfo->Error) + && isset($xml->TrackInfo->Error->Description) + && (string)$xml->TrackInfo->Error->Description!='' + ) { $errorTitle = (string)$xml->TrackInfo->Error->Description; } else { $errorTitle = Mage::helper('usa')->__('Unknown error'); @@ -595,6 +909,11 @@ class Mage_Usa_Model_Shipping_Carrier_Usps } } + /** + * Get tracking response + * + * @return string + */ public function getResponse() { $statuses = ''; @@ -633,28 +952,6 @@ class Mage_Usa_Model_Shipping_Carrier_Usps } /** - * Check is Сoutry U.S. Possessions and Trust Territories - * - * @param string $countyId - * @return boolean - */ - protected function _isUSCountry($countyId) - { - switch ($countyId) { - case 'AS': // Samoa American - case 'GU': // Guam - case 'MP': // Northern Mariana Islands - case 'PW': // Palau - case 'PR': // Puerto Rico - case 'VI': // Virgin Islands US - case 'US'; // United States - return true; - } - - return false; - } - - /** * Return USPS county name by country ISO 3166-1-alpha-2 code * Return false for unknown countries * @@ -885,6 +1182,7 @@ class Mage_Usa_Model_Shipping_Carrier_Usps 'ZA' => 'South Africa', 'ZM' => 'Zambia', 'ZW' => 'Zimbabwe', + 'US' => 'United States', ); if (isset($countries[$countryId])) { @@ -902,9 +1200,600 @@ class Mage_Usa_Model_Shipping_Carrier_Usps */ protected function _filterServiceName($name) { - $name = (string)preg_replace(array('~<[^/!][^>]+>.*]+>~sU', '~\ - 0.7.1 + 1.6.0.1 @@ -59,6 +59,9 @@ Mage_Usa_Model_Shipping_Carrier_Dhl + + Mage_Usa_Model_Shipping_Carrier_Dhl_International + @@ -92,26 +95,33 @@ - + + + + dhl + + + - + 0 0 - E,N,S,G,IE,E SAT,E 10:30AM + IE,E SAT,E 10:30AM,E,N,S,G Big Box - + R G https://eCommerce.airborne.com/ApiLandingTest.asp - + usa/shipping_carrier_dhl - + + 0 P - - - DHL + + + DHL (Deprecated) This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. 150 F @@ -120,34 +130,37 @@ 1,2,3,4,5 0 - - + + + + + 0 + 0 0 0 - PRIORITYOVERNIGHT,STANDARDOVERNIGHT,FIRSTOVERNIGHT,FEDEX2DAY,FEDEXEXPRESSSAVER,INTERNATIONALPRIORITY,INTERNATIONALECONOMY,INTERNATIONALFIRST,FEDEX1DAYFREIGHT,FEDEX2DAYFREIGHT,FEDEX3DAYFREIGHT,FEDEXGROUND,GROUNDHOMEDELIVERY,INTERNATIONALPRIORITY FREIGHT,INTERNATIONALECONOMY FREIGHT,EUROPEFIRSTINTERNATIONALPRIORITY - - REGULARPICKUP - FEDEXGROUND - https://gateway.fedex.com/GatewayDC + EUROPE_FIRST_INTERNATIONAL_PRIORITY,FEDEX_1_DAY_FREIGHT,FEDEX_2_DAY_FREIGHT,FEDEX_2_DAY,FEDEX_2_DAY_AM,FEDEX_3_DAY_FREIGHT,FEDEX_EXPRESS_SAVER,FEDEX_GROUND,FIRST_OVERNIGHT,GROUND_HOME_DELIVERY,INTERNATIONAL_ECONOMY,INTERNATIONAL_ECONOMY_FREIGHT,INTERNATIONAL_FIRST,INTERNATIONAL_GROUND,INTERNATIONAL_PRIORITY,INTERNATIONAL_PRIORITY_FREIGHT,PRIORITY_OVERNIGHT,SMART_POST,STANDARD_OVERNIGHT,FEDEX_FREIGHT,FEDEX_NATIONAL_FREIGHT + + REGULAR_PICKUP + FEDEX_GROUND 0 usa/shipping_carrier_fedex - YOURPACKAGING + YOUR_PACKAGING Federal Express This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. 150 F O - 0 0 - 1DM,1DML,1DA,1DAL,1DAPI,1DP,1DPL,2DM,2DML,2DA,2DAL,3DS,GND,GNDCOM,GNDRES,STD,XPR,WXS,XPRL,XDM,XDML,XPD + 1DM,1DML,1DA,1DAL,1DAPI,1DP,1DPL,2DM,2DML,2DA,2DAL,3DS,GND,GNDCOM,GNDRES,STD,XPR,WXS,XPRL,XDM,XDML,XPD,01,02,03,07,08,11,12,14,54,59,65 Shipments Originating in United States + 0 CP - + RES GND http://www.ups.com/using/services/rave/qcostcgi.cgi @@ -169,27 +182,50 @@ 1 UPS - 0 0 - Bound Printed Matter,Express Mail,Express Mail Flat Rate Envelope,Express Mail Flat Rate Envelope Hold For Pickup,Express Mail Flat-Rate Envelope Sunday/Holiday Guarantee,Express Mail Hold For Pickup,Express Mail International,Express Mail International Flat Rate Envelope,Express Mail PO to PO,Express Mail Sunday/Holiday Guarantee,First-Class Mail International Large Envelope,First-Class Mail International Letters,First-Class Mail International Package,First-Class,First-Class Mail,First-Class Mail Flat,First-Class Mail Large Envelope,First-Class Mail International,First-Class Mail Letter,First-Class Mail Parcel,First-Class Mail Package,Global Express Guaranteed (GXG),Global Express Guaranteed Non-Document Non-Rectangular,Global Express Guaranteed Non-Document Rectangular,Library Mail,Media Mail,Parcel Post,Priority Mail,Priority Mail Small Flat Rate Box,Priority Mail Medium Flat Rate Box,Priority Mail Large Flat Rate Box,Priority Mail Flat Rate Box,Priority Mail Flat Rate Envelope,Priority Mail International,Priority Mail International Flat Rate Box,Priority Mail International Flat Rate Envelope,Priority Mail International Small Flat Rate Box,Priority Mail International Medium Flat Rate Box,Priority Mail International Large Flat Rate Box,USPS GXG Envelopes + Bound Printed Matter,Express Mail,Express Mail Flat Rate Envelope,Express Mail Flat Rate Envelope Hold For Pickup,Express Mail Flat-Rate Envelope Sunday/Holiday Guarantee,Express Mail Hold For Pickup,Express Mail International,Express Mail International Flat Rate Envelope,Express Mail PO to PO,Express Mail Sunday/Holiday Guarantee,First-Class Mail International Large Envelope,First-Class Mail International Letters,First-Class Mail International Package,First-Class Mail International Parcel,First-Class,First-Class Mail,First-Class Mail Flat,First-Class Mail Large Envelope,First-Class Mail International,First-Class Mail Letter,First-Class Mail Parcel,First-Class Mail Package,Global Express Guaranteed (GXG),Global Express Guaranteed Non-Document Non-Rectangular,Global Express Guaranteed Non-Document Rectangular,Library Mail,Media Mail,Parcel Post,Priority Mail,Priority Mail Small Flat Rate Box,Priority Mail Medium Flat Rate Box,Priority Mail Large Flat Rate Box,Priority Mail Flat Rate Box,Priority Mail Flat Rate Envelope,Priority Mail International,Priority Mail International Flat Rate Box,Priority Mail International Flat Rate Envelope,Priority Mail International Small Flat Rate Box,Priority Mail International Medium Flat Rate Box,Priority Mail International Large Flat Rate Box,USPS GXG Envelopes VARIABLE - - + + http://production.shippingapis.com/ShippingAPI.dll - + https://secure.shippingapis.com/ShippingAPI.dll + 0 + true - Bound Printed Matter,Express Mail,Express Mail Flat Rate Envelope,Express Mail Flat Rate Envelope Hold For Pickup,Express Mail Flat-Rate Envelope Sunday/Holiday Guarantee,Express Mail Hold For Pickup,Express Mail International,Express Mail International Flat Rate Envelope,Express Mail PO to PO,Express Mail Sunday/Holiday Guarantee,First-Class Mail International Large Envelope,First-Class Mail International Letters,First-Class Mail International Package,First-Class,First-Class Mail,First-Class Mail Flat,First-Class Mail Large Envelope,First-Class Mail International,First-Class Mail Letter,First-Class Mail Parcel,First-Class Mail Package,Global Express Guaranteed (GXG),Global Express Guaranteed Non-Document Non-Rectangular,Global Express Guaranteed Non-Document Rectangular,Library Mail,Media Mail,Parcel Post,Priority Mail,Priority Mail Small Flat Rate Box,Priority Mail Medium Flat Rate Box,Priority Mail Large Flat Rate Box,Priority Mail Flat Rate Box,Priority Mail Flat Rate Envelope,Priority Mail International,Priority Mail International Flat Rate Box,Priority Mail International Flat Rate Envelope,Priority Mail International Small Flat Rate Box,Priority Mail International Medium Flat Rate Box,Priority Mail International Large Flat Rate Box,USPS GXG Envelopes + Bound Printed Matter,Express Mail,Express Mail Flat Rate Envelope,Express Mail Flat Rate Envelope Hold For Pickup,Express Mail Flat-Rate Envelope Sunday/Holiday Guarantee,Express Mail Hold For Pickup,Express Mail International,Express Mail International Flat Rate Envelope,Express Mail PO to PO,Express Mail Sunday/Holiday Guarantee,First-Class Mail International Large Envelope,First-Class Mail International Letters,First-Class Mail International Package,First-Class Mail International Parcel,First-Class,First-Class Mail,First-Class Mail Flat,First-Class Mail Large Envelope,First-Class Mail International,First-Class Mail Letter,First-Class Mail Parcel,First-Class Mail Package,Global Express Guaranteed (GXG),Global Express Guaranteed Non-Document Non-Rectangular,Global Express Guaranteed Non-Document Rectangular,Library Mail,Media Mail,Parcel Post,Priority Mail,Priority Mail Small Flat Rate Box,Priority Mail Medium Flat Rate Box,Priority Mail Large Flat Rate Box,Priority Mail Flat Rate Box,Priority Mail Flat Rate Envelope,Priority Mail International,Priority Mail International Flat Rate Box,Priority Mail International Flat Rate Envelope,Priority Mail International Small Flat Rate Box,Priority Mail International Medium Flat Rate Box,Priority Mail International Large Flat Rate Box,USPS GXG Envelopes usa/shipping_carrier_usps REGULAR United States Postal Service + + 0 This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. 70 F O + + usa/shipping_carrier_dhl_international + + 0 + DHL + 0 + 1,3,4,8,P,Q,E,F,H,J,M,V,Y + 2,5,6,7,9,B,C,D,U,K,L,G,W,I,N,O,R,S,T,X + G + https://xmlpi-ea.dhl.com/XMLShippingServlet + + + N + This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. + 1 + K + R + F + O + diff --git app/code/core/Mage/Usa/etc/dhl/international/countries.xml app/code/core/Mage/Usa/etc/dhl/international/countries.xml new file mode 100644 index 0000000..cc6b1f2 --- /dev/null +++ app/code/core/Mage/Usa/etc/dhl/international/countries.xml @@ -0,0 +1,1580 @@ + + + + + EUR + KG + CM + Andorra + + + AED + KG + CM + AP + United Arab Emirates + + + AFN + KG + CM + AP + Afghanistan + + + XCD + KG + CM + AM + Antigua + + + XCD + KG + CM + AM + Anguilla + + + EUR + KG + CM + AP + Albania + + + AMD + KG + CM + AP + Armenia + + + ANG + KG + CM + Netherlands Antilles + + + AOA + KG + CM + Angola + + + ARS + KG + CM + AM + Argentina + + + USD + LB + IN + American Samoa + + + EUR + KG + CM + EA + Austria + 1 + + + AUD + KG + CM + AP + Australia + + + AWG + KG + CM + AM + Aruba + + + AZM + KG + CM + Azerbaijan + + + BAM + KG + CM + AP + Bosnia and Herzegovina + + + BBD + KG + CM + AM + Barbados + + + BDT + KG + CM + AP + Bangladesh + + + EUR + KG + CM + EA + Belgium + 1 + + + XOF + KG + CM + Burkina Faso + + + BGN + KG + CM + EA + Bulgaria + 1 + + + BHD + KG + CM + AP + Bahrain + + + BIF + KG + CM + Burundi + + + XOF + KG + CM + Benin + + + BMD + KG + CM + AM + Bermuda + + + BND + KG + CM + Brunei + + + BOB + KG + CM + AM + Bolivia + +
+ BRL + KG + CM + AM + Brazil +
+ + BSD + KG + CM + AM + Bahamas + + + BTN + KG + CM + Bhutan + + + BWP + KG + CM + Botswana + + + BYR + KG + CM + AP + Belarus + + + BZD + KG + CM + Belize + + + CAD + KG + CM + AM + Canada + + + CDF + KG + CM + Congo, The Democratic Republic of + + + XAF + KG + CM + Central African Republic + + + XAF + KG + CM + Congo + + + CHF + KG + CM + EA + Switzerland + + + XOF + KG + CM + AP + Cote d'Ivoire + + + NZD + KG + CM + Cook Islands + + + CLP + KG + CM + AM + Chile + + + XAF + KG + CM + Cameroon + + + CNY + KG + CM + AP + China, People's Republic + + + COP + KG + CM + AM + Colombia + + + CRC + KG + CM + AM + Costa Rica + + + CUP + KG + CM + Cuba + + + CVE + KG + CM + Cape Verde + + + EUR + KG + CM + AP + Cyprus + 1 + + + CZK + KG + CM + EA + Czech Republic, The + 1 + + + EUR + KG + CM + EA + Germany + 1 + + + DJF + KG + CM + Djibouti + + + DKK + KG + CM + EA + Denmark + 1 + + + XCD + KG + CM + AM + Dominica + + + DOP + KG + CM + AM + Dominican Rep. + + + DZD + KG + CM + AP + Algeria + + + USD + KG + CM + AM + Ecuador + + + EEK + KG + CM + EA + Estonia + 1 + + + EGP + KG + CM + AP + Egypt + + + ERN + KG + CM + Eritrea + + + EUR + KG + CM + EA + Spain + 1 + + + ETB + KG + CM + Ethiopia + + + EUR + KG + CM + EA + Finland + 1 + + + FJD + KG + CM + AP + Fiji + + + FKP + KG + CM + Falkland Islands + + + USD + LB + IN + MICRONESIA, FEDERATED STATES OF + + + DKK + KG + CM + Faroe Islands + + + EUR + KG + CM + EA + France + 1 + + + XAF + KG + CM + Gabon + + + GBP + KG + CM + EA + United Kingdom + 1 + + + XCD + KG + CM + AM + Grenada + + + GEL + KG + CM + Georgia + + + EUR + KG + CM + AM + French Guyana + + + GBP + KG + CM + Guernsey + + + GHS + KG + CM + AP + Ghana + + + GIP + KG + CM + Gibraltar + + + DKK + KG + CM + Greenland + + + GMD + KG + CM + Gambia + + + GNF + KG + CM + Guinea Republic + + + EUR + KG + CM + AM + Guadeloupe + + + XAF + KG + CM + Guinea-Equatorial + + + EUR + KG + CM + EA + Greece + 1 + + + GTQ + KG + CM + AM + Guatemala + + + USD + LB + IN + AM + Guam + + + GWP + KG + CM + Guinea-Bissau + + + GYD + KG + CM + AM + Guyana (British) + + + HKD + KG + CM + AP + Hong Kong + + + HNL + KG + CM + AM + Honduras + +
+ HRK + KG + CM + AP + Croatia + + + HTG + KG + CM + AM + Haiti + + + HUF + KG + CM + EA + Hungary + 1 + + + EUR + KG + CM + Canary Islands, The + + + IDR + KG + CM + AP + Indonesia + + + EUR + KG + CM + EA + Ireland, Republic Of + 1 + + + ILS + KG + CM + AP + Israel + + + INR + KG + CM + AP + India + + + IQD + KG + CM + Iraq + + + IRR + KG + CM + AP + Iran (Islamic Republic of) + + + ISK + KG + CM + EA + Iceland + + + EUR + KG + CM + EA + Italy + 1 + + + GBP + KG + CM + Jersey + + + JMD + KG + CM + AM + Jamaica + + + JOD + KG + CM + AP + Jordan + + + JPY + KG + CM + AP + Japan + + + KES + KG + CM + AP + Kenya + + + KGS + KG + CM + AP + Kyrgyzstan + + + KHR + KG + CM + Cambodia + + + AUD + KG + CM + Kiribati + + + KMF + KG + CM + Comoros + + + XCD + KG + CM + AM + St. Kitts + + + KPW + KG + CM + Korea, The D.P.R of + + + KRW + KG + CM + AP + Korea, Republic Of + + + EUR + KG + CM + Kosovo + + + KWD + KG + CM + AP + Kuwait + + + KYD + KG + CM + AM + Cayman Islands + + + KZT + KG + CM + AP + Kazakhstan + + + LAK + KG + CM + Lao People's Democratic Republic + + + USD + KG + CM + AP + Lebanon + + + XCD + KG + CM + AM + St. Lucia + +
  • + CHF + KG + CM + Liechtenstein +
  • + + LKR + KG + CM + AP + Sri Lanka + + + LRD + KG + CM + Liberia + + + LSL + KG + CM + Lesotho + + + LTL + KG + CM + EA + Lithuania + 1 + + + EUR + KG + CM + EA + Luxembourg + 1 + + + LVL + KG + CM + EA + Latvia + 1 + + + LYD + KG + CM + Libya + + + MAD + KG + CM + AP + Morocco + + + EUR + KG + CM + Monaco + + + MDL + KG + CM + AP + Moldova, Republic Of + + + EUR + KG + CM + Montenegro, Republic of + + + MGA + KG + CM + Madagascar + + + USD + LB + IN + Marshall Islands + + + MKD + KG + CM + AP + Macedonia, Rep. of (FYROM) + + + XOF + KG + CM + Mali + + + USD + KG + CM + AP + Myanmar + + + MNT + KG + CM + Mongolia + + + MOP + KG + CM + Macau + + + USD + LB + IN + Saipan + + + EUR + KG + CM + AM + Martinique + + + MRO + KG + CM + Mauritania + + + XCD + KG + CM + Montserrat + + + EUR + KG + CM + AP + Malta + 1 + + + MUR + KG + CM + AP + Mauritius + + + MVR + KG + CM + Maldives + + + MWK + KG + CM + Malawi + + + MXN + KG + CM + AM + Mexico + + + MYR + KG + CM + AP + Malaysia + + + MZN + KG + CM + Mozambique + + + ZAR + KG + CM + AP + Namibia + + + XPF + KG + CM + New Caledonia + + + XOF + KG + CM + Niger + + + NGN + KG + CM + AP + Nigeria + + + NIO + KG + CM + AM + Nicaragua + + + EUR + KG + CM + EA + Netherlands, The + 1 + + + NOK + KG + CM + EA + Norway + + + NPR + KG + CM + AP + Nepal + + + AUD + KG + CM + Nauru, Republic Of + + + NZD + KG + CM + Niue + + + NZD + KG + CM + AP + New Zealand + + + OMR + KG + CM + AP + Oman + + + PAB + KG + CM + AM + Panama + + + PEN + KG + CM + AM + Peru + + + XPF + KG + CM + Tahiti + + + PGK + KG + CM + Papua New Guinea + + + PHP + KG + CM + AP + Philippines, The + + + PKR + KG + CM + AP + Pakistan + + + PLN + KG + CM + EA + Poland + 1 + + + USD + LB + IN + AM + Puerto Rico + + + EUR + KG + CM + EA + Portugal + 1 + + + USD + KG + CM + Palau + + + PYG + KG + CM + AM + Paraguay + + + QAR + KG + CM + AP + Qatar + + + EUR + KG + CM + AP + Reunion, Island Of + + + RON + KG + CM + EA + Romania + 1 + + + RSD + KG + CM + AP + Serbia, Republic of + + + RUB + KG + CM + AP + Russian Federation, The + + + RWF + KG + CM + Rwanda + + + SAR + KG + CM + AP + Saudi Arabia + + + SBD + KG + CM + Solomon Islands + + + SCR + KG + CM + Seychelles + + + SDG + KG + CM + AP + Sudan + + + SEK + KG + CM + EA + Sweden + 1 + + + SGD + KG + CM + AP + Singapore + + + EUR + KG + CM + EA + Slovenia + 1 + + + EUR + KG + CM + EA + Slovakia + 1 + + + SLL + KG + CM + Sierra Leone + + + EUR + KG + CM + San Marino + + + XOF + KG + CM + AP + Senegal + + + SOS + KG + CM + Somalia + + + SRD + KG + CM + AM + Suriname + + + STD + KG + CM + Sao Tome and Principe + + + USD + KG + CM + AM + El Salvador + + + SYP + KG + CM + Syria + + + SZL + KG + CM + Swaziland + + + USD + KG + CM + AM + Turks and Caicos Islands + + + XAF + KG + CM + Chad + + + XOF + KG + CM + Togo + + + THB + KG + CM + AP + Thailand + + + TJS + KG + CM + AP + Tajikistan + + + USD + KG + CM + East Timor + + + TND + KG + CM + Tunisia + + + TOP + KG + CM + Tonga + + + TRY + KG + CM + AP + Turkey + + + TTD + KG + CM + AM + Trinidad and Tobago + + + AUD + KG + CM + Tuvalu + + + TWD + KG + CM + AP + Taiwan + + + TZS + KG + CM + Tanzania + + + UAH + KG + CM + AP + Ukraine + + + UGX + KG + CM + Uganda + + + USD + LB + IN + AM + United States Of America + + + UYU + KG + CM + AM + Uruguay + + + UZS + KG + CM + AP + Uzbekistan + + + XCD + KG + CM + AM + St. Vincent + + + VEF + KG + CM + AM + Venezuela + + + USD + KG + CM + AM + Virgin Islands (British) + + + USD + LB + IN + Virgin Islands (US) + + + VND + KG + CM + AP + Vietnam + + + VUV + KG + CM + Vanuatu + + + WST + KG + CM + Samoa + + + EUR + KG + CM + Bonaire + + + EUR + KG + CM + AM + Curacao + + + ANG + KG + CM + St. Eustatius + + + EUR + KG + CM + AM + St. Maarten + + + XCD + KG + CM + AM + Nevis + + + SIS + KG + CM + Somaliland, Rep of (North Somalia) + + + ANG + KG + CM + AM + St. Barthelemy + + + YER + KG + CM + AP + Yemen, Republic of + + + EUR + KG + CM + Mayotte + + + ZAR + KG + CM + AP + South Africa + + + ZMK + KG + CM + Zambia + + + ZWD + KG + CM + Zimbabwe + +
    diff --git app/code/core/Mage/Usa/etc/system.xml app/code/core/Mage/Usa/etc/system.xml index 62664cb..8c642a1 100644 --- app/code/core/Mage/Usa/etc/system.xml +++ app/code/core/Mage/Usa/etc/system.xml @@ -21,7 +21,7 @@ * * @category Mage * @package Mage_Usa - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> @@ -30,9 +30,9 @@ - + text - 13 + 130 1 1 1 @@ -40,16 +40,16 @@ text - 7 + 70 1 1 0 - + select adminhtml/system_config_source_yesno - 1 + 10 1 1 0 @@ -58,7 +58,7 @@ multiselect usa/shipping_carrier_dhl_source_method - 17 + 170 1 1 0 @@ -67,7 +67,7 @@ text - 12 + 120 1 1 0 @@ -80,7 +80,7 @@ select adminhtml/system_config_source_enabledisable - 121 + 1210 1 1 0 @@ -88,7 +88,8 @@ text - 122 + validate-number validate-zero-or-greater + 1220 1 1 0 @@ -97,7 +98,7 @@ select adminhtml/system_config_source_yesno - 13 + 130 1 1 0 @@ -106,7 +107,7 @@ select usa/shipping_carrier_dhl_source_dutypaymenttype - 14 + 140 1 1 0 @@ -116,7 +117,7 @@ select free-method usa/shipping_carrier_dhl_source_freemethod - 120 + 1200 1 1 0 @@ -124,7 +125,7 @@ text - 2 + 20 1 1 0 @@ -133,7 +134,7 @@ select shipping/source_handlingType - 10 + 100 1 1 0 @@ -142,7 +143,7 @@ select shipping/source_handlingAction - 11 + 110 1 1 0 @@ -150,7 +151,8 @@ text - 12 + validate-number validate-zero-or-greater + 120 1 1 0 @@ -158,7 +160,8 @@ text - 13 + validate-number validate-zero-or-greater + 130 1 1 0 @@ -167,7 +170,7 @@ obscure adminhtml/system_config_backend_encrypted - 5 + 50 1 1 0 @@ -176,16 +179,25 @@ obscure adminhtml/system_config_backend_encrypted - 6 + 60 1 1 0 + + + select + usa/shipping_carrier_abstract_source_requesttype + 85 + 1 + 1 + 0 + select usa/shipping_carrier_dhl_source_shipmenttype - 9 + 90 1 1 0 @@ -194,7 +206,7 @@ obscure adminhtml/system_config_backend_encrypted - 8 + 80 1 1 0 @@ -203,7 +215,7 @@ obscure adminhtml/system_config_backend_encrypted - 8 + 80 1 1 0 @@ -211,7 +223,7 @@ text - 200 + 2000 1 1 0 @@ -219,7 +231,7 @@ <label>Title</label> <frontend_type>text</frontend_type> - <sort_order>2</sort_order> + <sort_order>20</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> @@ -227,7 +239,7 @@ <sallowspecific translate="label"> <label>Ship to Applicable Countries</label> <frontend_type>select</frontend_type> - <sort_order>190</sort_order> + <sort_order>1900</sort_order> <frontend_class>shipping-applicable-country</frontend_class> <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model> <show_in_default>1</show_in_default> @@ -237,7 +249,7 @@ <specificcountry translate="label"> <label>Ship to Specific Countries</label> <frontend_type>multiselect</frontend_type> - <sort_order>191</sort_order> + <sort_order>1910</sort_order> <source_model>adminhtml/system_config_source_country</source_model> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> @@ -247,7 +259,7 @@ <showmethod translate="label"> <label>Show Method if Not Applicable</label> <frontend_type>select</frontend_type> - <sort_order>194</sort_order> + <sort_order>1940</sort_order> <frontend_class>shipping-skip-hide</frontend_class> <source_model>adminhtml/system_config_source_yesno</source_model> <show_in_default>1</show_in_default> @@ -257,7 +269,7 @@ <specificerrmsg translate="label"> <label>Displayed Error Message</label> <frontend_type>textarea</frontend_type> - <sort_order>80</sort_order> + <sort_order>800</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> @@ -267,7 +279,7 @@ <label>Additional Protection Enabled</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> - <sort_order>130</sort_order> + <sort_order>1300</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> @@ -275,7 +287,8 @@ <additional_protection_min_value translate="label"> <label>Additional Protection Min Subtotal</label> <frontend_type>text</frontend_type> - <sort_order>131</sort_order> + <validate>validate-number validate-zero-or-greater</validate> + <sort_order>1310</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> @@ -284,7 +297,7 @@ <label>Additional Protection Value</label> <frontend_type>select</frontend_type> <source_model>usa/shipping_carrier_dhl_source_protection_value</source_model> - <sort_order>132</sort_order> + <sort_order>1320</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> @@ -293,17 +306,17 @@ <label>Additional Protection Configuration Value</label> <comment>Used only when "Additional Protection Value" is set to "Configuration". Can contain only numeric amount.</comment> <frontend_type>text</frontend_type> - <sort_order>133</sort_order> + <sort_order>1330</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </additional_protection_value> - <additional_protection_rounding translate="label comment"> + <additional_protection_rounding translate="label"> <label>Additional Protection Value Rounding Method</label> <frontend_type>select</frontend_type> <source_model>usa/shipping_carrier_dhl_source_protection_rounding</source_model> - <sort_order>134</sort_order> + <sort_order>1340</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> @@ -313,7 +326,7 @@ <label>Shipment Contains Hazardous Materials</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> - <sort_order>135</sort_order> + <sort_order>1350</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> @@ -322,7 +335,7 @@ <default_length translate="label"> <label>Default Package Length</label> <frontend_type>text</frontend_type> - <sort_order>136</sort_order> + <sort_order>1360</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> @@ -330,7 +343,7 @@ <default_width translate="label"> <label>Default Package Width</label> <frontend_type>text</frontend_type> - <sort_order>137</sort_order> + <sort_order>1370</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> @@ -338,7 +351,7 @@ <default_height translate="label"> <label>Default Package Height</label> <frontend_type>text</frontend_type> - <sort_order>138</sort_order> + <sort_order>1380</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> @@ -348,7 +361,7 @@ <label>Domestic Shipment Days</label> <frontend_type>multiselect</frontend_type> <source_model>adminhtml/system_config_source_locale_weekdays</source_model> - <sort_order>139</sort_order> + <sort_order>1390</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> @@ -359,7 +372,7 @@ <label>International Shipment Days</label> <frontend_type>multiselect</frontend_type> <source_model>adminhtml/system_config_source_locale_weekdays</source_model> - <sort_order>140</sort_order> + <sort_order>1400</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> @@ -369,7 +382,7 @@ <label>Debug</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> - <sort_order>195</sort_order> + <sort_order>1950</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> @@ -379,89 +392,115 @@ <fedex translate="label" module="usa"> <label>FedEx</label> <frontend_type>text</frontend_type> - <sort_order>12</sort_order> + <sort_order>120</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> <fields> + <active translate="label"> + <label>Enabled for Checkout</label> + <frontend_type>select</frontend_type> + <source_model>adminhtml/system_config_source_yesno</source_model> + <sort_order>10</sort_order> + <show_in_default>1</show_in_default> + <show_in_website>1</show_in_website> + <show_in_store>0</show_in_store> + </active> + <title translate="label"> + <label>Title</label> + <frontend_type>text</frontend_type> + <sort_order>20</sort_order> + <show_in_default>1</show_in_default> + <show_in_website>1</show_in_website> + <show_in_store>1</show_in_store> + obscure adminhtml/system_config_backend_encrypted - 3 + 40 1 1 0 Please make sure to use only digits here. No dashes are allowed. - - - select - adminhtml/system_config_source_yesno - 1 + + + obscure + adminhtml/system_config_backend_encrypted + 50 1 1 0 - - - - multiselect - usa/shipping_carrier_fedex_source_method - 17 + + + + obscure + adminhtml/system_config_backend_encrypted + 60 1 1 0 - 1 - - - + + + + obscure + adminhtml/system_config_backend_encrypted + 70 + 1 + 1 + 0 + + + select - adminhtml/system_config_source_enabledisable - 21 + adminhtml/system_config_source_yesno + 75 1 1 0 - - - - text - 22 + + + + select + usa/shipping_carrier_abstract_source_requesttype + 77 1 1 0 - - - + + + select - usa/shipping_carrier_fedex_source_dropoff - 5 + usa/shipping_carrier_fedex_source_packaging + 80 1 1 0 - - - + + + select - free-method - usa/shipping_carrier_fedex_source_freemethod - 20 + usa/shipping_carrier_fedex_source_dropoff + 90 1 1 0 - - - + + + text - 2 + validate-number validate-zero-or-greater + 100 1 1 0 - + select shipping/source_handlingType - 6 + 110 1 1 0 @@ -470,7 +509,7 @@ select shipping/source_handlingAction - 7 + 120 1 1 0 @@ -478,57 +517,80 @@ text - 8 + validate-number validate-zero-or-greater + 130 1 1 0 - - - text - 5 + + + select + 140 + adminhtml/system_config_source_yesno 1 1 0 - - - - select - usa/shipping_carrier_fedex_source_packaging - 4 + + + + multiselect + usa/shipping_carrier_fedex_source_method + 150 1 1 0 - - - + 1 + + + text - 100 + 155 1 1 0 - - - <label>Title</label> - <frontend_type>text</frontend_type> - <sort_order>2</sort_order> + <comment>The field is applicable if the Smart Post method is selected.</comment> + </smartpost_hubid> + <free_method translate="label"> + <label>Free Method</label> + <frontend_type>select</frontend_type> + <frontend_class>free-method</frontend_class> + <source_model>usa/shipping_carrier_fedex_source_freemethod</source_model> + <sort_order>160</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - - - + 0 + + + select - 8 - adminhtml/system_config_source_yesno + adminhtml/system_config_source_enabledisable + 170 1 1 0 - + + + + text + validate-number validate-zero-or-greater + 180 + 1 + 1 + 0 + + + + textarea + 190 + 1 + 1 + 1 + select - 90 + 200 shipping-applicable-country adminhtml/system_config_source_shipping_allspecificcountries 1 @@ -538,46 +600,46 @@ multiselect - 91 + 210 adminhtml/system_config_source_country 1 1 0 1 + + + select + adminhtml/system_config_source_yesno + 220 + 1 + 1 + 0 + select - 92 + 230 shipping-skip-hide adminhtml/system_config_source_yesno 1 1 0 - - - textarea - 80 - 1 - 1 - 1 - - - - select - adminhtml/system_config_source_yesno - 92 + + + text + 240 1 1 0 - + 0 text - 10 + 100 1 1 1 @@ -586,16 +648,16 @@ obscure adminhtml/system_config_backend_encrypted - 3 + 30 1 1 0 - + select adminhtml/system_config_source_yesno - 1 + 10 1 1 0 @@ -604,17 +666,26 @@ multiselect usa/shipping_carrier_ups_source_method - 17 + 170 1 1 0 1 + + + select + usa/shipping_carrier_abstract_source_requesttype + 47 + 1 + 1 + 0 + select usa/shipping_carrier_ups_source_container - 5 + 50 1 1 0 @@ -623,7 +694,7 @@ select adminhtml/system_config_source_enabledisable - 21 + 210 1 1 0 @@ -631,7 +702,8 @@ text - 22 + validate-number validate-zero-or-greater + 220 1 1 0 @@ -640,7 +712,7 @@ select usa/shipping_carrier_ups_source_destType - 6 + 60 1 1 0 @@ -650,7 +722,7 @@ select free-method usa/shipping_carrier_ups_source_freemethod - 20 + 200 1 1 0 @@ -658,7 +730,7 @@ text - 4 + 40 1 1 0 @@ -666,7 +738,7 @@ text - 3 + 30 1 1 0 @@ -675,7 +747,7 @@ select shipping/source_handlingType - 11 + 110 1 1 0 @@ -684,7 +756,7 @@ select shipping/source_handlingAction - 12 + 120 1 1 0 @@ -692,7 +764,8 @@ text - 13 + validate-number validate-zero-or-greater + 130 1 1 0 @@ -700,7 +773,8 @@ text - 8 + validate-number validate-zero-or-greater + 80 1 1 0 @@ -708,7 +782,8 @@ text - 9 + validate-number validate-zero-or-greater + 90 1 1 0 @@ -717,7 +792,7 @@ select usa/shipping_carrier_ups_source_originShipment - 3 + 30 1 1 0 @@ -726,7 +801,7 @@ obscure adminhtml/system_config_backend_encrypted - 3 + 30 1 1 0 @@ -735,7 +810,7 @@ select usa/shipping_carrier_ups_source_pickup - 8 + 80 1 1 0 @@ -743,15 +818,15 @@ text - 100 + 1000 1 1 0 - + 0 <label>Title</label> <frontend_type>text</frontend_type> - <sort_order>4</sort_order> + <sort_order>40</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> @@ -759,7 +834,7 @@ <tracking_xml_url translate="label"> <label>Tracking XML URL</label> <frontend_type>text</frontend_type> - <sort_order>6</sort_order> + <sort_order>60</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> @@ -768,25 +843,25 @@ <label>UPS Type</label> <frontend_type>select</frontend_type> <source_model>usa/shipping_carrier_ups_source_type</source_model> - <sort_order>2</sort_order> + <sort_order>20</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </type> - <unit_of_measure translate="label"> + <unit_of_measure translate="label comment"> <label>Weight Unit</label> <frontend_type>select</frontend_type> <source_model>usa/shipping_carrier_ups_source_unitofmeasure</source_model> - <sort_order>6</sort_order> + <sort_order>60</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </unit_of_measure> <username translate="label"> - <label>UserId</label> + <label>User ID</label> <frontend_type>obscure</frontend_type> <backend_model>adminhtml/system_config_backend_encrypted</backend_model> - <sort_order>3</sort_order> + <sort_order>30</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> @@ -795,15 +870,15 @@ <label>Enable Negotiated Rates</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> - <sort_order>4</sort_order> + <sort_order>40</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </negotiated_active> - <shipper_number translate="label"> + <shipper_number translate="label comment"> <label>Shipper Number</label> <frontend_type>text</frontend_type> - <sort_order>5</sort_order> + <sort_order>50</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> @@ -812,7 +887,7 @@ <sallowspecific translate="label"> <label>Ship to Applicable Countries</label> <frontend_type>select</frontend_type> - <sort_order>90</sort_order> + <sort_order>900</sort_order> <frontend_class>shipping-applicable-country</frontend_class> <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model> <show_in_default>1</show_in_default> @@ -822,7 +897,7 @@ <specificcountry translate="label"> <label>Ship to Specific Countries</label> <frontend_type>multiselect</frontend_type> - <sort_order>91</sort_order> + <sort_order>910</sort_order> <source_model>adminhtml/system_config_source_country</source_model> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> @@ -832,7 +907,7 @@ <showmethod translate="label"> <label>Show Method if Not Applicable</label> <frontend_type>select</frontend_type> - <sort_order>92</sort_order> + <sort_order>920</sort_order> <frontend_class>shipping-skip-hide</frontend_class> <source_model>adminhtml/system_config_source_yesno</source_model> <show_in_default>1</show_in_default> @@ -842,7 +917,7 @@ <specificerrmsg translate="label"> <label>Displayed Error Message</label> <frontend_type>textarea</frontend_type> - <sort_order>80</sort_order> + <sort_order>800</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> @@ -851,8 +926,8 @@ <label>Mode</label> <comment>Enables/Disables SSL verification of Magento server by UPS.</comment> <frontend_type>select</frontend_type> - <source_model>usa/shipping_carrier_ups_source_mode</source_model> - <sort_order>3</sort_order> + <source_model>usa/shipping_carrier_abstract_source_mode</source_model> + <sort_order>30</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> @@ -861,7 +936,7 @@ <label>Debug</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> - <sort_order>92</sort_order> + <sort_order>920</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> @@ -871,79 +946,157 @@ <usps translate="label" module="usa"> <label>USPS</label> <frontend_type>text</frontend_type> - <sort_order>11</sort_order> + <sort_order>110</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> <fields> <active translate="label"> - <label>Enabled</label> + <label>Enabled for Checkout</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> - <sort_order>1</sort_order> + <sort_order>10</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </active> - <allowed_methods translate="label"> - <label>Allowed Methods</label> - <frontend_type>multiselect</frontend_type> - <source_model>usa/shipping_carrier_usps_source_method</source_model> - <sort_order>17</sort_order> + <gateway_url translate="label"> + <label>Gateway URL</label> + <frontend_type>text</frontend_type> + <sort_order>20</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> - <can_be_empty>1</can_be_empty> - </allowed_methods> - <container translate="label"> - <label>Container</label> - <frontend_type>select</frontend_type> - <source_model>usa/shipping_carrier_usps_source_container</source_model> - <sort_order>4</sort_order> + </gateway_url> + <gateway_secure_url translate="label"> + <label>Secure Gateway URL</label> + <frontend_type>text</frontend_type> + <sort_order>30</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> - </container> - <free_shipping_enable translate="label"> - <label>Free Shipping with Minimum Order Amount</label> - <frontend_type>select</frontend_type> - <source_model>adminhtml/system_config_source_enabledisable</source_model> - <sort_order>21</sort_order> + </gateway_secure_url> + <title translate="label"> + <label>Title</label> + <frontend_type>text</frontend_type> + <sort_order>40</sort_order> + <show_in_default>1</show_in_default> + <show_in_website>1</show_in_website> + <show_in_store>1</show_in_store> + + + + obscure + adminhtml/system_config_backend_encrypted + 50 1 1 0 - - - - text - 22 + + + + obscure + adminhtml/system_config_backend_encrypted + 53 1 1 0 - - - + + + select - free-method - usa/shipping_carrier_usps_source_freemethod - 20 + 54 + usa/shipping_carrier_abstract_source_mode 1 1 0 - - - + + + + select + usa/shipping_carrier_abstract_source_requesttype + 55 + 1 + 1 + 0 + + + + select + usa/shipping_carrier_usps_source_container + 60 + 1 + 1 + 0 + + + + select + usa/shipping_carrier_usps_source_size + 70 + 1 + 1 + 0 + + + text - 2 + 73 1 1 0 - + LARGE + + + + text + 72 + 1 + 1 + 0 + LARGE + + + + text + 74 + 1 + 1 + 0 + LARGE + + + + text + 76 + 1 + 1 + 0 + LARGE + + + + select + usa/shipping_carrier_usps_source_machinable + 80 + 1 + 1 + 0 + + + + text + validate-number validate-zero-or-greater + 90 + 1 + 1 + 0 + select shipping/source_handlingType - 11 + 100 1 1 0 @@ -952,7 +1105,7 @@ select shipping/source_handlingAction - 12 + 110 1 1 0 @@ -960,66 +1113,344 @@ text - 13 + validate-number validate-zero-or-greater + 120 1 1 0 - - + + + multiselect + usa/shipping_carrier_usps_source_method + 130 + 1 + 1 + 0 + 1 + + + + select + free-method + usa/shipping_carrier_usps_source_freemethod + 140 + 1 + 1 + 0 + + + + select + adminhtml/system_config_source_enabledisable + 1500 + 1 + 1 + 0 + + + text - 8 + validate-number validate-zero-or-greater + 160 1 1 0 - - - + + + + textarea + 170 + 1 + 1 + 1 + + + select - usa/shipping_carrier_usps_source_machinable - 6 + 180 + shipping-applicable-country + adminhtml/system_config_source_shipping_allspecificcountries 1 1 0 - - - + + + + multiselect + 190 + adminhtml/system_config_source_country + 1 + 1 + 0 + 1 + + + select - usa/shipping_carrier_usps_source_size - 5 + adminhtml/system_config_source_yesno + 200 1 1 0 - + + + + select + 210 + shipping-skip-hide + adminhtml/system_config_source_yesno + 1 + 1 + 0 + text - 100 + 220 1 1 0 - + 0 + + + + + text + 140 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_yesno + 10 + 1 + 1 + 0 + + + + text + 20 + 1 + 1 + 0 + <label>Title</label> <frontend_type>text</frontend_type> - <sort_order>2</sort_order> + <sort_order>20</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> - - + + obscure adminhtml/system_config_backend_encrypted - 3 + 50 1 1 0 - + + + + obscure + adminhtml/system_config_backend_encrypted + 60 + 1 + 1 + 0 + + + + text + 70 + 1 + 1 + 0 + + + + select + usa/shipping_carrier_dhl_international_source_contenttype + 90 + 1 + 1 + 0 + + + + select + shipping/source_handlingType + 100 + 1 + 1 + 0 + + + + "Per Order" allows single handling fee for entire order. "Per Package" allows individual handling fee for each package. + select + shipping/source_handlingAction + 110 + 1 + 1 + 0 + + + + text + validate-number validate-zero-or-greater + 120 + 1 + 1 + 0 + + + + Allows breaking total order weight into smaller pieces if it exeeds 70 kg to ensure accurate calculation of shipping charges. + select + adminhtml/system_config_source_yesno + 130 + 1 + 1 + 1 + + + + select + usa/shipping_carrier_dhl_international_source_method_unitofmeasure + usa/adminhtml_dhl_unitofmeasure + 140 + 1 + 1 + 1 + + + + select + usa/shipping_carrier_dhl_international_source_method_size + 150 + 1 + 1 + 1 + + + + text + 151 + 1 + 1 + 1 + 1 + + + + text + 152 + 1 + 1 + 1 + 1 + + + + text + 153 + 1 + 1 + 1 + 1 + + + + multiselect + usa/shipping_carrier_dhl_international_source_method_doc + 170 + 1 + 1 + 0 + D + + + + multiselect + usa/shipping_carrier_dhl_international_source_method_nondoc + 170 + 1 + 1 + 0 + N + + + + Package ready time after order submission (in hours) + text + 180 + 1 + 1 + 0 + + + + textarea + 800 + 1 + 1 + 1 + + + + + select + free-method + usa/shipping_carrier_dhl_international_source_method_freedoc + 1200 + 1 + 1 + 0 + D + + + + select + free-method + usa/shipping_carrier_dhl_international_source_method_freenondoc + 1200 + 1 + 1 + 0 + N + + + + select + adminhtml/system_config_source_enabledisable + 1210 + 1 + 1 + 0 + + + + text + validate-number validate-zero-or-greater + 1220 + 1 + 1 + 0 + select - 90 + 1900 shipping-applicable-country adminhtml/system_config_source_shipping_allspecificcountries 1 @@ -1029,7 +1460,7 @@ multiselect - 91 + 1910 adminhtml/system_config_source_country 1 1 @@ -1039,32 +1470,32 @@ select - 92 + 1940 shipping-skip-hide adminhtml/system_config_source_yesno 1 1 0 - - - textarea - 80 + + + text + 2000 1 1 - 1 - + 0 + select adminhtml/system_config_source_yesno - 92 + 1950 1 1 0 - + diff --git app/code/core/Mage/Usa/etc/wsdl/FedEx/RateService_v10.wsdl app/code/core/Mage/Usa/etc/wsdl/FedEx/RateService_v10.wsdl new file mode 100644 index 0000000..d7e635a --- /dev/null +++ app/code/core/Mage/Usa/etc/wsdl/FedEx/RateService_v10.wsdl @@ -0,0 +1,4870 @@ + + + + + + + + Specifies additional labels to be produced. All required labels for shipments will be produced without the need to request additional labels. These are only available as thermal labels. + + + + + The type of additional labels to return. + + + + + The number of this type label to return + + + + + + + Identifies the type of additional labels. + + + + + + + + + + + + + + + Descriptive data for a physical location. May be used as an actual physical address (place to which one could go), or as a container of "address parts" which should be handled as a unit (such as a city-state-ZIP combination within the US). + + + + + Combination of number, street name, etc. At least one line is required for a valid physical address; empty lines should not be included. + + + + + Name of city, town, etc. + + + + + Identifying abbreviation for US state, Canada province, etc. Format and presence of this field will vary, depending on country. + + + + + Identification of a region (usually small) for mail/package delivery. Format and presence of this field will vary, depending on country. + + + + + Relevant only to addresses in Puerto Rico. + + + + + The two-letter code used to identify a country. + + + + + Indicates whether this address residential (as opposed to commercial). + + + + + + + + Specifies which filing option is being exercised by the customer. + Required for non-document shipments originating in Canada destined for any country other than Canada, the United States, Puerto Rico or the U.S. Virgin Islands. + + + + + + + + + + + + Identification of the type of barcode (symbology) used on FedEx documents and labels. + + + + + + + + + + + + + + + + + + Identification of a FedEx operating company (transportation). + + + + + + + + + + + + + The instructions indicating how to print the Certificate of Origin ( e.g. whether or not to include the instructions, image type, etc ...) + + + + + Specifies characteristics of a shipping document to be produced. + + + + + Specifies the usage and identification of customer supplied images to be used on this document. + + + + + + + + + + + + + Specifies the type of brokerage to be applied to a shipment. + + + + + + + + + + + + Descriptive data for the client submitting a transaction. + + + + + The FedEx account number associated with this transaction. + + + + + This number is assigned by FedEx and identifies the unique device from which the request is originating + + + + + Only used in transactions which require identification of the Fed Ex Office integrator. + + + + + Indicates the region from which the transaction is submitted. + + + + + The language to be used for human-readable Notification.localizedMessages in responses to the request containing this ClientDetail object. Different requests from the same client may contain different Localization data. (Contrast with TransactionDetail.localization, which governs data payload language/translation.) + + + + + + + + + + + + + + + + + + + + + + Identifies the type of funds FedEx should collect upon shipment delivery. + + + + + + + + + + Descriptive data required for a FedEx COD (Collect-On-Delivery) shipment. + + + + + + Specifies the details of the charges are to be added to the COD collect amount. + + + + + Identifies the type of funds FedEx should collect upon package delivery + + + + + For Express this is the descriptive data that is used for the recipient of the FedEx Letter containing the COD payment. For Ground this is the descriptive data for the party to receive the payment that prints the COD receipt. + + + + + Indicates which type of reference information to include on the COD return shipping label. + + + + + + + Indicates which type of reference information to include on the COD return shipping label. + + + + + + + + + + + CommercialInvoice element is required for electronic upload of CI data. It will serve to create/transmit an Electronic Commercial Invoice through the FedEx Systems. Customers are responsible for printing their own Commercial Invoice.If you would likeFedEx to generate a Commercial Invoice and transmit it to Customs. for clearance purposes, you need to specify that in the ShippingDocumentSpecification element. If you would like a copy of the Commercial Invoice that FedEx generated returned to you in reply it needs to be specified in the ETDDetail/RequestedDocumentCopies element. Commercial Invoice support consists of maximum of 99 commodity line items. + + + + + Any comments that need to be communicated about this shipment. + + + + + Any freight charges that are associated with this shipment. + + + + + Any taxes or miscellaneous charges(other than Freight charges or Insurance charges) that are associated with this shipment. + + + + + Specifies which kind of charge is being recorded in the preceding field. + + + + + Any packing costs that are associated with this shipment. + + + + + Any handling costs that are associated with this shipment. + + + + + Free-form text. + + + + + Free-form text. + + + + + Free-form text. + + + + + The reason for the shipment. Note: SOLD is not a valid purpose for a Proforma Invoice. + + + + + Customer assigned Invoice number + + + + + Name of the International Expert that completed the Commercial Invoice different from Sender. + + + + + Required for dutiable international Express or Ground shipment. This field is not applicable to an international PIB(document) or a non-document which does not require a Commercial Invoice + + + + + + + The instructions indicating how to print the Commercial Invoice( e.g. image type) Specifies characteristics of a shipping document to be produced. + + + + + + Specifies the usage and identification of a customer supplied image to be used on this document. + + + + + + + Information about the transit time and delivery commitment date and time. + + + + + The Commodity applicable to this commitment. + + + + + The FedEx service type applicable to this commitment. + + + + + Shows the specific combination of service options combined with the service type that produced this committment in the set returned to the caller. + + + + + Supporting detail for applied options identified in preceding field. + + + + + THe delivery commitment date/time. Express Only. + + + + + The delivery commitment day of the week. + + + + + The number of transit days; applies to Ground and LTL Freight; indicates minimum transit time for SmartPost. + + + + + Maximum number of transit days, for SmartPost shipments. + + + + + The service area code for the destination of this shipment. Express only. + + + + + The address of the broker to be used for this shipment. + + + + + The FedEx location identifier for the broker. + + + + + The delivery commitment date/time the shipment will arrive at the border. + + + + + The delivery commitment day of the week the shipment will arrive at the border. + + + + + The number of days it will take for the shipment to make it from broker to destination + + + + + The delivery commitment date for shipment served by GSP (Global Service Provider) + + + + + The delivery commitment day of the week for the shipment served by GSP (Global Service Provider) + + + + + Messages concerning the ability to provide an accurate delivery commitment on an International commit quote. These could be messages providing information about why a commitment could not be returned or a successful message such as "REQUEST COMPLETED" + + + + + Messages concerning the delivery commitment on an International commit quote such as "0:00 A.M. IF NO CUSTOMS DELAY" + + + + + Information about why a shipment delivery is delayed and at what level (country/service etc.). + + + + + + Required documentation for this shipment. + + + + + Freight origin and destination city center information and total distance between origin and destination city centers. + + + + + + + The type of delay this shipment will encounter. + + + + + + + + + + + + + + + + + + + For international multiple piece shipments, commodity information must be passed in the Master and on each child transaction. + If this shipment cotains more than four commodities line items, the four highest valued should be included in the first 4 occurances for this request. + + + + + + total number of pieces of this commodity + + + + + total number of pieces of this commodity + + + + + Complete and accurate description of this commodity. + + 450 + + + + + + Country code where commodity contents were produced or manufactured in their final form. + + 2 + + + + + + + Unique alpha/numeric representing commodity item. + At least one occurrence is required for US Export shipments if the Customs Value is greater than $2500 or if a valid US Export license is required. + + + 14 + + + + + + Total weight of this commodity. 1 explicit decimal position. Max length 11 including decimal. + + + + + Number of units of a commodity in total number of pieces for this line item. Max length is 9 + + + + + Unit of measure used to express the quantity of this commodity line item. + + 3 + + + + + + Contains only additional quantitative information other than weight and quantity to calculate duties and taxes. + + + + + Value of each unit in Quantity. Six explicit decimal positions, Max length 18 including decimal. + + + + + + Total customs value for this line item. + It should equal the commodity unit quantity times commodity unit value. + Six explicit decimal positions, max length 18 including decimal. + + + + + + Defines additional characteristic of commodity used to calculate duties and taxes + + + + + Applicable to US export shipping only. + + 12 + + + + + + + + An identifying mark or number used on the packaging of a shipment to help customers identify a particular shipment. + + + 15 + + + + + + All data required for this commodity in NAFTA Certificate of Origin. + + + + + + + Defines additional data to print in the Configurable portion of the label, this allows you to print the same type information on the label that can also be printed on the doc tab. + + + + + 1 of 12 possible zones to position data. + + + + + The identifiying text for the data in this zone. + + + + + A reference to a field in either the request or reply to print in this zone following the header. + + + + + A literal value to print after the header in this zone. + + + + + + + The descriptive data for a point-of-contact person. + + + + + Client provided identifier corresponding to this contact information. + + + + + Identifies the contact person's name. + + + + + Identifies the contact person's title. + + + + + Identifies the company this contact is associated with. + + + + + Identifies the phone number associated with this contact. + + + + + Identifies the phone extension associated with this contact. + + + + + Identifies the pager number associated with this contact. + + + + + Identifies the fax number associated with this contact. + + + + + Identifies the email address associated with this contact. + + + + + + + + + + + + + + + + + + + + + Specifies the currency exchange performed on financial amounts for this rate. + + + + + The currency code for the original (converted FROM) currency. + + + + + The currency code for the final (converted INTO) currency. + + + + + Multiplier used to convert fromCurrency units to intoCurrency units. + + + + + + + + + Indicates the type of custom delivery being requested. + + + + + Time by which delivery is requested. + + + + + Range of dates for custom delivery request; only used if type is BETWEEN. + + + + + Date for custom delivery request; only used for types of ON, BETWEEN, or AFTER. + + + + + + + + + + + + + + + Data required to produce a custom-specified document, either at shipment or package level. + + + + + Common information controlling document production. + + + + + Applicable only to documents produced on thermal printers with roll stock. + + + + + Applicable only to documents produced on thermal printers with roll stock. + + + + + Identifies the formatting specification used to construct this custom document. + + + + + + + Constructed string, based on format and zero or more data fields, printed in specified barcode symbology. + + + + + + + + + Width of thinnest bar/space element in the barcode. + + + + + + + + Solid (filled) rectangular area on label. + + + + + + + + + + + + + + + + + + + + + + + + Image to be included from printer's memory, or from a local file for offline clients. + + + + + + Printer-specific index of graphic image to be printed. + + + + + Fully-qualified path and file name for graphic image to be printed. + + + + + + + + + Horizontal position, relative to left edge of custom area. + + + + + Vertical position, relative to top edge of custom area. + + + + + + + Constructed string, based on format and zero or more data fields, printed in specified printer font (for thermal labels) or generic font/size (for plain paper labels). + + + + + + + + Printer-specific font name for use with thermal printer labels. + + + + + Generic font name for use with plain paper labels. + + + + + Generic font size for use with plain paper labels. + + + + + + + + + + + + + + + + + + + Reference information to be associated with this package. + + + + + + + + + + + + + + + + + + + + + + + Allows customer-specified control of label content. + + + + + If omitted, no doc tab will be produced (i.e. default = former NONE type). + + + + + Defines any custom content to print on the label. + + + + + Defines additional data to print in the Configurable portion of the label, this allows you to print the same type information on the label that can also be printed on the doc tab. + + + + + Controls which data/sections will be suppressed. + + + + + For customers producing their own Ground labels, this field specifies which secondary barcode will be printed on the label; so that the primary barcode produced by FedEx has the corect SCNC. + + + + + The language to use when printing the terms and conditions on the label. + + + + + Controls the number of additional copies of supplemental labels. + + + + + This value reduces the default quantity of destination/consignee air waybill labels. A value of zero indicates no change to default. A minimum of one copy will always be produced. + + + + + + + + + + Descriptive data identifying the Broker responsible for the shipmet. + Required if BROKER_SELECT_OPTION is requested in Special Services. + + + + + + Interacts both with properties of the shipment and contractual relationship with the shipper. + + + + + + Applicable only for Commercial Invoice. If the consignee and importer are not the same, the Following importer fields are required. + Importer/Contact/PersonName + Importer/Contact/CompanyName + Importer/Contact/PhoneNumber + Importer/Address/StreetLine[0] + Importer/Address/City + Importer/Address/StateOrProvinceCode - if Importer Country Code is US or CA + Importer/Address/PostalCode - if Importer Country Code is US or CA + Importer/Address/CountryCode + + + + + + Specifies how the recipient is identified for customs purposes; the requirements on this information vary with destination country. + + + + + Indicates how payment of duties for the shipment will be made. + + + + + Indicates whether this shipment contains documents only or non-documents. + + + + + The total customs value for the shipment. This total will rrepresent th esum of the values of all commodities, and may include freight, miscellaneous, and insurance charges. Must contain 2 explicit decimal positions with a max length of 17 including the decimal. For Express International MPS, the Total Customs Value is in the master transaction and all child transactions + + + + + Identifies responsibilities with respect to loss, damage, etc. + + + + + Documents amount paid to third party for coverage of shipment content. + + + + + + CommercialInvoice element is required for electronic upload of CI data. It will serve to create/transmit an Electronic Commercial Invoice through FedEx System. Customers are responsible for printing their own Commercial Invoice. Commercial Invoice support consists of a maximum of 20 commodity line items. + + + + + + For international multiple piece shipments, commodity information must be passed in the Master and on each child transaction. + If this shipment cotains more than four commodities line items, the four highest valued should be included in the first 4 occurances for this request. + + + + + + Country specific details of an International shipment. + + + + + FOOD_OR_PERISHABLE is required by FDA/BTA; must be true for food/perishable items coming to US or PR from non-US/non-PR origin. + + + + + + + Identifies whether or not the products being shipped are required to be accessible during delivery. + + + + + + + + + The descriptive data required for a FedEx shipment containing dangerous goods (hazardous materials). + + + + + Identifies whether or not the products being shipped are required to be accessible during delivery. + + + + + Shipment is packaged/documented for movement ONLY on cargo aircraft. + + + + + Indicates which kinds of hazardous content are in the current package. + + + + + Documents the kinds and quantities of all hazardous commodities in the current package. + + + + + Description of the packaging of this commodity, suitable for use on OP-900 and OP-950 forms. + + + + + Telephone number to use for contact in the event of an emergency. + + + + + Offeror's name or contract number, per DOT regulation. + + + + + + + + + + + + + + + + + + + + + + + + Information about why a shipment delivery is delayed and at what level( country/service etc.). + + + + + The date of the delay + + + + + + The attribute of the shipment that caused the delay(e.g. Country, City, LocationId, Zip, service area, special handling ) + + + + + The point where the delay is occurring (e.g. Origin, Destination, Broker location) + + + + + The reason for the delay (e.g. holiday, weekend, etc.). + + + + + The name of the holiday in that country that is causing the delay. + + + + + + + The attribute of the shipment that caused the delay(e.g. Country, City, LocationId, Zip, service area, special handling ) + + + + + + + + + + + + + + The point where the delay is occurring ( e.g. Origin, Destination, Broker location). + + + + + + + + + + + + Data required to complete the Destionation Control Statement for US exports. + + + + + + Comma-separated list of up to four country codes, required for DEPARTMENT_OF_STATE statement. + + + + + Name of end user, required for DEPARTMENT_OF_STATE statement. + + + + + + + Used to indicate whether the Destination Control Statement is of type Department of Commerce, Department of State or both. + + + + + + + + + The dimensions of this package and the unit type used for the measurements. + + + + + + + + + + + Driving or other transportation distances, distinct from dimension measurements. + + + + + Identifies the distance quantity. + + + + + Identifies the unit of measure for the distance value. + + + + + + + + + + + + + + + The DocTabContentType options available. + + + + + The DocTabContentType should be set to ZONE001 to specify additional Zone details. + + + + + The DocTabContentType should be set to BARCODED to specify additional BarCoded details. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Zone number can be between 1 and 12. + + + + + Header value on this zone. + + + + + Reference path to the element in the request/reply whose value should be printed on this zone. + + + + + Free form-text to be printed in this zone. + + + + + Justification for the text printed on this zone. + + + + + + + Identifies the method by which the package is to be tendered to FedEx. This element does not dispatch a courier for package pickup. + + + + + + + + + + + + Specific information about the delivery of the email and options for the shipment. + + + + + Email address to send the URL to. + + + + + A message to be inserted into the email. + + + + + + + Information describing email notifications that will be sent in relation to events that occur during package movement + + + + + A message that will be included in the email notifications + + + + + Information describing the destination of the email, format of the email and events to be notified on + + + + + + + + + + + + + + + The format of the email + + + + + + + + + + The descriptive data for a FedEx email notification recipient. + + + + + Identifies the relationship this email recipient has to the shipment. + + + + + The email address to send the notification to + + + + + The types of email notifications being requested for this recipient. + + + + + The format of the email notification. + + + + + The language/locale to be used in this email notification. + + + + + + + Identifies the set of valid email notification recipient types. For SHIPPER, RECIPIENT and BROKER the email address asssociated with their definitions will be used, any email address sent with the email notification for these three email notification recipient types will be ignored. + + + + + + + + + + + + + + + + + + + + Customer-declared value, with data type and legal values depending on excise condition, used in defining the taxable value of the item. + + + + + + + Specifies the types of Estimated Duties and Taxes to be included in a rate quotation for an international shipment. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Electronic Trade document references used with the ETD special service. + + + + + Indicates the types of shipping documents produced for the shipper by FedEx (see ShippingDocumentSpecification) which should be copied back to the shipper in the shipment result data. + + + + + Currently not supported. + + + + + + + + Country specific details of an International shipment. + + + + + + Specifies which filing option is being exercised by the customer. + Required for non-document shipments originating in Canada destined for any country other than Canada, the United States, Puerto Rico or the U.S. Virgin Islands. + + + + + + General field for exporting-country-specific export data (e.g. B13A for CA, FTSR Exemption or AES Citation for US). + + + + + This field is applicable only to Canada export non-document shipments of any value to any destination. No special characters allowed. + + 10 + + + + + + Department of Commerce/Department of State information about this shipment. + + + + + + + Details specific to an Express freight shipment. + + + + + Indicates whether or nor a packing list is enclosed. + + + + + + Total shipment pieces. + ie. 3 boxes and 3 pallets of 100 pieces each = Shippers Load and Count of 303. + Applicable to International Priority Freight and International Economy Freight. + Values must be in the range of 1 - 99999 + + + + + + Required for International Freight shipping. Values must be 8- 12 characters in length. + + 12 + + + + + + Currently not supported. + + + + + Currently not supported. + + + + + Currently not supported. + + + + + + + Currently not supported. Delivery contact information for an Express freight shipment. + + + + + + + + + Indicates a FedEx Express operating region. + + + + + + + + + + + + Identifies a kind of FedEx facility. + + + + + + + + + + Specifies the optional features/characteristics requested for a Freight shipment utilizing a flatbed trailer. + + + + + + + + + + + + + + + + + + + + Individual charge which contributes to the total base charge for the shipment. + + + + + Freight class for this line item. + + + + + Effective freight class used for rating this line item. + + + + + NMFC Code for commodity. + + + + + Customer-provided description for this commodity or class line. + + + + + Weight for this commodity or class line. + + + + + Rate or factor applied to this line item. + + + + + Identifies the manner in which the chargeRate for this line item was applied. + + + + + The net or extended charge for this line item. + + + + + + + Specifies the way in which base charges for a Freight shipment or shipment leg are calculated. + + + + + + + + + + + + + + + + These values represent the industry-standard freight classes used for FedEx Freight and FedEx National Freight shipment description. (Note: The alphabetic prefixes are required to distinguish these values from decimal numbers on some client platforms.) + + + + + + + + + + + + + + + + + + + + + + + + + Information about the Freight Service Centers associated with this shipment. + + + + + Information about the origin Freight Service Center. + + + + + Information about the destination Freight Service Center. + + + + + The distance between the origin and destination FreightService Centers + + + + + + + + + + Date for all Freight guarantee types. + + + + + + + + + + + + + Identifies responsibilities with respect to loss, damage, etc. + + + + + + + + + Rate data specific to FedEx Freight or FedEx National Freight services. + + + + + A unique identifier for a specific rate quotation. + + + + + Specifies how total base charge is determined. + + + + + Freight charges which accumulate to the total base charge for the shipment. + + + + + Human-readable descriptions of additional information on this shipment rating. + + + + + + + Additional non-monetary data returned with Freight rates. + + + + + Unique identifier for notation. + + + + + Human-readable explanation of notation. + + + + + + + This class describes the relationship between a customer-specified address and the FedEx Freight / FedEx National Freight Service Center that supports that address. + + + + + Freight Industry standard non-FedEx carrier identification + + + + + The name of the Interline carrier. + + + + + Additional time it might take at the origin or destination to pickup or deliver the freight. This is usually due to the remoteness of the location. This time is included in the total transit time. + + + + + Service branding which may be used for local pickup or delivery, distinct from service used for line-haul of customer's shipment. + + + + + Distance between customer address (pickup or delivery) and the supporting Freight / National Freight service center. + + + + + Time to travel between customer address (pickup or delivery) and the supporting Freight / National Freight service center. + + + + + Specifies when/how the customer can arrange for pickup or delivery. + + + + + Specifies days of operation if localServiceScheduling is LIMITED. + + + + + Freight service center that is a gateway on the border of Canada or Mexico. + + + + + Alphabetical code identifying a Freight Service Center + + + + + Freight service center Contact and Address + + + + + + + Specifies the type of service scheduling offered from a Freight or National Freight Service Center to a customer-supplied address. + + + + + + + + + + Data applicable to shipments using FEDEX_FREIGHT and FEDEX_NATIONAL_FREIGHT services. + + + + + Account number used with FEDEX_FREIGHT service. + + + + + Used for validating FedEx Freight account number and (optionally) identifying third party payment on the bill of lading. + + + + + Account number used with FEDEX_NATIONAL_FREIGHT service. + + + + + Used for validating FedEx National Freight account number and (optionally) identifying third party payment on the bill of lading. + + + + + Indicates the role of the party submitting the transaction. + + + + + Designates which of the requester's tariffs will be used for rating. + + + + + Identifies the declared value for the shipment + + + + + Identifies the declared value units corresponding to the above defined declared value + + + + + + Identifiers for promotional discounts offered to customers. + + + + + Total number of individual handling units in the entire shipment (for unit pricing). + + + + + Estimated discount rate provided by client for unsecured rate quote. + + + + + Total weight of pallets used in shipment. + + + + + Overall shipment dimensions. + + + + + Description for the shipment. + + + + + Specifies which party will pay surcharges for any special services which support split billing. + + + + + Details of the commodities in the shipment. + + + + + + + Description of an individual commodity or class of content in a shipment. + + + + + Freight class for this line item. + + + + + Specification of handling-unit packaging for this commodity or class line. + + + + + Customer-provided description for this commodity or class line. + + + + + Weight for this commodity or class line. + + + + + FED EX INTERNAL USE ONLY - Individual line item dimensions. + + + + + Volume (cubic measure) for this commodity or class line. + + + + + + + Indicates the role of the party submitting the transaction. + + + + + + + + + + Specifies which party will be responsible for payment of any surcharges for Freight special services for which split billing is allowed. + + + + + Identifies the special service. + + + + + Indicates who will pay for the special service. + + + + + + + Data required to produce a General Agency Agreement document. Remaining content (business data) to be defined once requirements have been completed. + + + + + + + + Documents the kind and quantity of an individual hazardous commodity in a package. + + + + + Identifies and describes an individual hazardous commodity. + + + + + Specifies the amount of the commodity in alternate units. + + + + + Customer-provided specifications for handling individual commodities. + + + + + + + Identifies and describes an individual hazardous commodity. For 201001 load, this is based on data from the FedEx Ground Hazardous Materials Shipping Guide. + + + + + Regulatory identifier for a commodity (e.g. "UN ID" value). + + + + + + + + + + + + + Specifies how the commodity is to be labeled. + + + + + + + + + + Customer-provided specifications for handling individual commodities. + + + + + Specifies how the customer wishes the label text to be handled for this commodity in this package. + + + + + Text used in labeling the commodity under control of the labelTextOption field. + + + + + + + Indicates which kind of hazardous content (as defined by DOT) is being reported. + + + + + + + + + + + + Identifies number and type of packaging units for hazardous commodities. + + + + + Number of units of the type below. + + + + + Units in which the hazardous commodity is packaged. + + + + + + + Identifies DOT packing group for a hazardous commodity. + + + + + + + + + + Identifies amount and units for quantity of hazardous commodities. + + + + + Number of units of the type below. + + + + + Units by which the hazardous commodity is measured. + + + + + + + Descriptive data required for a FedEx shipment that is to be held at the destination FedEx location for pickup by the recipient. + + + + + Contact phone number for recipient of shipment. + + + + + Contact and address of FedEx facility at which shipment is to be held. + + + + + Type of facility at which package/shipment is to be held. + + + + + Location identification (for facilities identified by an alphanumeric location code). + + + + + Location identification (for facilities identified by an numeric location code). + + + + + + + The descriptive data required by FedEx for home delivery services. + + + + + + Required for Date Certain Home Delivery. + + + + + Required for Date Certain and Appointment Home Delivery. + + 15 + + + + + + + + + + + + + + + + + + + + + + + + The type of International shipment. + + + + + + + + + Specifies the type of label to be returned. + + + + + + + + + + + + + Names for data elements / areas which may be suppressed from printing on labels. + + + + + + + + + + + + + + + + + This indicates if the top or bottom of the label comes out of the printer first. + + + + + + + + + Relative to normal orientation for the printer. + + + + + + + + + + + Description of shipping label to be returned in the reply + + + + + Specify type of label to be returned + + + + + + The type of image or printer commands the label is to be formatted in. + DPL = Unimark thermal printer language + EPL2 = Eltron thermal printer language + PDF = a label returned as a pdf image + PNG = a label returned as a png image + ZPLII = Zebra thermal printer language + + + + + + For thermal printer lables this indicates the size of the label and the location of the doc tab if present. + + + + + This indicates if the top or bottom of the label comes out of the printer first. + + + + + Relative to normal orientation for the printer. RIGHT=90 degrees clockwise, UPSIDE_DOWN=180 degrees, LEFT=90 degrees counterclockwise. + + + + + If present, this contact and address information will replace the return address information on the label. + + + + + Allows customer-specified control of label content. + + + + + + + For thermal printer labels this indicates the size of the label and the location of the doc tab if present. + + + + + + + + + + + + + + + + + + + + + + Identifies the Liability Coverage Amount. For Jan 2010 this value represents coverage amount per pound + + + + + + + + + + + + + Represents a one-dimensional measurement in small units (e.g. suitable for measuring a package or document), contrasted with Distance, which represents a large one-dimensional measurement (e.g. distance between cities). + + + + + The numerical quantity of this measurement. + + + + + The units for this measurement. + + + + + + + CM = centimeters, IN = inches + + + + + + + + + Identifies the representation of human-readable text. + + + + + Two-letter code for language (e.g. EN, FR, etc.) + + + + + Two-letter code for the region (e.g. us, ca, etc..). + + + + + + + + + + + + + Internal FedEx use only. + + + + + + + + + + + + + + + + + + Data required to produce a Certificate of Origin document. Remaining content (business data) to be defined once requirements have been completed. + + + + + + + Indicates which Party (if any) from the shipment is to be used as the source of importer data on the NAFTA COO form. + + + + + Contact information for "Authorized Signature" area of form. + + + + + + + + + + + + Defined by NAFTA regulations. + + + + + Defined by NAFTA regulations. + + + + + Identification of which producer is associated with this commodity (if multiple producers are used in a single shipment). + + + + + + Date range over which RVC net cost was calculated. + + + + + + + + + + + + + + + + Net cost method used. + + + + + + + + + + See instructions for NAFTA Certificate of Origin for code definitions. + + + + + + + + + + + + + + + + + + + See instructions for NAFTA Certificate of Origin for code definitions. + + + + + + + + + + + + + + + + + + + + The descriptive data regarding the result of the submitted transaction. + + + + + The severity of this notification. This can indicate success or failure or some other information about the request. The values that can be returned are SUCCESS - Your transaction succeeded with no other applicable information. NOTE - Additional information that may be of interest to you about your transaction. WARNING - Additional information that you need to know about your transaction that you may need to take action on. ERROR - Information about an error that occurred while processing your transaction. FAILURE - FedEx was unable to process your transaction at this time due to a system failure. Please try again later + + + + + Indicates the source of this notification. Combined with the Code it uniquely identifies this notification + + + + + A code that represents this notification. Combined with the Source it uniquely identifies this notification. + + + + + Human-readable text that explains this notification. + + + + + The translated message. The language and locale specified in the ClientDetail. Localization are used to determine the representation. Currently only supported in a TrackReply. + + + + + A collection of name/value pairs that provide specific data to help the client determine the nature of an error (or warning, etc.) witout having to parse the message string. + + + + + + + + + Identifies the type of data contained in Value (e.g. SERVICE_TYPE, PACKAGE_SEQUENCE, etc..). + + + + + The value of the parameter (e.g. PRIORITY_OVERNIGHT, 2, etc..). + + + + + + + Identifies the set of severity values for a Notification. + + + + + + + + + + + + The instructions indicating how to print the OP-900 form for hazardous materials packages. + + + + + Specifies characteristics of a shipping document to be produced. + + + + + Identifies which reference type (from the package's customer references) is to be used as the source for the reference on this OP-900. + + + + + Specifies the usage and identification of customer supplied images to be used on this document. + + + + + Data field to be used when a name is to be printed in the document instead of (or in addition to) a signature image. + + + + + + + The Oversize classification for a package. + + + + + + + + + + Data for a package's rates, as calculated per a specific rate type. + + + + + Type used for this specific set of rate data. + + + + + Indicates which weight was used. + + + + + INTERNAL FEDEX USE ONLY. + + + + + The weight that was used to calculate the rate. + + + + + The dimensional weight of this package (if greater than actual). + + + + + The oversize weight of this package (if the package is oversize). + + + + + The transportation charge only (prior to any discounts applied) for this package. + + + + + The sum of all discounts on this package. + + + + + This package's baseCharge - totalFreightDiscounts. + + + + + The sum of all surcharges on this package. + + + + + This package's netFreight + totalSurcharges (not including totalTaxes). + + + + + The sum of all taxes on this package. + + + + + This package's netFreight + totalSurcharges + totalTaxes. + + + + + The total sum of all rebates applied to this package. + + + + + All rate discounts that apply to this package. + + + + + All rebates that apply to this package. + + + + + All surcharges that apply to this package (either because of characteristics of the package itself, or because it is carrying per-shipment surcharges for the shipment of which it is a part). + + + + + All taxes applicable (or distributed to) this package. + + + + + The variable handling charges calculated based on the type variable handling charges requested. + + + + + + + Identifies the collection of special services offered by FedEx. + + + + + + + + + + + + + + + These special services are available at the package level for some or all service types. If the shipper is requesting a special service which requires additional data, the package special service type must be present in the specialServiceTypes collection, and the supporting detail must be provided in the appropriate sub-object below. + + + + + The types of all special services requested for the enclosing shipment or package. + + + + + For use with FedEx Ground services only; COD must be present in shipment's special services. + + + + + Descriptive data required for a FedEx shipment containing dangerous materials. This element is required when SpecialServiceType.DANGEROUS_GOODS or HAZARDOUS_MATERIAL is present in the SpecialServiceTypes collection. + + + + + Descriptive data required for a FedEx shipment containing dry ice. This element is required when SpecialServiceType.DRY_ICE is present in the SpecialServiceTypes collection. + + + + + The descriptive data required for FedEx signature services. This element is required when SpecialServiceType.SIGNATURE_OPTION is present in the SpecialServiceTypes collection. + + + + + To be filled. + + + + + + + Identifies the packaging used by the requestor for the package. See PackagingType for list of valid enumerated values. + + + + + + + + + + + + + + The descriptive data for a person or company entitiy doing business with FedEx. + + + + + Identifies the FedEx account number assigned to the customer. + + 12 + + + + + + Descriptive data for taxpayer identification information. + + + + + Descriptive data identifying the point-of-contact person. + + + + + The descriptive data for a physical location. + + + + + + + The descriptive data for the monetary compensation given to FedEx for services rendered to the customer. + + + + + Identifies the method of payment for a service. See PaymentType for list of valid enumerated values. + + + + + Descriptive data identifying the party responsible for payment for a service. + + + + + + + Identifies the method of payment for a service. + + + + + + + + Descriptive data identifying the party responsible for payment for a service. + + + + + Identifies the FedEx account number assigned to the payor. + + 12 + + + + + + Identifies the country of the payor. + + + + + + + This information describes the kind of pending shipment being requested. + + + + + + Date after which the pending shipment will no longer be available for completion. + + + + + Only used with type of EMAIL. + + + + + + + + + + + + This enumeration rationalizes the former FedEx Express international "admissibility package" types (based on ANSI X.12) and the FedEx Freight packaging types. The values represented are those common to both carriers. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This class describes the pickup characteristics of a shipment (e.g. for use in a tag request). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Currently not supported. + + + + + + + + + + + + + + + + + + Indicates the reason that a dim divisor value was chose. + + + + + + + + + + + + Identifies a discount applied to the shipment. + + + + + Identifies the type of discount applied to the shipment. + + + + + + The amount of the discount applied to the shipment. + + + + + The percentage of the discount applied to the shipment. + + + + + + + Identifies the type of discount applied to the shipment. + + + + + + + + + + + + Selects the value from a set of rate data to which the percentage is applied. + + + + + + + + + + + The response to a RateRequest. The Notifications indicate whether the request was successful or not. + + + + + This indicates the highest level of severity of all the notifications returned in this reply. + + + + + The descriptive data regarding the results of the submitted transaction. + + + + + Contains the CustomerTransactionId that was sent in the request. + + + + + The version of this reply. + + + + + Each element contains all rate data for a single service. If service was specified in the request, there will be a single entry in this array; if service was omitted in the request, there will be a separate entry in this array for each service being compared. + + + + + + + + + Identifies the FedEx service to use in shipping the package. See ServiceType for list of valid enumerated values. + + + + + Identifies the packaging used by the requestor for the package. See PackagingType for list of valid enumerated values. + + + + + Shows the specific combination of service options combined with the service type that produced this committment in the set returned to the caller. + + + + + Supporting detail for applied options identified in preceding field. + + + + + + + + + Identification of an airport, using standard three-letter abbreviations. + + + + + Indicates whether or not this shipment is eligible for a money back guarantee. + + + + + Commitment code for the origin. + + + + + Commitment code for the destination. + + + + + Time in transit from pickup to delivery. + + + + + Maximum expected transit time + + + + + The signature option for this package. + + + + + The actual rate type of the charges for this package. + + + + + Each element contains all rate data for a single rate type. + + + + + + + Descriptive data sent to FedEx by a customer in order to rate a package/shipment. + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Allows the caller to specify that the transit time and commit data are to be returned in the reply. + + + + + Candidate carriers for rate-shopping use case. This field is only considered if requestedShipment/serviceType is omitted. + + + + + Contains zero or more service options whose combinations are to be considered when replying with available services. + + + + + The shipment for which a rate quote (or rate-shopping comparison) is desired. + + + + + + + Indicates the type of rates to be returned. + + + + + + + + + Select the type of rate from which the element is to be selected. + + + + + + + + + If requesting rates using the PackageDetails element (one package at a time) in the request, the rates for each package will be returned in this element. Currently total piece total weight rates are also retuned in this element. + + + + + Echoed from the corresponding package in the rate request (if provided). + + + + + Used with request containing PACKAGE_GROUPS, to identify which group of identical packages was used to produce a reply item. + + + + + The difference between "list" and "account" net charge. + + + + + Ground COD is shipment level. + + + + + + Rate data that are tied to a specific package and rate type combination. + + + + + + + This class groups the shipment and package rating data for a specific rate type for use in a rating reply, which groups result data by rate type. + + + + + The difference between "list" and "account" total net charge. + + + + + Express COD is shipment level. + + + + + The shipment-level totals for this rate type. + + + + + The package-level data for this rate type. + + + + + + + The method used to calculate the weight to be used in rating the package.. + + + + + + + + + + + + + + + + + + + Identifies a discount applied to the shipment. + + + + + + + The amount of the discount applied to the shipment. + + + + + The percentage of the discount applied to the shipment. + + + + + + + Identifies the type of discount applied to the shipment. + + + + + + + + + + Specifies how the recipient is identified for customs purposes; the requirements on this information vary with destination country. + + + + + Specifies the kind of identification being used. + + + + + Contains the actual ID value, of the type specified above. + + + + + + + Type of Brazilian taxpayer identifier provided in Recipient/TaxPayerIdentification/Number. For shipments bound for Brazil this overrides the value in Recipient/TaxPayerIdentification/TinType + + + + + + + + + + FOOD_OR_PERISHABLE is required by FDA/BTA; must be true for food/perishable items coming to US or PR from non-US/non-PR origin + + + + + + + + + + This class rationalizes RequestedPackage and RequestedPackageSummary from previous interfaces. The way in which it is uses within a RequestedShipment depends on the RequestedPackageDetailType value specified for that shipment. + + + + + Used only with INDIVIDUAL_PACKAGE, as a unique identifier of each requested package. + + + + + Used only with PACKAGE_GROUPS, as a unique identifier of each group of identical packages. + + + + + Used only with PACKAGE_GROUPS, as a count of packages within a group of identical packages. + + + + + + Only used for INDIVIDUAL_PACKAGES and PACKAGE_GROUPS. Ignored for PACKAGE_SUMMARY, in which case totalInsuredValue and packageCount on the shipment will be used to determine this value. + + + + + Only used for INDIVIDUAL_PACKAGES and PACKAGE_GROUPS. Ignored for PACKAGE_SUMMARY, in which case totalweight and packageCount on the shipment will be used to determine this value. + + + + + + Provides additional detail on how the customer has physically packaged this item. As of June 2009, required for packages moving under international and SmartPost services. + + + + + Human-readable text describing the package. + + + + + + + Only used for INDIVIDUAL_PACKAGES and PACKAGE_GROUPS. + + + + + + + The descriptive data for the shipment being tendered to FedEx. + + + + + Identifies the date and time the package is tendered to FedEx. Both the date and time portions of the string are expected to be used. The date should not be a past date or a date more than 10 days in the future. The time is the local time of the shipment based on the shipper's time zone. The date component must be in the format: YYYY-MM-DD (e.g. 2006-06-26). The time component must be in the format: HH:MM:SS using a 24 hour clock (e.g. 11:00 a.m. is 11:00:00, whereas 5:00 p.m. is 17:00:00). The date and time parts are separated by the letter T (e.g. 2006-06-26T17:00:00). There is also a UTC offset component indicating the number of hours/mainutes from UTC (e.g 2006-06-26T17:00:00-0400 is defined form June 26, 2006 5:00 pm Eastern Time). + + + + + Identifies the method by which the package is to be tendered to FedEx. This element does not dispatch a courier for package pickup. See DropoffType for list of valid enumerated values. + + + + + Identifies the FedEx service to use in shipping the package. See ServiceType for list of valid enumerated values. + + + + + Identifies the packaging used by the requestor for the package. See PackagingType for list of valid enumerated values. + + + + + Identifies the total weight of the shipment being conveyed to FedEx.This is only applicable to International shipments and should only be used on the first package of a mutiple piece shipment.This value contains 1 explicit decimal position + + + + + Total insured amount. + + + + + Descriptive data identifying the party responsible for shipping the package. Shipper and Origin should have the same address. + + + + + Descriptive data identifying the party receiving the package. + + + + + A unique identifier for a recipient location + + 10 + + + + + + Physical starting address for the shipment, if different from shipper's address. + + + + + Descriptive data indicating the method and means of payment to FedEx for providing shipping services. + + + + + Descriptive data regarding special services requested by the shipper for this shipment. If the shipper is requesting a special service which requires additional data (e.g. COD), the special service type must be present in the specialServiceTypes collection, and the supporting detail must be provided in the appropriate sub-object. For example, to request COD, "COD" must be included in the SpecialServiceTypes collection and the CodDetail object must contain the required data. + + + + + Details specific to an Express freight shipment. + + + + + Data applicable to shipments using FEDEX_FREIGHT and FEDEX_NATIONAL_FREIGHT services. + + + + + Used with Ground Home Delivery and Freight. + + + + + Details about how to calculate variable handling charges at the shipment level. + + + + + Customs clearance data, used for both international and intra-country shipping. + + + + + For use in "process tag" transaction. + + + + + Specifies the characteristics of a shipment pertaining to SmartPost services. + + + + + If true, only the shipper/payor will have visibility of this shipment. + + + + + Details about the image format and printer type the label is to returned in. + + + + + Contains data used to create additional (non-label) shipping documents. + + + + + Specifies whether and what kind of rates the customer wishes to have quoted on this shipment. The reply will also be constrained by other data on the shipment and customer. + + + + + Specifies whether the customer wishes to have Estimated Duties and Taxes provided with the rate quotation on this shipment. Only applies with shipments moving under international services. + + + + + The total number of packages in the entire shipment (even when the shipment spans multiple transactions.) + + + + + Specifies which package-level data values are provided at the shipment-level only. The package-level data values types specified here will not be provided at the package-level. + + + + + One or more package-attribute descriptions, each of which describes an individual package, a group of identical packages, or (for the total-piece-total-weight case) common characteristics all packages in the shipment. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + These values are used to control the availability of certain special services at the time when a customer uses the e-mail label link to create a return shipment. + + + + + + + + + + + + Identifies the allowed (merchant-authorized) special services which may be selected when the subsequent shipment is created. Only services represented in EMailLabelAllowedSpecialServiceType will be controlled by this list. + + + + + + + Information relating to a return shipment. + + + + + The type of return shipment that is being requested. At present the only type of retrun shipment that is supported is PRINT_RETURN_LABEL. With this option you can print a return label to insert into the box of an outbound shipment. This option can not be used to print an outbound label. + + + + + Return Merchant Authorization + + + + + Specific information about the delivery of the email and options for the shipment. + + + + + + + The type of return shipment that is being requested. + + + + + + + + + + The "PAYOR..." rates are expressed in the currency identified in the payor's rate table(s). The "RATED..." rates are expressed in the currency of the origin country. Former "...COUNTER..." values have become "...RETAIL..." values, except for PAYOR_COUNTER and RATED_COUNTER, which have been removed. + + + + + + + + + + + + + + + Return Merchant Authorization + + + + + Return Merchant Authorization Number + + 20 + + + + + + The reason for the return. + + 60 + + + + + + + + + + + + + + + + These values control the optional features of service that may be combined in a commitment/rate comparision transaction. + + + + + + + + + + + Supporting detail for applied options identified in a rate quote. + + + + + Identifies the type of Freight Guarantee applied, if FREIGHT_GUARANTEE is applied to the rate quote. + + + + + Identifies the smartPostHubId used during rate quote, if SMART_POST_HUB_ID is a variable option on the rate request. + + + + + Identifies the indicia used during rate quote, if SMART_POST_ALLOWED_INDICIA is a variable option on the rate request. + + + + + + + Identifies the FedEx service to use in shipping the package. See ServiceType for list of valid enumerated values. + + + + + + + + + + + + + + + + + + + + + + + + + + + + Shipment-level totals of dry ice data across all packages. + + + + + Total number of packages in the shipment that contain dry ice. + + + + + Total shipment dry ice weight for all packages. + + + + + + + Data for a single leg of a shipment's total/summary rates, as calculated per a specific rate type. + + + + + Human-readable text describing the shipment leg. + + + + + Origin for this leg. + + + + + Destination for this leg. + + + + + Type used for this specific set of rate data. + + + + + Indicates the rate scale used. + + + + + Indicates the rate zone used (based on origin and destination). + + + + + + Indicates which weight was used. + + + + + INTERNAL FEDEX USE ONLY. + + + + + Specifies the currency exchange performed on financial amounts for this rate. + + + + + Indicates which special rating cases applied to this shipment. + + + + + + Identifies the type of dim divisor that was applied. + + + + + + + Sum of dimensional weights for all packages. + + + + + + + + + This shipment's totalNetFreight + totalSurcharges (not including totalTaxes). + + + + + Total of the transportation-based taxes. + + + + + + + Total of all values under this shipment's dutiesAndTaxes; only provided if estimated duties and taxes were calculated for this shipment. + + + + + This shipment's totalNetCharge + totalDutiesAndTaxes; only provided if estimated duties and taxes were calculated for this shipment AND duties, taxes and transportation charges are all paid by the same sender's account. + + + + + Rate data specific to FedEx Freight and FedEx National Freight services. + + + + + All rate discounts that apply to this shipment. + + + + + All rebates that apply to this shipment. + + + + + All surcharges that apply to this shipment. + + + + + All transportation-based taxes applicable to this shipment. + + + + + All commodity-based duties and taxes applicable to this shipment. + + + + + The "order level" variable handling charges. + + + + + The total of all variable handling charges at both shipment (order) and package level. + + + + + + + These values identify which package-level data values will be provided at the shipment-level. + + + + + + + + + + Data for a shipment's total/summary rates, as calculated per a specific rate type. The "total..." fields may differ from the sum of corresponding package data for Multiweight or Express MPS. + + + + + Type used for this specific set of rate data. + + + + + Indicates the rate scale used. + + + + + Indicates the rate zone used (based on origin and destination). + + + + + Indicates the type of pricing used for this shipment. + + + + + Indicates which weight was used. + + + + + INTERNAL FEDEX USE ONLY. + + + + + Specifies the currency exchange performed on financial amounts for this rate. + + + + + Indicates which special rating cases applied to this shipment. + + + + + The value used to calculate the weight based on the dimensions. + + + + + Identifies the type of dim divisor that was applied. + + + + + + The weight used to calculate these rates. + + + + + Sum of dimensional weights for all packages. + + + + + + The total discounts used in the rate calculation. + + + + + The freight charge minus discounts. + + + + + The total amount of all surcharges applied to this shipment. + + + + + This shipment's totalNetFreight + totalSurcharges (not including totalTaxes). + + + + + Total of the transportation-based taxes. + + + + + The net charge after applying all discounts and surcharges. + + + + + The total sum of all rebates applied to this shipment. + + + + + Total of all values under this shipment's dutiesAndTaxes; only provided if estimated duties and taxes were calculated for this shipment. + + + + + This shipment's totalNetCharge + totalDutiesAndTaxes; only provided if estimated duties and taxes were calculated for this shipment AND duties, taxes and transportation charges are all paid by the same sender's account. + + + + + Identifies the Rate Details per each leg in a Freight Shipment + + + + + Rate data specific to FedEx Freight and FedEx National Freight services. + + + + + All rate discounts that apply to this shipment. + + + + + All rebates that apply to this shipment. + + + + + All surcharges that apply to this shipment. + + + + + All transportation-based taxes applicable to this shipment. + + + + + All commodity-based duties and taxes applicable to this shipment. + + + + + The "order level" variable handling charges. + + + + + The total of all variable handling charges at both shipment (order) and package level. + + + + + + + Identifies the collection of special service offered by FedEx. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + These special services are available at the shipment level for some or all service types. If the shipper is requesting a special service which requires additional data (such as the COD amount), the shipment special service type must be present in the specialServiceTypes collection, and the supporting detail must be provided in the appropriate sub-object below. + + + + + The types of all special services requested for the enclosing shipment (or other shipment-level transaction). + + + + + Descriptive data required for a FedEx COD (Collect-On-Delivery) shipment. This element is required when SpecialServiceType.COD is present in the SpecialServiceTypes collection. + + + + + Descriptive data required for a FedEx shipment that is to be held at the destination FedEx location for pickup by the recipient. This element is required when SpecialServiceType.HOLD_AT_LOCATION is present in the SpecialServiceTypes collection. + + + + + Descriptive data required for FedEx to provide email notification to the customer regarding the shipment. This element is required when SpecialServiceType.EMAIL_NOTIFICATION is present in the SpecialServiceTypes collection. + + + + + The descriptive data required for FedEx Printed Return Label. This element is required when SpecialServiceType.PRINTED_RETURN_LABEL is present in the SpecialServiceTypes collection + + + + + This field should be populated for pending shipments (e.g. e-mail label) It is required by a PENDING_SHIPMENT special service type. + + + + + The number of packages with dry ice and the total weight of the dry ice. + + + + + The descriptive data required for FedEx Home Delivery options. This element is required when SpecialServiceType.HOME_DELIVERY_PREMIUM is present in the SpecialServiceTypes collection + + + + + + + Electronic Trade document references. + + + + + Specification for date or range of dates on which delivery is to be attempted. + + + + + + + Each occurrence of this class specifies a particular way in which a kind of shipping document is to be produced and provided. + + + + + Values in this field specify how to create and return the document. + + + + + Specifies how to organize all documents of this type. + + + + + Specifies how to e-mail document images. + + + + + Specifies how a queued document is to be printed. + + + + + + + Specifies how to return a shipping document to the caller. + + + + + + + + + + + + + + Specifies how to e-mail shipping documents. + + + + + Provides the roles and email addresses for e-mail recipients. + + + + + Identifies the convention by which documents are to be grouped as e-mail attachments. + + + + + + + + + + + + + Specifies an individual recipient of e-mailed shipping document(s). + + + + + Identifies the relationship of this recipient in the shipment. + + + + + Address to which the document is to be sent. + + + + + + + Specifies characteristics of a shipping document to be produced. + + + + + Specifies how to create, organize, and return the document. + + + + + Specifies how far down the page to move the beginning of the image; allows for printing on letterhead and other pre-printed stock. + + + + + + + For those shipping document types which have both a "form" and "instructions" component (e.g. NAFTA Certificate of Origin and General Agency Agreement), this field indicates whether to provide the instructions. + + + + + Governs the language to be used for this individual document, independently from other content returned for the same shipment. + + + + + + + Specifies how to organize all shipping documents of the same type. + + + + + + + + + Specifies the image format used for a shipping document. + + + + + + + + + + + + Specifies printing options for a shipping document. + + + + + Provides environment-specific printer identification. + + + + + + + Contains all data required for additional (non-label) shipping documents to be produced in conjunction with a specific shipment. + + + + + Indicates the types of shipping documents requested by the shipper. + + + + + + + Specifies the production of each package-level custom document (the same specification is used for all packages). + + + + + Specifies the production of a shipment-level custom document. + + + + + Details pertaining to the GAA. + + + + + Details pertaining to NAFTA COO. + + + + + Specifies the production of the OP-900 document for hazardous materials packages. + + + + + + + Specifies the type of paper (stock) on which a document will be printed. + + + + + + + + + + + + + + + + + The descriptive data required for FedEx delivery signature services. + + + + + Identifies the delivery signature services option selected by the customer for this shipment. See OptionType for the list of valid values. + + + + + Identifies the delivery signature release authorization number. + + 10 + + + + + + + + Identifies the delivery signature services options offered by FedEx. + + + + + + + + + + + + These values are mutually exclusive; at most one of them can be attached to a SmartPost shipment. + + + + + + + + + + + + + + + + + + + + + Data required for shipments handled under the SMART_POST and GROUND_SMART_POST service types. + + + + + + + + + + + Indicates which special rating cases applied to this shipment. + + + + + + + + + Identifies each surcharge applied to the shipment. + + + + + The type of surcharge applied to the shipment. + + + + + + + The amount of the surcharge applied to the shipment. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Identifies each tax applied to the shipment. + + + + + + + + + + + + + + + + + + + + + Specifice the kind of tax or miscellaneous charge being reported on a Commercial Invoice. + + + + + + + + + + + + + The descriptive data for taxpayer identification information. + + + + + Identifies the category of the taxpayer identification number. See TinType for the list of values. + + + + + Identifies the taxpayer identification number. + + 18 + + + + + + Identifies the usage of Tax Identification Number in Shipment processing + + + + + + + + Required for dutiable international express or ground shipment. This field is not applicable to an international PIB (document) or a non-document which does not require a commercial invoice express shipment. + CFR_OR_CPT (Cost and Freight/Carriage Paid TO) + CIF_OR_CIP (Cost Insurance and Freight/Carraige Insurance Paid) + DDP (Delivered Duty Paid) + DDU (Delivered Duty Unpaid) + EXW (Ex Works) + FOB_OR_FCA (Free On Board/Free Carrier) + + + + + + + + + + + + + + Identifies the category of the taxpayer identification number. + + + + + + + + + + + + + + + + + + + + + + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Free form text to be echoed back in the reply. Used to match requests and replies. + + + + + Governs data payload language/translations (contrasted with ClientDetail.localization, which governs Notification.localizedMessage language selection). + + + + + + + Time in transit from pickup to delivery. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This definition of variable handling charge detail is intended for use in Jan 2011 corp load. + + + + + Used with Variable handling charge type of FIXED_VALUE. Contains the amount to be added to the freight charge. Contains 2 explicit decimal positions with a total max length of 10 including the decimal. + + + + + Actual percentage (10 means 10%, which is a mutiplier of 0.1) + + + + + Select the value from a set of rate data to which the percentage is applied. + + + + + Select the type of rate from which the element is to be selected. + + + + + + + The variable handling charges calculated based on the type variable handling charges requested. + + + + + The variable handling charge amount calculated based on the requested variable handling charge detail. + + + + + The calculated varibale handling charge plus the net charge. + + + + + + + Three-dimensional volume/cubic measurement. + + + + + + + + + Units of three-dimensional volume/cubic measure. + + + + + + + + + The descriptive data for the heaviness of an object. + + + + + Identifies the unit of measure associated with a weight value. + + + + + Identifies the weight value of a package/shipment. + + + + + + + Identifies the unit of measure associated with a weight value. See WeightUnits for the list of valid enumerated values. + + + + + + + + + Used in authentication of the sender's identity. + + + + + Credential used to authenticate a specific software application. This value is provided by FedEx after registration. + + + + + + + Two part authentication string used for the sender's identity + + + + + Identifying part of authentication credential. This value is provided by FedEx after registration + + + + + Secret part of authentication key. This value is provided by FedEx after registration. + + + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Identifies a system or sub-system which performs an operation. + + + + + Identifies the service business level. + + + + + Identifies the service interface level. + + + + + Identifies the service code level. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git app/code/core/Mage/Usa/etc/wsdl/FedEx/RateService_v9.wsdl app/code/core/Mage/Usa/etc/wsdl/FedEx/RateService_v9.wsdl new file mode 100644 index 0000000..bc35b1d --- /dev/null +++ app/code/core/Mage/Usa/etc/wsdl/FedEx/RateService_v9.wsdl @@ -0,0 +1,4756 @@ + + + + + + + + + Specifies additional labels to be produced. All required labels for shipments will be produced without the need to request additional labels. These are only available as thermal labels. + + + + + The type of additional labels to return. + + + + + The number of this type label to return + + + + + + + Identifies the type of additional labels. + + + + + + + + + + + + + + + Descriptive data for a physical location. May be used as an actual physical address (place to which one could go), or as a container of "address parts" which should be handled as a unit (such as a city-state-ZIP combination within the US). + + + + + Combination of number, street name, etc. At least one line is required for a valid physical address; empty lines should not be included. + + + + + Name of city, town, etc. + + + + + Identifying abbreviation for US state, Canada province, etc. Format and presence of this field will vary, depending on country. + + + + + Identification of a region (usually small) for mail/package delivery. Format and presence of this field will vary, depending on country. + + + + + Relevant only to addresses in Puerto Rico. + + + + + The two-letter code used to identify a country. + + + + + Indicates whether this address is residential (as opposed to commercial). + + + + + + + + Specifies which filing option is being exercised by the customer. + Required for non-document shipments originating in Canada destined for any country other than Canada, the United States, Puerto Rico or the U.S. Virgin Islands. + + + + + + + + + + + + Identification of the type of barcode (symbology) used on FedEx documents and labels. + + + + + + + + + + + + + + + + + + Identification of a FedEx operating company (transportation). + + + + + + + + + + + + + The instructions indicating how to print the Certificate of Origin ( e.g. whether or not to include the instructions, image type, etc ...) + + + + + Specifies characteristics of a shipping document to be produced. + + + + + Specifies the usage and identification of customer supplied images to be used on this document. + + + + + + + Specifies the type of brokerage to be applied to a shipment. + + + + + + + + + + + + Descriptive data for the client submitting a transaction. + + + + + The FedEx account number associated with this transaction. + + + + + This number is assigned by FedEx and identifies the unique device from which the request is originating. + + + + + Only used in transactions which require identification of the Fed Ex Office integrator. + + + + + Indicates the region from which the transaction is submitted. + + + + + The language to be used for human-readable Notification.localizedMessages in responses to the request containing this ClientDetail object. Different requests from the same client may contain different Localization data. (Contrast with TransactionDetail.localization, which governs data payload language/translation.) + + + + + + + Identifies what freight charges should be added to the COD collect amount. + + + + + + + + + + + + + + + + + + + Identifies the type of funds FedEx should collect upon shipment delivery. + + + + + + + + + + Descriptive data required for a FedEx COD (Collect-On-Delivery) shipment. + + + + + + Identifies if freight charges are to be added to the COD amount. This element determines which freight charges should be added to the COD collect amount. See CodAddTransportationChargesType for a list of valid enumerated values. + + + + + Identifies the type of funds FedEx should collect upon package delivery + + + + + For Express this is the descriptive data that is used for the recipient of the FedEx Letter containing the COD payment. For Ground this is the descriptive data for the party to receive the payment that prints the COD receipt. + + + + + Indicates which type of reference information to include on the COD return shipping label. + + + + + + + Indicates which type of reference information to include on the COD return shipping label. + + + + + + + + + + + CommercialInvoice element is required for electronic upload of CI data. It will serve to create/transmit an Electronic Commercial Invoice through the FedEx Systems. Customers are responsible for printing their own Commercial Invoice.If you would likeFedEx to generate a Commercial Invoice and transmit it to Customs. for clearance purposes, you need to specify that in the ShippingDocumentSpecification element. If you would like a copy of the Commercial Invoice that FedEx generated returned to you in reply it needs to be specified in the ETDDetail/RequestedDocumentCopies element. Commercial Invoice support consists of maximum of 99 commodity line items. + + + + + Any comments that need to be communicated about this shipment. + + + + + Any freight charges that are associated with this shipment. + + + + + Any taxes or miscellaneous charges(other than Freight charges or Insurance charges) that are associated with this shipment. + + + + + Any packing costs that are associated with this shipment. + + + + + Any handling costs that are associated with this shipment. + + + + + Free-form text. + + + + + Free-form text. + + + + + Free-form text. + + + + + The reason for the shipment. Note: SOLD is not a valid purpose for a Proforma Invoice. + + + + + Descriptive text for the purpose of the shipment. + + + + + Customer assigned invoice number. + + + + + Name of the International Expert that completed the Commercial Invoice different from Sender. + + + + + Required for dutiable international Express or Ground shipment. This field is not applicable to an international PIB(document) or a non-document which does not require a Commercial Invoice. + + + + + + + The instructions indicating how to print the Commercial Invoice( e.g. image type) Specifies characteristics of a shipping document to be produced. + + + + + + Specifies the usage and identification of a customer supplied image to be used on this document. + + + + + + + Information about the transit time and delivery commitment date and time. + + + + + The Commodity applicable to this commitment. + + + + + The FedEx service type applicable to this commitment. + + + + + Shows the specific combination of service options combined with the service type that produced this committment in the set returned to the caller. + + + + + Supporting detail for applied options identified in preceding field. + + + + + THe delivery commitment date/time. Express Only. + + + + + The delivery commitment day of the week. + + + + + The number of transit days; applies to Ground and LTL Freight; indicates minimum transit time for SmartPost. + + + + + Maximum number of transit days, for SmartPost shipments. + + + + + The service area code for the destination of this shipment. Express only. + + + + + The address of the broker to be used for this shipment. + + + + + The FedEx location identifier for the broker. + + + + + The delivery commitment date/time the shipment will arrive at the border. + + + + + The delivery commitment day of the week the shipment will arrive at the border. + + + + + The number of days it will take for the shipment to make it from broker to destination + + + + + The delivery commitment date for shipment served by GSP (Global Service Provider) + + + + + The delivery commitment day of the week for the shipment served by GSP (Global Service Provider) + + + + + Messages concerning the ability to provide an accurate delivery commitment on an International commit quote. These could be messages providing information about why a commitment could not be returned or a successful message such as "REQUEST COMPLETED" + + + + + Messages concerning the delivery commitment on an International commit quote such as "0:00 A.M. IF NO CUSTOMS DELAY" + + + + + Information about why a shipment delivery is delayed and at what level (country/service etc.). + + + + + + Required documentation for this shipment. + + + + + Freight origin and destination city center information and total distance between origin and destination city centers. + + + + + + + The type of delay this shipment will encounter. + + + + + + + + + + + + + + + + + + + For international multiple piece shipments, commodity information must be passed in the Master and on each child transaction. + If this shipment cotains more than four commodities line items, the four highest valued should be included in the first 4 occurances for this request. + + + + + + total number of pieces of this commodity + + + + + total number of pieces of this commodity + + + + + Complete and accurate description of this commodity. + + 450 + + + + + + Country code where commodity contents were produced or manufactured in their final form. + + 2 + + + + + + + Unique alpha/numeric representing commodity item. + At least one occurrence is required for US Export shipments if the Customs Value is greater than $2500 or if a valid US Export license is required. + + + 14 + + + + + + Total weight of this commodity. 1 explicit decimal position. Max length 11 including decimal. + + + + + Number of units of a commodity in total number of pieces for this line item. Max length is 9 + + + + + Unit of measure used to express the quantity of this commodity line item. + + 3 + + + + + + Contains only additional quantitative information other than weight and quantity to calculate duties and taxes. + + + + + Value of each unit in Quantity. Six explicit decimal positions, Max length 18 including decimal. + + + + + + Total customs value for this line item. + It should equal the commodity unit quantity times commodity unit value. + Six explicit decimal positions, max length 18 including decimal. + + + + + + Defines additional characteristic of commodity used to calculate duties and taxes + + + + + Applicable to US export shipping only. + + 12 + + + + + + + + An identifying mark or number used on the packaging of a shipment to help customers identify a particular shipment. + + + 15 + + + + + + All data required for this commodity in NAFTA Certificate of Origin. + + + + + + + Defines additional data to print in the Configurable portion of the label, this allows you to print the same type information on the label that can also be printed on the doc tab. + + + + + 1 of 12 possible zones to position data. + + + + + The identifiying text for the data in this zone. + + + + + A reference to a field in either the request or reply to print in this zone following the header. + + + + + A literal value to print after the header in this zone. + + + + + + + The descriptive data for a point-of-contact person. + + + + + Client provided identifier corresponding to this contact information. + + + + + Identifies the contact person's name. + + + + + Identifies the contact person's title. + + + + + Identifies the company this contact is associated with. + + + + + Identifies the phone number associated with this contact. + + + + + Identifies the phone extension associated with this contact. + + + + + Identifies the pager number associated with this contact. + + + + + Identifies the fax number associated with this contact. + + + + + Identifies the email address associated with this contact. + + + 120 + 35 + + + + + + + + + + + + + + + + + + + + + + + Specifies the currency exchange performed on financial amounts for this rate. + + + + + The currency code for the original (converted FROM) currency. + + + + + The currency code for the final (converted INTO) currency. + + + + + Multiplier used to convert fromCurrency units to intoCurrency units. + + + + + + + + + Indicates the type of custom delivery being requested. + + + + + Time by which delivery is requested. + + + + + Range of dates for custom delivery request; only used if type is BETWEEN. + + + + + Date for custom delivery request; only used for types of ON, BETWEEN, or AFTER. + + + + + + + + + + + + + + + Data required to produce a custom-specified document, either at shipment or package level. + + + + + Common information controlling document production. + + + + + Applicable only to documents produced on thermal printers with roll stock. + + + + + Applicable only to documents produced on thermal printers with roll stock. + + + + + Identifies the formatting specification used to construct this custom document. + + + + + + + Constructed string, based on format and zero or more data fields, printed in specified barcode symbology. + + + + + + + + + Width of thinnest bar/space element in the barcode. + + + + + + + + Solid (filled) rectangular area on label. + + + + + + + + + + + + + + + + + + + + + + + + Image to be included from printer's memory, or from a local file for offline clients. + + + + + + Printer-specific index of graphic image to be printed. + + + + + Fully-qualified path and file name for graphic image to be printed. + + + + + + + + + Horizontal position, relative to left edge of custom area. + + + + + Vertical position, relative to top edge of custom area. + + + + + + + Constructed string, based on format and zero or more data fields, printed in specified printer font (for thermal labels) or generic font/size (for plain paper labels). + + + + + + + + Printer-specific font name for use with thermal printer labels. + + + + + Generic font name for use with plain paper labels. + + + + + Generic font size for use with plain paper labels. + + + + + + + + + + + + + + + + + + + Reference information to be associated with this package. + + + + + + + + + + + + + + + + + + + + + + + Allows customer-specified control of label content. + + + + + If omitted, no doc tab will be produced (i.e. default = former NONE type). + + + + + Defines any custom content to print on the label. + + + + + Defines additional data to print in the Configurable portion of the label, this allows you to print the same type information on the label that can also be printed on the doc tab. + + + + + Controls which data/sections will be suppressed. + + + + + The language to use when printing the terms and conditions on the label. + + + + + Controls the number of additional copies of supplemental labels. + + + + + This value reduces the default quantity of destination/consignee air waybill labels. A value of zero indicates no change to default. A minimum of one copy will always be produced. + + + + + + + + + + Descriptive data identifying the Broker responsible for the shipmet. + Required if BROKER_SELECT_OPTION is requested in Special Services. + + + + + + Interacts both with properties of the shipment and contractual relationship with the shipper. + + + + + + Applicable only for Commercial Invoice. If the consignee and importer are not the same, the Following importer fields are required. + Importer/Contact/PersonName + Importer/Contact/CompanyName + Importer/Contact/PhoneNumber + Importer/Address/StreetLine[0] + Importer/Address/City + Importer/Address/StateOrProvinceCode - if Importer Country Code is US or CA + Importer/Address/PostalCode - if Importer Country Code is US or CA + Importer/Address/CountryCode + + + + + + Specifies how the recipient is identified for customs purposes; the requirements on this information vary with destination country. + + + + + Indicates how payment of duties for the shipment will be made. + + + + + Indicates whether this shipment contains documents only or non-documents. + + + + + The total customs value for the shipment. This total will rrepresent th esum of the values of all commodities, and may include freight, miscellaneous, and insurance charges. Must contain 2 explicit decimal positions with a max length of 17 including the decimal. For Express International MPS, the Total Customs Value is in the master transaction and all child transactions + + + + + Identifies responsibilities with respect to loss, damage, etc. + + + + + Documents amount paid to third party for coverage of shipment content. + + + + + + CommercialInvoice element is required for electronic upload of CI data. It will serve to create/transmit an Electronic Commercial Invoice through FedEx System. Customers are responsible for printing their own Commercial Invoice. Commercial Invoice support consists of a maximum of 20 commodity line items. + + + + + + For international multiple piece shipments, commodity information must be passed in the Master and on each child transaction. + If this shipment cotains more than four commodities line items, the four highest valued should be included in the first 4 occurances for this request. + + + + + + Country specific details of an International shipment. + + + + + FOOD_OR_PERISHABLE is required by FDA/BTA; must be true for food/perishable items coming to US or PR from non-US/non-PR origin. + + + + + + + Identifies whether or not the products being shipped are required to be accessible during delivery. + + + + + + + + + The descriptive data required for a FedEx shipment containing dangerous goods (hazardous materials). + + + + + Identifies whether or not the products being shipped are required to be accessible during delivery. + + + + + Shipment is packaged/documented for movement ONLY on cargo aircraft. + + + + + Indicates which kinds of hazardous content are in the current package. + + + + + Documents the kinds and quantities of all hazardous commodities in the current package. + + + + + Description of the packaging of this commodity, suitable for use on OP-900 and OP-950 forms. + + + + + Telephone number to use for contact in the event of an emergency. + + + + + + + + + + + + + + + + + + + + + + + + + + Information about why a shipment delivery is delayed and at what level( country/service etc.). + + + + + The date of the delay + + + + + + The attribute of the shipment that caused the delay(e.g. Country, City, LocationId, Zip, service area, special handling ) + + + + + The point where the delay is occurring (e.g. Origin, Destination, Broker location) + + + + + The reason for the delay (e.g. holiday, weekend, etc.). + + + + + The name of the holiday in that country that is causing the delay. + + + + + + + The attribute of the shipment that caused the delay(e.g. Country, City, LocationId, Zip, service area, special handling ) + + + + + + + + + + + + + + The point where the delay is occurring ( e.g. Origin, Destination, Broker location). + + + + + + + + + + + + Data required to complete the Destionation Control Statement for US exports. + + + + + + Comma-separated list of up to four country codes, required for DEPARTMENT_OF_STATE statement. + + + + + Name of end user, required for DEPARTMENT_OF_STATE statement. + + + + + + + Used to indicate whether the Destination Control Statement is of type Department of Commerce, Department of State or both. + + + + + + + + + The dimensions of this package and the unit type used for the measurements. + + + + + + + + + + + + + + + + + + + + + + + Driving or other transportation distances, distinct from dimension measurements. + + + + + Identifies the distance quantity. + + + + + Identifies the unit of measure for the distance value. + + + + + + + + + + + + + + + The DocTabContentType options available. + + + + + The DocTabContentType should be set to ZONE001 to specify additional Zone details. + + + + + The DocTabContentType should be set to BARCODED to specify additional BarCoded details. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Zone number can be between 1 and 12. + + + + + Header value on this zone. + + + + + Reference path to the element in the request/reply whose value should be printed on this zone. + + + + + Free form-text to be printed in this zone. + + + + + Justification for the text printed on this zone. + + + + + + + Identifies the method by which the package is to be tendered to FedEx. This element does not dispatch a courier for package pickup. + + + + + + + + + + + + Specific information about the delivery of the email and options for the shipment. + + + + + Email address to send the URL to. + + + + + A message to be inserted into the email. + + + + + + + Information describing email notifications that will be sent in relation to events that occur during package movement + + + + + A message that will be included in the email notifications + + 120 + + + + + + Information describing the destination of the email, format of the email and events to be notified on + + + + + + + The format of the email. + + + + + + + + + + The descriptive data for a FedEx email notification recipient. + + + + + Identifies the relationship this email recipient has to the shipment. + + + + + The email address to send the notification to + + + 120 + 35 + + + + + + + Notify the email recipient when this shipment has been shipped. + + + + + Notify the email recipient if this shipment encounters a problem while in route + + + + + Notify the email recipient when this shipment has been delivered. + + + + + The format of the email notification. + + + + + The language/locale to be used in this email notification. + + + + + + + Identifies the set of valid email notification recipient types. For SHIPPER, RECIPIENT and BROKER the email address asssociated with their definitions will be used, any email address sent with the email notification for these three email notification recipient types will be ignored. + + + + + + + + + + + + + + + + + + + + Customer-declared value, with data type and legal values depending on excise condition, used in defining the taxable value of the item. + + + + + + + Specifies the types of Estimated Duties and Taxes to be included in a rate quotation for an international shipment. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Electronic Trade document references used with the ETD special service. + + + + + Indicates the types of shipping documents produced for the shipper by FedEx (see ShippingDocumentSpecification) which should be copied back to the shipper in the shipment result data. + + + + + Currently not supported. + + + + + + + + Country specific details of an International shipment. + + + + + + Specifies which filing option is being exercised by the customer. + Required for non-document shipments originating in Canada destined for any country other than Canada, the United States, Puerto Rico or the U.S. Virgin Islands. + + + + + + + Required only if B13AFilingOption is one of the following: + FILED_ELECTRONICALLY + MANUALLY_ATTACHED + SUMMARY_REPORTING + If B13AFilingOption = NOT_REQUIRED, this field should contain a valid B13A Exception Number. + + + 50 + + + + + + This field is applicable only to Canada export non-document shipments of any value to any destination. No special characters allowed. + + 10 + + + + + + Department of Commerce/Department of State information about this shipment. + + + + + + + Details specific to an Express freight shipment. + + + + + Indicates whether or nor a packing list is enclosed. + + + + + + Total shipment pieces. + ie. 3 boxes and 3 pallets of 100 pieces each = Shippers Load and Count of 303. + Applicable to International Priority Freight and International Economy Freight. + Values must be in the range of 1 - 99999 + + + + + + Required for International Freight shipping. Values must be 8- 12 characters in length. + + 12 + + + + + + Currently not supported. + + + + + Currently not supported. + + + + + Currently not supported. + + + + + + + Currently not supported. Delivery contact information for an Express freight shipment. + + + + + + + + + Indicates a FedEx Express operating region. + + + + + + + + + + + + Identifies a kind of FedEx facility. + + + + + + + + + + Specifies the optional features/characteristics requested for a Freight shipment utilizing a flatbed trailer. + + + + + + + + + + + + + + + + + + + + Individual charge which contributes to the total base charge for the shipment. + + + + + Freight class for this line item. + + + + + Effective freight class used for rating this line item. + + + + + NMFC Code for commodity. + + + + + Customer-provided description for this commodity or class line. + + + + + Weight for this commodity or class line. + + + + + Rate or factor applied to this line item. + + + + + Identifies the manner in which the chargeRate for this line item was applied. + + + + + The net or extended charge for this line item. + + + + + + + + + + + + + + + + + + + + These values represent the industry-standard freight classes used for FedEx Freight and FedEx National Freight shipment description. (Note: The alphabetic prefixes are required to distinguish these values from decimal numbers on some client platforms.) + + + + + + + + + + + + + + + + + + + + + + + + + Information about the Freight Service Centers associated with this shipment. + + + + + Information about the origin Freight Service Center. + + + + + Information about the destination Freight Service Center. + + + + + The distance between the origin and destination FreightService Centers + + + + + + + + + + Date for all Freight guarantee types. + + + + + Time for GUARANTEED_TIME only. + + + + + + + + + + + + + + Identifies responsibilities with respect to loss, damage, etc. + + + + + + + + + Rate data specific to FedEx Freight or FedEx National Freight services. + + + + + A unique identifier for a specific rate quotation. + + + + + Specifies the way in which base charges for a Freight shipment are calculated. + + + + + Freight charges which accumulate to the total base charge for the shipment. + + + + + Human-readable descriptions of additional information on this shipment rating. + + + + + + + Additional non-monetary data returned with Freight rates. + + + + + Unique identifier for notation. + + + + + Human-readable explanation of notation. + + + + + + + This class describes the relationship between a customer-specified address and the FedEx Freight / FedEx National Freight Service Center that supports that address. + + + + + Freight Industry standard non-FedEx carrier identification + + + + + The name of the Interline carrier. + + + + + Additional time it might take at the origin or destination to pickup or deliver the freight. This is usually due to the remoteness of the location. This time is included in the total transit time. + + + + + Service branding which may be used for local pickup or delivery, distinct from service used for line-haul of customer's shipment. + + + + + Distance between customer address (pickup or delivery) and the supporting Freight / National Freight service center. + + + + + Time to travel between customer address (pickup or delivery) and the supporting Freight / National Freight service center. + + + + + Specifies when/how the customer can arrange for pickup or delivery. + + + + + Specifies days of operation if localServiceScheduling is LIMITED. + + + + + Freight service center that is a gateway on the border of Canada or Mexico. + + + + + Alphabetical code identifying a Freight Service Center + + + + + Freight service center Contact and Address + + + + + + + Specifies the type of service scheduling offered from a Freight or National Freight Service Center to a customer-supplied address. + + + + + + + + + + Data applicable to shipments using FEDEX_FREIGHT and FEDEX_NATIONAL_FREIGHT services. + + + + + Account number used with FEDEX_FREIGHT service. + + + + + Used for validating FedEx Freight account number and (optionally) identifying third party payment on the bill of lading. + + + + + Account number used with FEDEX_NATIONAL_FREIGHT service. + + + + + Used for validating FedEx National Freight account number and (optionally) identifying third party payment on the bill of lading. + + + + + Indicates the role of the party submitting the transaction. + + + + + Designates which of the requester's tariffs will be used for rating. + + + + + Identifies the declared value for the shipment + + + + + Identifies the declared value units corresponding to the above defined declared value + + + + + + Identifiers for promotional discounts offered to customers. + + + + + Total number of individual handling units in the entire shipment (for unit pricing). + + + + + Estimated discount rate provided by client for unsecured rate quote. + + + + + Total weight of pallets used in shipment. + + + + + Overall shipment dimensions. + + + + + Description for the shipment. + + + + + Specifies which party will pay surcharges for any special services which support split billing. + + + + + Details of the commodities in the shipment. + + + + + + + Description of an individual commodity or class of content in a shipment. + + + + + Freight class for this line item. + + + + + Specification of handling-unit packaging for this commodity or class line. + + + + + Customer-provided description for this commodity or class line. + + + + + Weight for this commodity or class line. + + + + + FED EX INTERNAL USE ONLY - Individual line item dimensions. + + + + + Volume (cubic measure) for this commodity or class line. + + + + + + + Indicates the role of the party submitting the transaction. + + + + + + + + + + Specifies which party will be responsible for payment of any surcharges for Freight special services for which split billing is allowed. + + + + + Identifies the special service. + + + + + Indicates who will pay for the special service. + + + + + + + Data required to produce a General Agency Agreement document. Remaining content (business data) to be defined once requirements have been completed. + + + + + + + + Documents the kind and quantity of an individual hazardous commodity in a package. + + + + + Identifies and describes an individual hazardous commodity. + + + + + Specifies the amount of the commodity in alternate units. + + + + + Customer-provided specifications for handling individual commodities. + + + + + + + Identifies and describes an individual hazardous commodity. For 201001 load, this is based on data from the FedEx Ground Hazardous Materials Shipping Guide. + + + + + Regulatory identifier for a commodity (e.g. "UN ID" value). + + + + + + + + + + + + + Specifies how the commodity is to be labeled. + + + + + + + + + + Customer-provided specifications for handling individual commodities. + + + + + Specifies how the customer wishes the label text to be handled for this commodity in this package. + + + + + Text used in labeling the commodity under control of the labelTextOption field. + + + + + + + Indicates which kind of hazardous content (as defined by DOT) is being reported. + + + + + + + + + + + + Identifies number and type of packaging units for hazardous commodities. + + + + + Number of units of the type below. + + + + + Units in which the hazardous commodity is packaged. + + + + + + + Identifies DOT packing group for a hazardous commodity. + + + + + + + + + + Identifies amount and units for quantity of hazardous commodities. + + + + + Number of units of the type below. + + + + + Units by which the hazardous commodity is measured. + + + + + + + Descriptive data required for a FedEx shipment that is to be held at the destination FedEx location for pickup by the recipient. + + + + + Contact phone number for recipient of shipment. + + 15 + + + + + + Contact and address of FedEx facility at which shipment is to be held. + + + + + Type of facility at which package/shipment is to be held. + + + + + Location identification (for facilities identified by an alphanumeric location code). + + + + + Location identification (for facilities identified by an numeric location code). + + + + + + + The descriptive data required by FedEx for home delivery services. + + + + + + + Required for Date Certain Home Delivery. + + + + + Required for Date Certain and Appointment Home Delivery. + + 15 + + + + + + + + + + + + + + + + + + + + + + + + The type of International shipment. + + + + + + + + + Specifies the type of label to be returned. + + + + + + + + + + + + Names for data elements / areas which may be suppressed from printing on labels. + + + + + + + + + + + + + + + + + This indicates if the top or bottom of the label comes out of the printer first. + + + + + + + + + Relative to normal orientation for the printer. RIGHT=90 degrees clockwise, UPSIDE_DOWN=180 degrees, LEFT=90 degrees counterclockwise. + + + + + + + + + + + Description of shipping label to be returned in the reply + + + + + Specify type of label to be returned + + + + + + The type of image or printer commands the label is to be formatted in. + DPL = Unimark thermal printer language + EPL2 = Eltron thermal printer language + PDF = a label returned as a pdf image + PNG = a label returned as a png image + ZPLII = Zebra thermal printer language + + + + + + For thermal printer lables this indicates the size of the label and the location of the doc tab if present. + + + + + This indicates if the top or bottom of the label comes out of the printer first. + + + + + Relative to normal orientation for the printer. RIGHT=90 degrees clockwise, UPSIDE_DOWN=180 degrees, LEFT=90 degrees counterclockwise. + + + + + If present, this contact and address information will replace the return address information on the label. + + + + + Allows customer-specified control of label content. + + + + + + + For thermal printer labels this indicates the size of the label and the location of the doc tab if present. + + + + + + + + + + + + + + + + + + + + + + Identifies the Liability Coverage Amount. For Jan 2010 this value represents coverage amount per pound + + + + + + + + + + + + + Represents a one-dimensional measurement in small units (e.g. suitable for measuring a package or document), contrasted with Distance, which represents a large one-dimensional measurement (e.g. distance between cities). + + + + + The numerical quantity of this measurement. + + + + + The units for this measurement. + + + + + + + CM = centimeters, IN = inches + + + + + + + + + Identifies the representation of human-readable text. + + + + + Two-letter code for language (e.g. EN, FR, etc.) + + + + + Two-letter code for the region (e.g. us, ca, etc..). + + + + + + + + + + + + + Internal FedEx use only. + + + + + + + + + + + + + + + + + + Data required to produce a Certificate of Origin document. + + + + + + + Indicates which Party (if any) from the shipment is to be used as the source of importer data on the NAFTA COO form. + + + + + Contact information for "Authorized Signature" area of form. + + + + + + + + + + + + Defined by NAFTA regulations. + + + + + Defined by NAFTA regulations. + + + + + Identification of which producer is associated with this commodity (if multiple producers are used in a single shipment). + + + + + + Date range over which RVC net cost was calculated. + + + + + + + + + + + + + + + + Net cost method used. + + + + + + + + + + See instructions for NAFTA Certificate of Origin for code definitions. + + + + + + + + + + + + + + + + + + + See instructions for NAFTA Certificate of Origin for code definitions. + + + + + + + + + + + + + + + + + + + + The descriptive data regarding the result of the submitted transaction. + + + + + The severity of this notification. This can indicate success or failure or some other information about the request. The values that can be returned are SUCCESS - Your transaction succeeded with no other applicable information. NOTE - Additional information that may be of interest to you about your transaction. WARNING - Additional information that you need to know about your transaction that you may need to take action on. ERROR - Information about an error that occurred while processing your transaction. FAILURE - FedEx was unable to process your transaction at this time due to a system failure. Please try again later + + + + + Indicates the source of this notification. Combined with the Code it uniquely identifies this notification + + + + + A code that represents this notification. Combined with the Source it uniquely identifies this notification. + + 8 + + + + + + Human-readable text that explains this notification. + + 255 + + + + + + The translated message. The language and locale specified in the ClientDetail. Localization are used to determine the representation. Currently only supported in a TrackReply. + + + + + A collection of name/value pairs that provide specific data to help the client determine the nature of an error (or warning, etc.) witout having to parse the message string. + + + + + + + + + Identifies the type of data contained in Value (e.g. SERVICE_TYPE, PACKAGE_SEQUENCE, etc..). + + + + + The value of the parameter (e.g. PRIORITY_OVERNIGHT, 2, etc..). + + + + + + + Identifies the set of severity values for a Notification. + + + + + + + + + + + + The instructions indicating how to print the OP-900 form for hazardous materials packages. + + + + + Specifies characteristics of a shipping document to be produced. + + + + + Identifies which reference type (from the package's customer references) is to be used as the source for the reference on this OP-900. + + + + + Specifies the usage and identification of customer supplied images to be used on this document. + + + + + Data field to be used when a name is to be printed in the document instead of (or in addition to) a signature image. + + + + + + + The Oversize classification for a package. + + + + + + + + + + Data for a package's rates, as calculated per a specific rate type. + + + + + Type used for this specific set of rate data. + + + + + Indicates which weight was used. + + + + + Internal FedEx use only. + + + + + The weight that was used to calculate the rate. + + + + + The dimensional weight of this package (if greater than actual). + + + + + The oversize weight of this package (if the package is oversize). + + + + + The transportation charge only (prior to any discounts applied) for this package. + + + + + The sum of all discounts on this package. + + + + + This package's baseCharge - totalFreightDiscounts. + + + + + The sum of all surcharges on this package. + + + + + This package's netFreight + totalSurcharges (not including totalTaxes). + + + + + The sum of all taxes on this package. + + + + + This package's netFreight + totalSurcharges + totalTaxes. + + + + + The total sum of all rebates applied to this package. + + + + + All rate discounts that apply to this package. + + + + + All rebates that apply to this package. + + + + + All surcharges that apply to this package (either because of characteristics of the package itself, or because it is carrying per-shipment surcharges for the shipment of which it is a part). + + + + + All taxes applicable (or distributed to) this package. + + + + + The variable handling charges calculated based on the type variable handling charges requested. + + + + + + + Identifies the collection of special services offered by FedEx. + + + + + + + + + + + + + + These special services are available at the package level for some or all service types. If the shipper is requesting a special service which requires additional data, the package special service type must be present in the specialServiceTypes collection, and the supporting detail must be provided in the appropriate sub-object below. + + + + + The types of all special services requested for the enclosing shipment or package. + + + + + For use with FedEx Ground services only; COD must be present in shipment's special services. + + + + + Descriptive data required for a FedEx shipment containing dangerous materials. This element is required when SpecialServiceType.DANGEROUS_GOODS or HAZARDOUS_MATERIAL is present in the SpecialServiceTypes collection. + + + + + Descriptive data required for a FedEx shipment containing dry ice. This element is required when SpecialServiceType.DRY_ICE is present in the SpecialServiceTypes collection. + + + + + The descriptive data required for FedEx signature services. This element is required when SpecialServiceType.SIGNATURE_OPTION is present in the SpecialServiceTypes collection. + + + + + To be filled. + + + + + + + Identifies the packaging used by the requestor for the package. See PackagingType for list of valid enumerated values. + + + + + + + + + + + + + + The descriptive data for a person or company entitiy doing business with FedEx. + + + + + Identifies the FedEx account number assigned to the customer. + + 12 + + + + + + Descriptive data for taxpayer identification information. + + + + + Descriptive data identifying the point-of-contact person. + + + + + The descriptive data for a physical location. + + + + + + + The descriptive data for the monetary compensation given to FedEx for services rendered to the customer. + + + + + Identifies the method of payment for a service. See PaymentType for list of valid enumerated values. + + + + + Descriptive data identifying the party responsible for payment for a service. + + + + + + + Identifies the method of payment for a service. + + + + + + + + Descriptive data identifying the party responsible for payment for a service. + + + + + Identifies the FedEx account number assigned to the payor. + + 12 + + + + + + Identifies the country of the payor. + + + + + + + This information describes the kind of pending shipment being requested. + + + + + + + Date after which the pending shipment will no longer be available for completion. + + + + + Only used with type of EMAIL. + + + + + + + + + + + + This enumeration rationalizes the former FedEx Express international "admissibility package" types (based on ANSI X.12) and the FedEx Freight packaging types. The values represented are those common to both carriers. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This class describes the pickup characteristics of a shipment (e.g. for use in a tag request). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Currently not supported. + + + + + + + + + + + + + + + + + + Identifies the type of dim divisor that was applied. + + + + + + + + + + + + Identifies a discount applied to the shipment. + + + + + Identifies the type of discount applied to the shipment. + + + + + + The amount of the discount applied to the shipment. + + + + + The percentage of the discount applied to the shipment. + + + + + + + Identifies the type of discount applied to the shipment. + + + + + + + + + + + + The response to a RateRequest. The Notifications indicate whether the request was successful or not. + + + + + This indicates the highest level of severity of all the notifications returned in this reply. + + + + + The descriptive data regarding the results of the submitted transaction. + + + + + Contains the CustomerTransactionId that was sent in the request. + + + + + The version of this reply. + + + + + Each element contains all rate data for a single service. If service was specified in the request, there will be a single entry in this array; if service was omitted in the request, there will be a separate entry in this array for each service being compared. + + + + + + + + + Identifies the FedEx service to use in shipping the package. See ServiceType for list of valid enumerated values. + + + + + Identifies the packaging used by the requestor for the package. See PackagingType for list of valid enumerated values. + + + + + Shows the specific combination of service options combined with the service type that produced this committment in the set returned to the caller. + + + + + Supporting detail for applied options identified in preceding field. + + + + + + + + + Identification of an airport, using standard three-letter abbreviations. + + + + + Indicates whether or not this shipment is eligible for a money back guarantee. + + + + + Commitment code for the origin. + + + + + Commitment code for the destination. + + + + + Time in transit from pickup to delivery. + + + + + Maximum expected transit time. + + + + + The signature option for this package. + + + + + The actual rate type of the charges for this package. + + + + + Each element contains all rate data for a single rate type. + + + + + + + Descriptive data sent to FedEx by a customer in order to rate a package/shipment. + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Allows the caller to specify that the transit time and commit data are to be returned in the reply. + + + + + Candidate carriers for rate-shopping use case. This field is only considered if requestedShipment/serviceType is omitted. + + + + + Contains zero or more service options whose combinations are to be considered when replying with available services. + + + + + The shipment for which a rate quote (or rate-shopping comparison) is desired. + + + + + + + Indicates the type of rates to be returned. + + + + + + + + + If requesting rates using the PackageDetails element (one package at a time) in the request, the rates for each package will be returned in this element. Currently total piece total weight rates are also retuned in this element. + + + + + Echoed from the corresponding package in the rate request (if provided). + + + + + Used with request containing PACKAGE_GROUPS, to identify which group of identical packages was used to produce a reply item. + + + + + The difference between "list" and "account" net charge. + + + + + Ground COD is package level. + + + + + + Rate data that are tied to a specific package and rate type combination. + + + + + + + This class groups the shipment and package rating data for a specific rate type for use in a rating reply, which groups result data by rate type. + + + + + The difference between "list" and "account" total net charge. + + + + + Ground COD is package level. + + + + + The shipment-level totals for this rate type. + + + + + The package-level data for this rate type. + + + + + + + The method used to calculate the weight to be used in rating the package.. + + + + + + + + + + + + + + + + + + + Identifies a discount applied to the shipment. + + + + + + + The amount of the discount applied to the shipment. + + + + + The percentage of the discount applied to the shipment. + + + + + + + Identifies the type of discount applied to the shipment. + + + + + + + + + + Specifies how the recipient is identified for customs purposes; the requirements on this information vary with destination country. + + + + + Specifies the kind of identification being used. + + + + + Contains the actual ID value, of the type specified above. + + + + + + + Type of Brazilian taxpayer identifier provided in Recipient/TaxPayerIdentification/Number. For shipments bound for Brazil this overrides the value in Recipient/TaxPayerIdentification/TinType + + + + + + + + + + FOOD_OR_PERISHABLE is required by FDA/BTA; must be true for food/perishable items coming to US or PR from non-US/non-PR origin + + + + + + + + + + + + + + + + + This class rationalizes RequestedPackage and RequestedPackageSummary from previous interfaces. The way in which it is uses within a RequestedShipment depends on the RequestedPackageDetailType value specified for that shipment. + + + + + Used only with INDIVIDUAL_PACKAGE, as a unique identifier of each requested package. + + + + + Used only with PACKAGE_GROUPS, as a unique identifier of each group of identical packages. + + + + + Used only with PACKAGE_GROUPS, as a count of packages within a group of identical packages. + + + + + + Only used for INDIVIDUAL_PACKAGES and PACKAGE_GROUPS. Ignored for PACKAGE_SUMMARY, in which case totalInsuredValue and packageCount on the shipment will be used to determine this value. + + + + + Only used for INDIVIDUAL_PACKAGES and PACKAGE_GROUPS. Ignored for PACKAGE_SUMMARY, in which case totalweight and packageCount on the shipment will be used to determine this value. + + + + + + Provides additional detail on how the customer has physically packaged this item. As of June 2009, required for packages moving under international and SmartPost services. + + + + + Human-readable text describing the package. + + + + + + + Only used for INDIVIDUAL_PACKAGES and PACKAGE_GROUPS. + + + + + + + The descriptive data for the shipment being tendered to FedEx. + + + + + Identifies the date and time the package is tendered to FedEx. Both the date and time portions of the string are expected to be used. The date should not be a past date or a date more than 10 days in the future. The time is the local time of the shipment based on the shipper's time zone. The date component must be in the format: YYYY-MM-DD (e.g. 2006-06-26). The time component must be in the format: HH:MM:SS using a 24 hour clock (e.g. 11:00 a.m. is 11:00:00, whereas 5:00 p.m. is 17:00:00). The date and time parts are separated by the letter T (e.g. 2006-06-26T17:00:00). There is also a UTC offset component indicating the number of hours/mainutes from UTC (e.g 2006-06-26T17:00:00-0400 is defined form June 26, 2006 5:00 pm Eastern Time). + + + + + Identifies the method by which the package is to be tendered to FedEx. This element does not dispatch a courier for package pickup. See DropoffType for list of valid enumerated values. + + + + + Identifies the FedEx service to use in shipping the package. See ServiceType for list of valid enumerated values. + + + + + Identifies the packaging used by the requestor for the package. See PackagingType for list of valid enumerated values. + + + + + Identifies the total weight of the shipment being conveyed to FedEx.This is only applicable to International shipments and should only be used on the first package of a mutiple piece shipment.This value contains 1 explicit decimal position + + + + + Total insured amount. + + + + + Descriptive data identifying the party responsible for shipping the package. Shipper and Origin should have the same address. + + + + + Descriptive data identifying the party receiving the package. + + + + + A unique identifier for a recipient location + + 10 + + + + + + Physical starting address for the shipment, if different from shipper's address. + + + + + Descriptive data indicating the method and means of payment to FedEx for providing shipping services. + + + + + Descriptive data regarding special services requested by the shipper for this shipment. If the shipper is requesting a special service which requires additional data (e.g. COD), the special service type must be present in the specialServiceTypes collection, and the supporting detail must be provided in the appropriate sub-object. For example, to request COD, "COD" must be included in the SpecialServiceTypes collection and the CodDetail object must contain the required data. + + + + + Details specific to an Express freight shipment. + + + + + Data applicable to shipments using FEDEX_FREIGHT and FEDEX_NATIONAL_FREIGHT services. + + + + + Used with Ground Home Delivery and Freight. + + + + + Details about how to calculate variable handling charges at the shipment level. + + + + + Customs clearance data, used for both international and intra-country shipping. + + + + + For use in "process tag" transaction. + + + + + + If true, only the shipper/payor will have visibility of this shipment. + + + + + Details about the image format and printer type the label is to returned in. + + + + + Details such as shipping document types, NAFTA information, CI information, and GAA information. + + + + + Specifies whether and what kind of rates the customer wishes to have quoted on this shipment. The reply will also be constrained by other data on the shipment and customer. + + + + + Specifies whether the customer wishes to have Estimated Duties and Taxes provided with the rate quotation on this shipment. Only applies with shipments moving under international services. + + + + + For a multiple piece shipment this is the total number of packages in the shipment. + + + + + Specifies whether packages are described individually, in groups, or summarized in a single description for total-piece-total-weight. This field controls which fields of the RequestedPackageLineItem will be used, and how many occurrences are expected. + + + + + One or more package-attribute descriptions, each of which describes an individual package, a group of identical packages, or (for the total-piece-total-weight case) common characteristics all packages in the shipment. + + + + + + + + + Currently not supported. + + + + + Currently not supported. + + + + + + + + Currently not supported. + + + + + Currently not supported. + + + + + + + + + + + + + + + + + + These values are used to control the availability of certain special services at the time when a customer uses the e-mail label link to create a return shipment. + + + + + + + + + + + + Identifies the allowed (merchant-authorized) special services which may be selected when the subsequent shipment is created. Only services represented in EMailLabelAllowedSpecialServiceType will be controlled by this list. + + + + + + + Information relating to a return shipment. + + + + + The type of return shipment that is being requested. At present the only type of retrun shipment that is supported is PRINT_RETURN_LABEL. With this option you can print a return label to insert into the box of an outbound shipment. This option can not be used to print an outbound label. + + + + + Return Merchant Authorization + + + + + Specific information about the delivery of the email and options for the shipment. + + + + + + + The type of return shipment that is being requested. + + + + + + + + + + The "PAYOR..." rates are expressed in the currency identified in the payor's rate table(s). The "RATED..." rates are expressed in the currency of the origin country. + + + + + + + + + + + + + + + Return Merchant Authorization + + + + + Return Merchant Authorization Number + + 20 + + + + + + The reason for the return. + + 60 + + + + + + + + These values control the optional features of service that may be combined in a commitment/rate comparision transaction. + + + + + + + + + + + Supporting detail for applied options identified in a rate quote. + + + + + Identifies the type of Freight Guarantee applied, if FREIGHT_GUARANTEE is applied to the rate quote. + + + + + Identifies the smartPostHubId used during rate quote, if SMART_POST_HUB_ID is a variable option on the rate request. + + + + + Identifies the indicia used during rate quote, if SMART_POST_ALLOWED_INDICIA is a variable option on the rate request. + + + + + + + Identifies the FedEx service to use in shipping the package. See ServiceType for list of valid enumerated values. + + + + + + + + + + + + + + + + + + + + + + + + + + + Shipment-level totals of dry ice data across all packages. + + + + + Total number of packages in the shipment that contain dry ice. + + + + + Total shipment dry ice weight for all packages. + + + + + + + Data for a shipment's total/summary rates, as calculated per a specific rate type. The "total..." fields may differ from the sum of corresponding package data for Multiweight or Express MPS. + + + + + Type used for this specific set of rate data. + + + + + Indicates the rate scale used. + + 5 + + + + + + Indicates the rate zone used (based on origin and destination). + + 1 + + + + + + Indicates the type of pricing used for this shipment. + + + + + Indicates which weight was used. + + + + + INTERNAL FEDEX USE ONLY. + + + + + Specifies the currency exchange performed on financial amounts for this rate. + + + + + Indicates which special rating cases applied to this shipment. + + + + + The value used to calculate the weight based on the dimensions. + + + + + Identifies the type of dim divisor that was applied. + + + + + + The weight used to calculate these rates. + + + + + Sum of dimensional weights for all packages. + + + + + + The total discounts used in the rate calculation. + + + + + The freight charge minus discounts. + + + + + The total amount of all surcharges applied to this shipment. + + + + + This shipment's totalNetFreight + totalSurcharges (not including totalTaxes). + + + + + Total of the transportation-based taxes. + + + + + The net charge after applying all discounts and surcharges. + + + + + The total sum of all rebates applied to this shipment. + + + + + Total of all values under this shipment's dutiesAndTaxes; only provided if estimated duties and taxes were calculated for this shipment. + + + + + This shipment's totalNetCharge + totalDutiesAndTaxes; only provided if estimated duties and taxes were calculated for this shipment AND duties, taxes and transportation charges are all paid by the same sender's account. + + + + + Rate data specific to FedEx Freight and FedEx National Freight services. + + + + + All rate discounts that apply to this shipment. + + + + + All rebates that apply to this shipment. + + + + + All surcharges that apply to this shipment. + + + + + All transportation-based taxes applicable to this shipment. + + + + + All commodity-based duties and taxes applicable to this shipment. + + + + + The "order level" variable handling charges. + + + + + The total of all variable handling charges at both shipment (order) and package level. + + + + + + + Identifies the collection of special service offered by FedEx. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + These special services are available at the shipment level for some or all service types. If the shipper is requesting a special service which requires additional data (such as the COD amount), the shipment special service type must be present in the specialServiceTypes collection, and the supporting detail must be provided in the appropriate sub-object below. + + + + + The types of all special services requested for the enclosing shipment (or other shipment-level transaction). + + + + + Descriptive data required for a FedEx COD (Collect-On-Delivery) shipment. This element is required when SpecialServiceType.COD is present in the SpecialServiceTypes collection. + + + + + Descriptive data required for a FedEx shipment that is to be held at the destination FedEx location for pickup by the recipient. This element is required when SpecialServiceType.HOLD_AT_LOCATION is present in the SpecialServiceTypes collection. + + + + + Descriptive data required for FedEx to provide email notification to the customer regarding the shipment. This element is required when SpecialServiceType.EMAIL_NOTIFICATION is present in the SpecialServiceTypes collection. + + + + + The descriptive data required for FedEx Printed Return Label. This element is required when SpecialServiceType.PRINTED_RETURN_LABEL is present in the SpecialServiceTypes collection + + + + + This field should be populated for pending shipments (e.g. e-mail label) It is required by a PENDING_SHIPMENT special service type. + + + + + The number of packages with dry ice and the total weight of the dry ice. + + + + + The descriptive data required for FedEx Home Delivery options. This element is required when SpecialServiceType.HOME_DELIVERY_PREMIUM is present in the SpecialServiceTypes collection + + + + + + + Electronic Trade document references. + + + + + Specification for date or range of dates on which delivery is to be attempted. + + + + + + + Each occurrence of this class specifies a particular way in which a kind of shipping document is to be produced and provided. + + + + + Values in this field specify how to create and return the document. + + + + + Specifies how to organize all documents of this type. + + + + + Specifies how to e-mail document images. + + + + + Specifies how a queued document is to be printed. + + + + + + + Specifies how to return a shipping document to the caller. + + + + + + + + + + + + + + Specifies how to e-mail shipping documents. + + + + + Provides the roles and email addresses for e-mail recipients. + + + + + Identifies the convention by which documents are to be grouped as e-mail attachments. + + + + + + + + + + + + + Specifies an individual recipient of e-mailed shipping document(s). + + + + + Identifies the relationship of this recipient in the shipment. + + + + + Address to which the document is to be sent. + + + + + + + Specifies characteristics of a shipping document to be produced. + + + + + Specifies how to create, organize, and return the document. + + + + + Specifies how far down the page to move the beginning of the image; allows for printing on letterhead and other pre-printed stock. + + + + + + + For those shipping document types which have both a "form" and "instructions" component (e.g. NAFTA Certificate of Origin and General Agency Agreement), this field indicates whether to provide the instructions. + + + + + Governs the language to be used for this individual document, independently from other content returned for the same shipment. + + + + + + + Specifies how to organize all shipping documents of the same type. + + + + + + + + + Specifies the image format used for a shipping document. + + + + + + + + + + + + Specifies printing options for a shipping document. + + + + + Provides environment-specific printer identification. + + + + + + + Contains all data required for additional (non-label) shipping documents to be produced in conjunction with a specific shipment. + + + + + Indicates the types of shipping documents requested by the shipper. + + + + + + + Specifies the production of each package-level custom document (the same specification is used for all packages). + + + + + Specifies the production of a shipment-level custom document. + + + + + Details pertaining to the GAA. + + + + + Details pertaining to NAFTA COO. + + + + + Specifies the production of the OP-900 document for hazardous materials packages. + + + + + + + Specifies the type of paper (stock) on which a document will be printed. + + + + + + + + + + + + + + + + + The descriptive data required for FedEx delivery signature services. + + + + + Identifies the delivery signature services option selected by the customer for this shipment. See OptionType for the list of valid values. + + + + + Identifies the delivery signature release authorization number. + + 10 + + + + + + + + Identifies the delivery signature services options offered by FedEx. + + + + + + + + + + + + These values are mutually exclusive; at most one of them can be attached to a SmartPost shipment. + + + + + + + + + + + + + + + + + + + + + Data required for shipments handled under the SMART_POST and GROUND_SMART_POST service types. + + + + + + + + + + + Indicates which special rating cases applied to this shipment. + + + + + + + + + Identifies each surcharge applied to the shipment. + + + + + The type of surcharge applied to the shipment. + + + + + + + The amount of the surcharge applied to the shipment. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Identifies each tax applied to the shipment. + + + + + + + + + + + + + + + + + + + + + The descriptive data for taxpayer identification information. + + + + + Identifies the category of the taxpayer identification number. See TinType for the list of values. + + + + + Identifies the taxpayer identification number. + + 18 + + + + + + Identifies the usage of Tax Identification Number in Shipment processing + + + + + + + + Required for dutiable international express or ground shipment. This field is not applicable to an international PIB (document) or a non-document which does not require a commercial invoice express shipment. + CFR_OR_CPT (Cost and Freight/Carriage Paid TO) + CIF_OR_CIP (Cost Insurance and Freight/Carraige Insurance Paid) + DDP (Delivered Duty Paid) + DDU (Delivered Duty Unpaid) + EXW (Ex Works) + FOB_OR_FCA (Free On Board/Free Carrier) + + + + + + + + + + + + + + Identifies the category of the taxpayer identification number. + + + + + + + + + + + + + + + + + + + + + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Free form text to be echoed back in the reply. Used to match requests and replies. + + 40 + + + + + + Governs data payload language/translations (contrasted with ClientDetail.localization, which governs Notification.localizedMessage language selection). + + + + + + + Time in transit from pickup to delivery. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Details about how to calculate variable handling charges at the shipment level. + + + + + The type of handling charge to be calculated and returned in the reply. + + + + + Used with Variable handling charge type of FIXED_VALUE. Contains the amount to be added to the freight charge. Contains 2 explicit decimal positions with a total max length of 10 including the decimal. + + + + + Used with Variable handling charge types PERCENTAGE_OF_BASE, PERCENTAGE_OF_NET or PERCETAGE_OF_NET_EXCL_TAXES. Used to calculate the amount to be added to the freight charge. Contains 2 explicit decimal positions. + + + + + + + The type of handling charge to be calculated and returned in the reply. + + + + + + + + + + + The variable handling charges calculated based on the type variable handling charges requested. + + + + + The variable handling charge amount calculated based on the requested variable handling charge detail. + + + + + The calculated varibale handling charge plus the net charge. + + + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Identifies a system or sub-system which performs an operation. + + + + + Identifies the service business level. + + + + + Identifies the service interface level. + + + + + Identifies the service code level. + + + + + + + Three-dimensional volume/cubic measurement. + + + + + + + + + Units of three-dimensional volume/cubic measure. + + + + + + + + + Two part authentication string used for the sender's identity + + + + + Identifying part of authentication credential. This value is provided by FedEx after registration + + 16 + + + + + + Secret part of authentication key. This value is provided by FedEx after registration. + + 25 + + + + + + + + Used in authentication of the sender's identity. + + + + + Credential used to authenticate a specific software application. This value is provided by FedEx after registration. + + + + + + + The descriptive data for the heaviness of an object. + + + + + Identifies the unit of measure associated with a weight value. See WeightUnits for the list of valid enumerated values. + + + + + Identifies the weight value of the package/shipment. Contains 1 explicit decimal position + + + + + + + Identifies the unit of measure associated with a weight value. See WeightUnits for the list of valid enumerated values. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git app/code/core/Mage/Usa/etc/wsdl/FedEx/ShipService_v10.wsdl app/code/core/Mage/Usa/etc/wsdl/FedEx/ShipService_v10.wsdl new file mode 100644 index 0000000..6a35329 --- /dev/null +++ app/code/core/Mage/Usa/etc/wsdl/FedEx/ShipService_v10.wsdl @@ -0,0 +1,5472 @@ + + + + + + + + + + + + + + + + + + Specifies additional labels to be produced. All required labels for shipments will be produced without the need to request additional labels. These are only available as thermal labels. + + + + + The type of additional labels to return. + + + + + The number of this type label to return + + + + + + + Identifies the type of additional labels. + + + + + + + + + + + + + + + + Descriptive data for a physical location. May be used as an actual physical address (place to which one could go), or as a container of "address parts" which should be handled as a unit (such as a city-state-ZIP combination within the US). + + + + + Combination of number, street name, etc. At least one line is required for a valid physical address; empty lines should not be included. + + + + + Name of city, town, etc. + + + + + Identifying abbreviation for US state, Canada province, etc. Format and presence of this field will vary, depending on country. + + + + + Identification of a region (usually small) for mail/package delivery. Format and presence of this field will vary, depending on country. + + + + + Relevant only to addresses in Puerto Rico. + + + + + The two-letter code used to identify a country. + + + + + Indicates whether this address residential (as opposed to commercial). + + + + + + + + + Position of Astra element + + + + + Content corresponding to the Astra Element + + + + + + + + Specifies which filing option is being exercised by the customer. + Required for non-document shipments originating in Canada destined for any country other than Canada, the United States, Puerto Rico or the U.S. Virgin Islands. + + + + + + + + + + + + Identification of the type of barcode (symbology) used on FedEx documents and labels. + + + + + + + + + + Each instance of this data type represents a barcode whose content must be represented as binary data (i.e. not ASCII text). + + + + + The kind of barcode data in this instance. + + + + + The data content of this instance. + + + + + + + + + + + + + + + + + + + + Descriptive data sent to FedEx by a customer in order to Cancel a Pending shipment. + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + + + + Identification of a FedEx operating company (transportation). + + + + + + + + + + + + + The instructions indicating how to print the Certificate of Origin ( e.g. whether or not to include the instructions, image type, etc ...) + + + + + Specifies characteristics of a shipping document to be produced. + + + + + Specifies the usage and identification of customer supplied images to be used on this document. + + + + + + + Specifies the type of brokerage to be applied to a shipment. + + + + + + + + + + + + Descriptive data for the client submitting a transaction. + + + + + The FedEx account number associated with this transaction. + + + + + This number is assigned by FedEx and identifies the unique device from which the request is originating + + + + + Only used in transactions which require identification of the Fed Ex Office integrator. + + + + + The language to be used for human-readable Notification.localizedMessages in responses to the request containing this ClientDetail object. Different requests from the same client may contain different Localization data. (Contrast with TransactionDetail.localization, which governs data payload language/translation.) + + + + + + + Identifies what freight charges should be added to the COD collect amount. + + + + + + + + + + + + + + + + + + + Identifies the type of funds FedEx should collect upon shipment delivery. + + + + + + + + + + + + Descriptive data required for a FedEx COD (Collect-On-Delivery) shipment. + + + + + + Identifies if freight charges are to be added to the COD amount. This element determines which freight charges should be added to the COD collect amount. See CodAddTransportationChargesType for a list of valid enumerated values. + + + + + Identifies the type of funds FedEx should collect upon package delivery + + + + + For Express this is the descriptive data that is used for the recipient of the FedEx Letter containing the COD payment. For Ground this is the descriptive data for the party to receive the payment that prints the COD receipt. + + + + + Indicates which type of reference information to include on the COD return shipping label. + + + + + + + + + The COD amount (after any accumulations) that must be collected upon delivery of a package shipped using the COD special service. + + + + + + Contains the data which form the Astra and 2DCommon barcodes that print on the COD return label. + + + + + The label image or printer commands to print the label. + + + + + + + Indicates which type of reference information to include on the COD return shipping label. + + + + + + + + + + + + + The COD amount (after any accumulations) that must be collected upon delivery of a package shipped using the COD special service. + + + + + Currently not supported. + + TBD + + + + + + The description of the FedEx service type used for the COD return shipment. Currently not supported. + + 70 + + + + + + The description of the packaging used for the COD return shipment. + + 40 + + + + + + Currently not supported. + + TBD + + + + + + Currently not supported. + + + + + Currently not supported. + + + + + + The CodRoutingDetail element will contain the COD return tracking number and form id. In the case of a COD multiple piece shipment these will need to be inserted in the request for the last piece of the multiple piece shipment. + The service commitment is the only other element of the RoutingDetail that is used for a CodRoutingDetail. + + + + + + Contains the data which form the Astra and 2DCommon barcodes that print on the COD return label. + + + + + The label image or printer commands to print the label. + + + + + + + CommercialInvoice element is required for electronic upload of CI data. It will serve to create/transmit an Electronic Commercial Invoice through the FedEx Systems. Customers are responsible for printing their own Commercial Invoice.If you would likeFedEx to generate a Commercial Invoice and transmit it to Customs. for clearance purposes, you need to specify that in the ShippingDocumentSpecification element. If you would like a copy of the Commercial Invoice that FedEx generated returned to you in reply it needs to be specified in the ETDDetail/RequestedDocumentCopies element. Commercial Invoice support consists of maximum of 99 commodity line items. + + + + + Any comments that need to be communicated about this shipment. + + + + + Any freight charges that are associated with this shipment. + + + + + Any taxes or miscellaneous charges(other than Freight charges or Insurance charges) that are associated with this shipment. + + + + + Any packing costs that are associated with this shipment. + + + + + Any handling costs that are associated with this shipment. + + + + + Free-form text. + + + + + Free-form text. + + + + + Free-form text. + + + + + The reason for the shipment. Note: SOLD is not a valid purpose for a Proforma Invoice. + + + + + Customer assigned Invoice number + + + + + Name of the International Expert that completed the Commercial Invoice different from Sender. + + + + + Required for dutiable international Express or Ground shipment. This field is not applicable to an international PIB(document) or a non-document which does not require a Commercial Invoice + + + + + + + The instructions indicating how to print the Commercial Invoice( e.g. image type) Specifies characteristics of a shipping document to be produced. + + + + + + Specifies the usage and identification of a customer supplied image to be used on this document. + + + + + + + + For international multiple piece shipments, commodity information must be passed in the Master and on each child transaction. + If this shipment cotains more than four commodities line items, the four highest valued should be included in the first 4 occurances for this request. + + + + + + Name of this commodity. + + + + + Total number of pieces of this commodity + + + + + Complete and accurate description of this commodity. + + 450 + + + + + + Country code where commodity contents were produced or manufactured in their final form. + + 2 + + + + + + + Unique alpha/numeric representing commodity item. + At least one occurrence is required for US Export shipments if the Customs Value is greater than $2500 or if a valid US Export license is required. + + + 14 + + + + + + Total weight of this commodity. 1 explicit decimal position. Max length 11 including decimal. + + + + + Number of units of a commodity in total number of pieces for this line item. Max length is 9 + + + + + Unit of measure used to express the quantity of this commodity line item. + + 3 + + + + + + Contains only additional quantitative information other than weight and quantity to calculate duties and taxes. + + + + + Value of each unit in Quantity. Six explicit decimal positions, Max length 18 including decimal. + + + + + + Total customs value for this line item. + It should equal the commodity unit quantity times commodity unit value. + Six explicit decimal positions, max length 18 including decimal. + + + + + + Defines additional characteristic of commodity used to calculate duties and taxes + + + + + Applicable to US export shipping only. + + 12 + + + + + + + Date of expiration. Must be at least 1 day into future. + The date that the Commerce Export License expires. Export License commodities may not be exported from the U.S. on an expired license. + Applicable to US Export shipping only. + Required only if commodity is shipped on commerce export license, and Export License Number is supplied. + + + + + + + An identifying mark or number used on the packaging of a shipment to help customers identify a particular shipment. + + + 15 + + + + + + All data required for this commodity in NAFTA Certificate of Origin. + + + + + + + + + The identifier for all clearance documents associated with this shipment. + + + + + + + + + + Identifies the branded location name, the hold at location phone number and the address of the location. + + + + + Identifies the type of FedEx location. + + + + + + + + + The package sequence number of this package in a multiple piece shipment. + + + + + The Tracking number and form id for this package. + + + + + Used with request containing PACKAGE_GROUPS, to identify which group of identical packages was used to produce a reply item. + + + + + Oversize class for this package. + + + + + All package-level rating data for this package, which may include data for multiple rate types. + + + + + Associated with package, due to interaction with per-package hazardous materials presence/absence. + + + + + The data that is used to from the Astra and 2DCommon barcodes for the label.. + + + + + The textual description of the special service applied to the package. + + + + + + The label image or printer commands to print the label. + + + + + All package-level shipping documents (other than labels and barcodes). For use in loads after January, 2008. + + + + + Information about the COD return shipment. + + + + + Actual signature option applied, to allow for cases in which the original value conflicted with other service features in the shipment. + + + + + Documents the kinds and quantities of all hazardous commodities in the current package, using updated hazardous commodity description data. + + + + + + + + + Indicates whether or not this is a US Domestic shipment. + + + + + Indicates the carrier that will be used to deliver this shipment. + + + + + The master tracking number and form id of this multiple piece shipment. This information is to be provided for each subsequent of a multiple piece shipment. + + + + + Description of the FedEx service used for this shipment. Currently not supported. + + 70 + + + + + + Description of the packaging used for this shipment. Currently not supported. + + 40 + + + + + + Information about the routing, origin, destination and delivery of a shipment. + + + + + Only used with pending shipments. + + + + + Only used in the reply to tag requests. + + + + + Provides reply information specific to SmartPost shipments. + + + + + All shipment-level rating data for this shipment, which may include data for multiple rate types. + + + + + Information about the COD return shipment. + + + + + Returns the default holding location information when HOLD_AT_LOCATION special service is requested and the client does not specify the hold location address. + + + + + Indicates whether or not this shipment is eligible for a money back guarantee. + + + + + Returns any defaults or updates applied to RequestedShipment.exportDetail.exportComplianceStatement. + + + + + + All shipment-level shipping documents (other than labels and barcodes). + + + + + Package level details about this package. + + + + + + + Provides reply information specific to SmartPost shipments. + + + + + Identifies the carrier that will pick up the SmartPost shipment. + + + + + Indicates whether the shipment is deemed to be machineable, based on dimensions, weight, and packaging. + + + + + + + Provides reply information specific to a tag request. + + + + + . + + + + + As of June 2007, returned only for FedEx Express services. + + + + + As of June 2007, returned only for FedEx Express services. + + + + + As of June 2007, returned only for FedEx Express services. + + + + + As of June 2007, returned only for FedEx Express services. + + + + + FEDEX INTERNAL USE ONLY: for use by INET. + + + + + + + Defines additional data to print in the Configurable portion of the label, this allows you to print the same type information on the label that can also be printed on the doc tab. + + + + + 1 of 12 possible zones to position data. + + + + + The identifiying text for the data in this zone. + + + + + A reference to a field in either the request or reply to print in this zone following the header. + + + + + A literal value to print after the header in this zone. + + + + + + + The descriptive data for a point-of-contact person. + + + + + Client provided identifier corresponding to this contact information. + + + + + Identifies the contact person's name. + + + + + Identifies the contact person's title. + + + + + Identifies the company this contact is associated with. + + + + + Identifies the phone number associated with this contact. + + + + + Identifies the phone extension associated with this contact. + + + + + Identifies the pager number associated with this contact. + + + + + Identifies the fax number associated with this contact. + + + + + Identifies the email address associated with this contact. + + + + + + + + + + + + + Content Record. + + + + + Part Number. + + + + + Item Number. + + + + + Received Quantity. + + + + + Description. + + + + + + + Reply to the Close Request transaction. The Close Reply bring back the ASCII data buffer which will be used to print the Close Manifest. The Manifest is essential at the time of pickup. + + + + + Identifies the highest severity encountered when executing the request; in order from high to low: FAILURE, ERROR, WARNING, NOTE, SUCCESS. + + + + + The descriptive data detailing the status of a sumbitted transaction. + + + + + Descriptive data that governs data payload language/translations. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + The reply payload. All of the returned information about this shipment/package. + + + + + + + Create Pending Shipment Request + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + The descriptive data identifying the client submitting the transaction. + + + + + The descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Descriptive data about the shipment being sent by the requestor. + + + + + + + Currency exchange rate information. + + + + + The currency code for the original (converted FROM) currency. + + + + + The currency code for the final (converted INTO) currency. + + + + + Multiplier used to convert fromCurrency units to intoCurrency units. + + + + + + + + + Indicates the type of custom delivery being requested. + + + + + Time by which delivery is requested. + + + + + Range of dates for custom delivery request; only used if type is BETWEEN. + + + + + Date for custom delivery request; only used for types of ON, BETWEEN, or AFTER. + + + + + + + + + + + + + + + Data required to produce a custom-specified document, either at shipment or package level. + + + + + Common information controlling document production. + + + + + Applicable only to documents produced on thermal printers with roll stock. + + + + + Applicable only to documents produced on thermal printers with roll stock. + + + + + Identifies the formatting specification used to construct this custom document. + + + + + Identifies the individual document specified by the client. + + + + + If provided, thermal documents will include specified doc tab content. If omitted, document will be produced without doc tab content. + + + + + + + Constructed string, based on format and zero or more data fields, printed in specified barcode symbology. + + + + + + + + + Width of thinnest bar/space element in the barcode. + + + + + + + + Solid (filled) rectangular area on label. + + + + + + + + + Valid values for CustomLabelCoordinateUnits + + + + + + + + + + + + + + + + + + Image to be included from printer's memory, or from a local file for offline clients. + + + + + + Printer-specific index of graphic image to be printed. + + + + + Fully-qualified path and file name for graphic image to be printed. + + + + + + + + + Horizontal position, relative to left edge of custom area. + + + + + Vertical position, relative to top edge of custom area. + + + + + + + Constructed string, based on format and zero or more data fields, printed in specified printer font (for thermal labels) or generic font/size (for plain paper labels). + + + + + + + + Printer-specific font name for use with thermal printer labels. + + + + + Generic font name for use with plain paper labels. + + + + + Generic font size for use with plain paper labels. + + + + + + + + + + + + + + + + + + + Reference information to be associated with this package. + + + + + The reference type to be associated with this reference data. + + + + + + + + The types of references available for use. + + + + + + + + + + + + + + + + Allows customer-specified control of label content. + + + + + If omitted, no doc tab will be produced (i.e. default = former NONE type). + + + + + Defines any custom content to print on the label. + + + + + Defines additional data to print in the Configurable portion of the label, this allows you to print the same type information on the label that can also be printed on the doc tab. + + + + + Controls which data/sections will be suppressed. + + + + + Customer-provided SCNC for use with label-data-only processing of FedEx Ground shipments. + + + + + + Controls the number of additional copies of supplemental labels. + + + + + This value reduces the default quantity of destination/consignee air waybill labels. A value of zero indicates no change to default. A minimum of one copy will always be produced. + + + + + + + + + + Interacts both with properties of the shipment and contractual relationship with the shipper. + + + + + + Specifies how the recipient is identified for customs purposes; the requirements on this information vary with destination country. + + + + + + + + Identifies responsibilities with respect to loss, damage, etc. + + + + + Documents amount paid to third party for coverage of shipment content. + + + + + + + + + + + + + + + + + + The descriptive data required for a FedEx shipment containing dangerous goods (hazardous materials). + + + + + Identifies whether or not the products being shipped are required to be accessible during delivery. + + + + + Shipment is packaged/documented for movement ONLY on cargo aircraft. + + + + + Indicates which kinds of hazardous content are in the current package. + + + + + Documents the kinds and quantities of all hazardous commodities in the current package. + + + + + Description of the packaging of this commodity, suitable for use on OP-900 and OP-950 forms. + + + + + Telephone number to use for contact in the event of an emergency. + + + + + Offeror's name or contract number, per DOT regulation. + + + + + + + + + The beginning date in a date range. + + + + + The end date in a date range. + + + + + + + Valid values for DayofWeekType + + + + + + + + + + + + + + Descriptive data sent to FedEx by a customer in order to delete a package. + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + The timestamp of the shipment request. + + + + + Identifies the FedEx tracking number of the package being cancelled. + + + + + Determines the type of deletion to be performed in relation to package level vs shipment level. + + + + + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Only used for tags which had FedEx Express services. + + + + + Only used for tags which had FedEx Express services. + + + + + If the original ProcessTagRequest specified third-party payment, then the delete request must contain the same pay type and payor account number for security purposes. + + + + + Also known as Pickup Confirmation Number or Dispatch Number + + + + + + + Specifies the type of deletion to be performed on a shipment. + + + + + + + + + + Data required to complete the Destionation Control Statement for US exports. + + + + + List of applicable Statment types. + + + + + Comma-separated list of up to four country codes, required for DEPARTMENT_OF_STATE statement. + + + + + Name of end user, required for DEPARTMENT_OF_STATE statement. + + + + + + + Used to indicate whether the Destination Control Statement is of type Department of Commerce, Department of State or both. + + + + + + + + + The dimensions of this package and the unit type used for the measurements. + + + + + + + + + + + + + The DocTabContentType options available. + + + + + The DocTabContentType should be set to ZONE001 to specify additional Zone details. + + + + + The DocTabContentType should be set to BARCODED to specify additional BarCoded details. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Zone number can be between 1 and 12. + + + + + Header value on this zone. + + + + + Reference path to the element in the request/reply whose value should be printed on this zone. + + + + + Free form-text to be printed in this zone. + + + + + Justification for the text printed on this zone. + + + + + + + Identifies the method by which the package is to be tendered to FedEx. This element does not dispatch a courier for package pickup. + + + + + + + + + + + + Describes specific information about the email label shipment. + + + + + Notification email will be sent to this email address + + + + + Message to be sent in the notification email + + + + + + + + + + + + + Information describing email notifications that will be sent in relation to events that occur during package movement + + + + + Specifies whether/how email notifications are grouped. + + + + + A message that will be included in the email notifications + + + + + Information describing the destination of the email, format of the email and events to be notified on + + + + + + + The format of the email + + + + + + + + + + The descriptive data for a FedEx email notification recipient. + + + + + Identifies the relationship this email recipient has to the shipment. + + + + + The email address to send the notification to + + + + + Notify the email recipient when this shipment has been shipped. + + + + + Notify the email recipient if this shipment encounters a problem while in route + + + + + Notify the email recipient when this shipment has been delivered. + + + + + The format of the email notification. + + + + + The language/locale to be used in this email notification. + + + + + + + Identifies the set of valid email notification recipient types. For SHIPPER, RECIPIENT and BROKER the email address asssociated with their definitions will be used, any email address sent with the email notification for these three email notification recipient types will be ignored. + + + + + + + + + + + + + + + + + + + + + Customer-declared value, with data type and legal values depending on excise condition, used in defining the taxable value of the item. + + + + + + + Specifies the types of Estimated Duties and Taxes to be included in a rate quotation for an international shipment. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Specifies the client-requested response in the event of errors within shipment. + PACKAGE_ERROR_LABELS : Return per-package error label in addition to error Notifications. + STANDARD : Return error Notifications only. + + + + + + + + + + Electronic Trade document references used with the ETD special service. + + + + + Indicates the types of shipping documents produced for the shipper by FedEx (see ShippingDocumentSpecification) which should be copied back to the shipper in the shipment result data. + + + + + + + + Country specific details of an International shipment. + + + + + + Specifies which filing option is being exercised by the customer. + Required for non-document shipments originating in Canada destined for any country other than Canada, the United States, Puerto Rico or the U.S. Virgin Islands. + + + + + + General field for exporting-country-specific export data (e.g. B13A for CA, FTSR Exemption or AES Citation for US). + + + + + This field is applicable only to Canada export non-document shipments of any value to any destination. No special characters allowed. + + 10 + + + + + + Department of Commerce/Department of State information about this shipment. + + + + + + + Details specific to an Express freight shipment. + + + + + Indicates whether or nor a packing list is enclosed. + + + + + + Total shipment pieces. + e.g. 3 boxes and 3 pallets of 100 pieces each = Shippers Load and Count of 303. + Applicable to International Priority Freight and International Economy Freight. + Values must be in the range of 1 - 99999 + + + + + + Required for International Freight shipping. Values must be 8- 12 characters in length. + + 12 + + + + + + + + Identifies a kind of FedEx facility. + + + + + + + + + + + + + + + + Data required to produce the Freight handling-unit-level address labels. Note that the number of UNIQUE labels (the N as in 1 of N, 2 of N, etc.) is determined by total handling units. + + + + + + Indicates the number of copies to be produced for each unique label. + + + + + If omitted, no doc tab will be produced (i.e. default = former NONE type). + + + + + + + Individual charge which contributes to the total base charge for the shipment. + + + + + Freight class for this line item. + + + + + Effective freight class used for rating this line item. + + + + + NMFC Code for commodity. + + + + + Customer-provided description for this commodity or class line. + + + + + Weight for this commodity or class line. + + + + + Rate or factor applied to this line item. + + + + + Identifies the manner in which the chargeRate for this line item was applied. + + + + + The net or extended charge for this line item. + + + + + + + + + + + + + + These values represent the industry-standard freight classes used for FedEx Freight and FedEx National Freight shipment description. (Note: The alphabetic prefixes are required to distinguish these values from decimal numbers on some client platforms.) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Identifies responsibilities with respect to loss, damage, etc. + + + + + + + + + Rate data specific to FedEx Freight or FedEx National Freight services. + + + + + A unique identifier for a specific rate quotation. + + + + + Freight charges which accumulate to the total base charge for the shipment. + + + + + Human-readable descriptions of additional information on this shipment rating. + + + + + + + Additional non-monetary data returned with Freight rates. + + + + + Unique identifier for notation. + + + + + Human-readable explanation of notation. + + + + + + + Data applicable to shipments using FEDEX_FREIGHT and FEDEX_NATIONAL_FREIGHT services. + + + + + Account number used with FEDEX_FREIGHT service. + + + + + Used for validating FedEx Freight account number and (optionally) identifying third party payment on the bill of lading. + + + + + Identification values to be printed during creation of a Freight bill of lading. + + + + + Indicates the role of the party submitting the transaction. + + + + + Designates which of the requester's tariffs will be used for rating. + + + + + Designates the terms of the "collect" payment for a Freight Shipment. + + + + + Identifies the declared value for the shipment + + + + + Identifies the declared value units corresponding to the above defined declared value + + + + + + Identifiers for promotional discounts offered to customers. + + + + + Total number of individual handling units in the entire shipment (for unit pricing). + + + + + Estimated discount rate provided by client for unsecured rate quote. + + + + + Total weight of pallets used in shipment. + + + + + Overall shipment dimensions. + + + + + Description for the shipment. + + + + + Specifies which party will pay surcharges for any special services which support split billing. + + + + + Must be populated if any line items contain hazardous materials. + + + + + Details of the commodities in the shipment. + + + + + + + Description of an individual commodity or class of content in a shipment. + + + + + Freight class for this line item. + + + + + FEDEX INTERNAL USE ONLY: for FedEx system that estimate freight class from customer-provided dimensions and weight. + + + + + Number of individual handling units to which this line applies. (NOTE: Total of line-item-level handling units may not balance to shipment-level total handling units.) + + + + + Specification of handling-unit packaging for this commodity or class line. + + + + + Number of pieces for this commodity or class line. + + + + + NMFC Code for commodity. + + + + + Indicates the kind of hazardous material content in this line item. + + + + + For printed reference per line item. + + + + + For printed reference per line item. + + + + + Customer-provided description for this commodity or class line. + + + + + Weight for this commodity or class line. + + + + + FED EX INTERNAL USE ONLY - Individual line item dimensions. + + + + + Volume (cubic measure) for this commodity or class line. + + + + + + + Indicates the role of the party submitting the transaction. + + + + + + + + + + Specifies which party will be responsible for payment of any surcharges for Freight special services for which split billing is allowed. + + + + + Identifies the special service. + + + + + Indicates who will pay for the special service. + + + + + + + Data required to produce a General Agency Agreement document. Remaining content (business data) to be defined once requirements have been completed. + + + + + + + + Documents the kind and quantity of an individual hazardous commodity in a package. + + + + + Identifies and describes an individual hazardous commodity. + + + + + Specifies the amount of the commodity in alternate units. + + + + + Customer-provided specifications for handling individual commodities. + + + + + + + Identifies and describes an individual hazardous commodity. For 201001 load, this is based on data from the FedEx Ground Hazardous Materials Shipping Guide. + + + + + Regulatory identifier for a commodity (e.g. "UN ID" value). + + + + + + + + + + + + + Specifies how the commodity is to be labeled. + + + + + + + + + + Customer-provided specifications for handling individual commodities. + + + + + Specifies how the customer wishes the label text to be handled for this commodity in this package. + + + + + Text used in labeling the commodity under control of the labelTextOption field. + + + + + + + Indicates which kind of hazardous content (as defined by DOT) is being reported. + + + + + + + + + + + + Identifies number and type of packaging units for hazardous commodities. + + + + + Number of units of the type below. + + + + + Units in which the hazardous commodity is packaged. + + + + + + + Identifies DOT packing group for a hazardous commodity. + + + + + + + + + + Identifies amount and units for quantity of hazardous commodities. + + + + + Number of units of the type below. + + + + + Units by which the hazardous commodity is measured. + + + + + + + Descriptive data required for a FedEx shipment that is to be held at the destination FedEx location for pickup by the recipient. + + + + + Contact phone number for recipient of shipment. + + + + + Contact and address of FedEx facility at which shipment is to be held. + + + + + Type of facility at which package/shipment is to be held. + + + + + + + The descriptive data required by FedEx for home delivery services. + + + + + The type of Home Delivery Premium service being requested. + + + + + Required for Date Certain Home Delivery. + + + + + Required for Date Certain and Appointment Home Delivery. + + 15 + + + + + + + + The type of Home Delivery Premium service being requested. + + + + + + + + + + + + + + + + + + + The type of International shipment. + + + + + + + + + + Specifies the type of label to be returned. + + + + + + + + + + + Names for data elements / areas which may be suppressed from printing on labels. + + + + + + + + + + + + This indicates if the top or bottom of the label comes out of the printer first. + + + + + + + + + Relative to normal orientation for the printer. + + + + + + + + + + + Description of shipping label to be returned in the reply + + + + + Specifies how to create, organize, and return the document. + + + + + Specify type of label to be returned + + + + + Specifies the image format used for a shipping document. + + + + + For thermal printer lables this indicates the size of the label and the location of the doc tab if present. + + + + + This indicates if the top or bottom of the label comes out of the printer first. + + + + + If present, this contact and address information will replace the return address information on the label. + + + + + Allows customer-specified control of label content. + + + + + + + For thermal printer labels this indicates the size of the label and the location of the doc tab if present. + + + + + + + + + + + + + + + + + + + + + + + Identifies the Liability Coverage Amount. For Jan 2010 this value represents coverage amount per pound + + + + + + + + + + + + + Represents a one-dimensional measurement in small units (e.g. suitable for measuring a package or document), contrasted with Distance, which represents a large one-dimensional measurement (e.g. distance between cities). + + + + + The numerical quantity of this measurement. + + + + + The units for this measurement. + + + + + + + CM = centimeters, IN = inches + + + + + + + + + Identifies the representation of human-readable text. + + + + + Two-letter code for language (e.g. EN, FR, etc.) + + + + + Two-letter code for the region (e.g. us, ca, etc..). + + + + + + + + + + + + + Identifies which type minimum charge was applied. + + + + + + + + + + + + The descriptive data for the medium of exchange for FedEx services. + + + + + Identifies the currency of the monetary amount. + + 3 + + + + + + Identifies the monetary amount. + + + + + + + Data required to produce a Certificate of Origin document. Remaining content (business data) to be defined once requirements have been completed. + + + + + + + Indicates which Party (if any) from the shipment is to be used as the source of importer data on the NAFTA COO form. + + + + + Contact information for "Authorized Signature" area of form. + + + + + + + + + + This element is currently not supported and is for the future use. + + + + + Defined by NAFTA regulations. + + + + + Defined by NAFTA regulations. + + + + + Identification of which producer is associated with this commodity (if multiple producers are used in a single shipment). + + + + + + Date range over which RVC net cost was calculated. + + + + + + + + + + + + + + + Net cost method used. + + + + + + + + + See instructions for NAFTA Certificate of Origin for code definitions. + + + + + + + + + + + + + This element is currently not supported and is for the future use. + + + + + + + + + See instructions for NAFTA Certificate of Origin for code definitions. + + + + + + + + + + + This element is currently not supported and is for the future use. + + + + + + + + + + + + The descriptive data regarding the result of the submitted transaction. + + + + + The severity of this notification. This can indicate success or failure or some other information about the request. The values that can be returned are SUCCESS - Your transaction succeeded with no other applicable information. NOTE - Additional information that may be of interest to you about your transaction. WARNING - Additional information that you need to know about your transaction that you may need to take action on. ERROR - Information about an error that occurred while processing your transaction. FAILURE - FedEx was unable to process your transaction at this time due to a system failure. Please try again later + + + + + Indicates the source of this notification. Combined with the Code it uniquely identifies this notification + + + + + A code that represents this notification. Combined with the Source it uniquely identifies this notification. + + + + + Human-readable text that explains this notification. + + + + + The translated message. The language and locale specified in the ClientDetail. Localization are used to determine the representation. Currently only supported in a TrackReply. + + + + + A collection of name/value pairs that provide specific data to help the client determine the nature of an error (or warning, etc.) witout having to parse the message string. + + + + + + + + + Identifies the type of data contained in Value (e.g. SERVICE_TYPE, PACKAGE_SEQUENCE, etc..). + + + + + The value of the parameter (e.g. PRIORITY_OVERNIGHT, 2, etc..). + + + + + + + Identifies the set of severity values for a Notification. + + + + + + + + + + + + The instructions indicating how to print the OP-900 form for hazardous materials packages. + + + + + Specifies characteristics of a shipping document to be produced. + + + + + Identifies which reference type (from the package's customer references) is to be used as the source for the reference on this OP-900. + + + + + Specifies the usage and identification of customer supplied images to be used on this document. + + + + + Data field to be used when a name is to be printed in the document instead of (or in addition to) a signature image. + + + + + + + The oversize class types. + + + + + + + + + + Each instance of this data type represents the set of barcodes (of all types) which are associated with a specific package. + + + + + Binary-style barcodes for this package. + + + + + String-style barcodes for this package. + + + + + + + Data for a package's rates, as calculated per a specific rate type. + + + + + Type used for this specific set of rate data. + + + + + Indicates which weight was used. + + + + + INTERNAL FEDEX USE ONLY. + + + + + The weight that was used to calculate the rate. + + + + + The dimensional weight of this package (if greater than actual). + + + + + The oversize weight of this package (if the package is oversize). + + + + + The transportation charge only (prior to any discounts applied) for this package. + + + + + The sum of all discounts on this package. + + + + + This package's baseCharge - totalFreightDiscounts. + + + + + The sum of all surcharges on this package. + + + + + This package's netFreight + totalSurcharges (not including totalTaxes). + + + + + The sum of all taxes on this package. + + + + + This package's netFreight + totalSurcharges + totalTaxes. + + + + + The total sum of all rebates applied to this package. + + + + + All rate discounts that apply to this package. + + + + + All rebates that apply to this package. + + + + + All surcharges that apply to this package (either because of characteristics of the package itself, or because it is carrying per-shipment surcharges for the shipment of which it is a part). + + + + + All taxes applicable (or distributed to) this package. + + + + + The variable handling charges calculated based on the type variable handling charges requested. + + + + + + + This class groups together for a single package all package-level rate data (across all rate types) as part of the response to a shipping request, which groups shipment-level data together and groups package-level data by package. + + + + + This rate type identifies which entry in the following array is considered as presenting the "actual" rates for the package. + + + + + The "list" net charge minus "actual" net charge. + + + + + Each element of this field provides package-level rate data for a specific rate type. + + + + + + + Identifies the collection of special service offered by FedEx. BROKER_SELECT_OPTION should be used for Ground shipments only. + + + + + + + + + + + + + + These special services are available at the package level for some or all service types. If the shipper is requesting a special service which requires additional data, the package special service type must be present in the specialServiceTypes collection, and the supporting detail must be provided in the appropriate sub-object below. + + + + + The types of all special services requested for the enclosing shipment or package. + + + + + For use with FedEx Ground services only; COD must be present in shipment's special services. + + + + + Descriptive data required for a FedEx shipment containing dangerous materials. This element is required when SpecialServiceType.DANGEROUS_GOODS or HAZARDOUS_MATERIAL is present in the SpecialServiceTypes collection. + + + + + Descriptive data required for a FedEx shipment containing dry ice. This element is required when SpecialServiceType.DRY_ICE is present in the SpecialServiceTypes collection. + + + + + The descriptive data required for FedEx signature services. This element is required when SpecialServiceType.SIGNATURE_OPTION is present in the SpecialServiceTypes collection. + + + + + The descriptive data required for FedEx Priority Alert service. This element is required when SpecialServiceType.PRIORITY_ALERT is present in the SpecialServiceTypes collection. + + + + + + + Identifies the collection of available FedEx or customer packaging options. + + + + + + + + + + + + + + The descriptive data for a person or company entitiy doing business with FedEx. + + + + + Identifies the FedEx account number assigned to the customer. + + 12 + + + + + + + Descriptive data identifying the point-of-contact person. + + + + + The descriptive data for a physical location. + + + + + + + The descriptive data for the monetary compensation given to FedEx for services rendered to the customer. + + + + + Identifies the method of payment for a service. See PaymentType for list of valid enumerated values. + + + + + Descriptive data identifying the party responsible for payment for a service. + + + + + + + Identifies the method of payment for a service. + + + + + + + + + + + The descriptive data identifying the party responsible for payment for a service. + + + + + Identifies the FedEx account number assigned to the payor. + + 12 + + + + + + Identifies the country of the payor. + + 2 + + + + + + + + This information describes how and when a pending shipment may be accessed for completion. + + + + + Only for pending shipment type of "EMAIL" + + + + + Only for pending shipment type of "EMAIL" + + + + + Only for pending shipment type of "EMAIL" + + + + + This element is currently not supported and is for the future use. + + + + + + + This information describes the kind of pending shipment being requested. + + + + + Identifies the type of FedEx pending shipment + + + + + Date after which the pending shipment will no longer be available for completion. + + + + + Only used with type of EMAIL. + + + + + + + Identifies the type of service for a pending shipment. + + + + + + + + This enumeration rationalizes the former FedEx Express international "admissibility package" types (based on ANSI X.12) and the FedEx Freight packaging types. The values represented are those common to both carriers. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This class describes the pickup characteristics of a shipment (e.g. for use in a tag request). + + + + + + + + Identifies the type of Pickup request + + + + + Identifies the type of source for Pickup request + + + + + + + Identifies the type of source for pickup request service. + + + + + + + + + Identifies the type of pickup request service. + + + + + + + + + Identifies the type of pricing used for this shipment. + + + + + + + + + + + + + + + + + + + + Represents a reference identifier printed on Freight bills of lading + + + + + + + + + Identifies a particular reference identifier printed on a Freight bill of lading. + + + + + + + + + + + + + + + + This indicates the highest level of severity of all the notifications returned in this reply + + + + + The descriptive data regarding the results of the submitted transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + The reply payload. All of the returned information about this shipment/package. + + + + + Empty unless error label behavior is PACKAGE_ERROR_LABELS and one or more errors occured during transaction processing. + + + + + + + Descriptive data sent to FedEx by a customer in order to ship a package. + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Descriptive data about the shipment being sent by the requestor. + + + + + + + + + + + + + + + + Descriptive data sent to FedEx by a customer in order to ship a package. + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Descriptive data about the shipment being sent by the requestor. + + + + + + + Test for the Commercial Invoice. Note that Sold is not a valid Purpose for a Proforma Invoice. + + + + + + + + + + + + + Indicates the reason that a dim divisor value was chose. + + + + + + + + + + + + Identifies a discount applied to the shipment. + + + + + Identifies the type of discount applied to the shipment. + + + + + + The amount of the discount applied to the shipment. + + + + + The percentage of the discount applied to the shipment. + + + + + + + The type of the discount. + + + + + + + + + + + + + Identifies the type(s) of rates to be returned in the reply. + + + + + + + + + + The weight method used to calculate the rate. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Specifies how the recipient is identified for customs purposes; the requirements on this information vary with destination country. + + + + + Specifies the kind of identification being used. + + + + + Contains the actual ID value, of the type specified above. + + + + + + + Type of Brazilian taxpayer identifier provided in Recipient/TaxPayerIdentification/Number. For shipments bound for Brazil this overrides the value in Recipient/TaxPayerIdentification/TinType + + + + + + + + + + FOOD_OR_PERISHABLE is required by FDA/BTA; must be true for food/perishable items coming to US or PR from non-US/non-PR origin + + + + + + + + + + + + + + + + + This class rationalizes RequestedPackage and RequestedPackageSummary from previous interfaces. The way in which it is uses within a RequestedShipment depends on the RequestedPackageDetailType value specified for that shipment. + + + + + Used only with INDIVIDUAL_PACKAGE, as a unique identifier of each requested package. + + + + + Used only with PACKAGE_GROUPS, as a unique identifier of each group of identical packages. + + + + + Used only with PACKAGE_GROUPS, as a count of packages within a group of identical packages. + + + + + + Only used for INDIVIDUAL_PACKAGES and PACKAGE_GROUPS. Ignored for PACKAGE_SUMMARY, in which case totalInsuredValue and packageCount on the shipment will be used to determine this value. + + + + + Only used for INDIVIDUAL_PACKAGES and PACKAGE_GROUPS. Ignored for PACKAGE_SUMMARY, in which case totalweight and packageCount on the shipment will be used to determine this value. + + + + + + Provides additional detail on how the customer has physically packaged this item. As of June 2009, required for packages moving under international and SmartPost services. + + + + + Human-readable text describing the package. + + + + + + + Only used for INDIVIDUAL_PACKAGES and PACKAGE_GROUPS. + + + + + + + The descriptive data for the shipment being tendered to FedEx. + + + + + Identifies the date and time the package is tendered to FedEx. Both the date and time portions of the string are expected to be used. The date should not be a past date or a date more than 10 days in the future. The time is the local time of the shipment based on the shipper's time zone. The date component must be in the format: YYYY-MM-DD (e.g. 2006-06-26). The time component must be in the format: HH:MM:SS using a 24 hour clock (e.g. 11:00 a.m. is 11:00:00, whereas 5:00 p.m. is 17:00:00). The date and time parts are separated by the letter T (e.g. 2006-06-26T17:00:00). There is also a UTC offset component indicating the number of hours/mainutes from UTC (e.g 2006-06-26T17:00:00-0400 is defined form June 26, 2006 5:00 pm Eastern Time). + + + + + Identifies the method by which the package is to be tendered to FedEx. This element does not dispatch a courier for package pickup. See DropoffType for list of valid enumerated values. + + + + + Identifies the FedEx service to use in shipping the package. See ServiceType for list of valid enumerated values. + + + + + Identifies the packaging used by the requestor for the package. See PackagingType for list of valid enumerated values. + + + + + Identifies the total weight of the shipment being conveyed to FedEx.This is only applicable to International shipments and should only be used on the first package of a mutiple piece shipment.This value contains 1 explicit decimal position + + + + + Total insured amount. + + + + + + Descriptive data identifying the party responsible for shipping the package. Shipper and Origin should have the same address. + + + + + Descriptive data identifying the party receiving the package. + + + + + A unique identifier for a recipient location + + 10 + + + + + + Physical starting address for the shipment, if different from shipper's address. + + + + + Descriptive data indicating the method and means of payment to FedEx for providing shipping services. + + + + + Descriptive data regarding special services requested by the shipper for this shipment. If the shipper is requesting a special service which requires additional data (e.g. COD), the special service type must be present in the specialServiceTypes collection, and the supporting detail must be provided in the appropriate sub-object. For example, to request COD, "COD" must be included in the SpecialServiceTypes collection and the CodDetail object must contain the required data. + + + + + Details specific to an Express freight shipment. + + + + + Data applicable to shipments using FEDEX_FREIGHT and FEDEX_NATIONAL_FREIGHT services. + + + + + Used with Ground Home Delivery and Freight. + + + + + Details about how to calculate variable handling charges at the shipment level. + + + + + Customs clearance data, used for both international and intra-country shipping. + + + + + For use in "process tag" transaction. + + + + + + If true, only the shipper/payor will have visibility of this shipment. + + + + + Specifies the client-requested response in the event of errors within shipment. + + + + + Details about the image format and printer type the label is to returned in. + + + + + Contains data used to create additional (non-label) shipping documents. + + + + + Specifies whether and what kind of rates the customer wishes to have quoted on this shipment. The reply will also be constrained by other data on the shipment and customer. + + + + + Specifies the type of rate the customer wishes to have used as the actual rate type. + + + + + Specifies whether the customer wishes to have Estimated Duties and Taxes provided with the rate quotation on this shipment. Only applies with shipments moving under international services. + + + + + Only used with multiple-transaction shipments. + + + + + Only used with multi-piece COD shipments sent in multiple transactions. Required on last transaction only. + + + + + The total number of packages in the entire shipment (even when the shipment spans multiple transactions.) + + + + + Specifies whether packages are described individually, in groups, or summarized in a single description for total-piece-total-weight. This field controls which fields of the RequestedPackageLineItem will be used, and how many occurrences are expected. + + + + + One or more package-attribute descriptions, each of which describes an individual package, a group of identical packages, or (for the total-piece-total-weight case) common characteristics all packages in the shipment. + + + + + + + + + + + + + + + + + + + + + + + These values are used to control the availability of certain special services at the time when a customer uses the e-mail label link to create a return shipment. + + + + + + + + + Return Email Details + + + + + Phone number of the merchant + + + + + Identifies the allowed (merchant-authorized) special services which may be selected when the subsequent shipment is created. Only services represented in EMailLabelAllowedSpecialServiceType will be controlled by this list. + + + + + + + Information relating to a return shipment. + + + + + The type of return shipment that is being requested. + + + + + Return Merchant Authorization + + + + + Describes specific information about the email label for return shipment. + + + + + + + The type of return shipment that is being requested. + + + + + + + + + + The "PAYOR..." rates are expressed in the currency identified in the payor's rate table(s). The "RATED..." rates are expressed in the currency of the origin country. Former "...COUNTER..." values have become "...RETAIL..." values, except for PAYOR_COUNTER and RATED_COUNTER, which have been removed. + + + + + + + + + + + + + + + + Shipping document type. + + + + + + + + + + + + + + + + + + + + + + + + + + + + Return Merchant Authorization + + + + + The RMA number. + + 20 + + + + + + The reason for the return. + + 60 + + + + + + + + The tracking number information and the data to form the Astra barcode for the label. + + + + + The tracking number information for the shipment. + + + + + + The textual description of the special service applied to the package. + + + + + + + + Information about the routing, origin, destination and delivery of a shipment. + + + + + The routing information detail for this shipment. + + + + + The tracking number information and the data to form the Astra barcode for the label. + + + + + + + Identifies the collection of available FedEx service options. + + + + + + + + + + + + + + + + + + + + + + + + + Shipment-level totals of dry ice data across all packages. + + + + + Total number of packages in the shipment that contain dry ice. + + + + + Total shipment dry ice weight for all packages. + + + + + + + Data for a shipment's total/summary rates, as calculated per a specific rate type. The "total..." fields may differ from the sum of corresponding package data for Multiweight or Express MPS. + + + + + Type used for this specific set of rate data. + + + + + Indicates the rate scale used. + + + + + Indicates the rate zone used (based on origin and destination). + + + + + Identifies the type of pricing used for this shipment. + + + + + Indicates which weight was used. + + + + + INTERNAL FEDEX USE ONLY. + + + + + Specifies the currency exchange performed on financial amounts for this rate. + + + + + Indicates which special rating cases applied to this shipment. + + + + + The value used to calculate the weight based on the dimensions. + + + + + Identifies the type of dim divisor that was applied. + + + + + Specifies a fuel surcharge percentage. + + + + + The weight used to calculate these rates. + + + + + Sum of dimensional weights for all packages. + + + + + The total freight charge that was calculated for this package before surcharges, discounts and taxes. + + + + + The total discounts used in the rate calculation. + + + + + The freight charge minus discounts. + + + + + The total amount of all surcharges applied to this shipment. + + + + + This shipment's totalNetFreight + totalSurcharges (not including totalTaxes). + + + + + Total of the transportation-based taxes. + + + + + The net charge after applying all discounts and surcharges. + + + + + The total sum of all rebates applied to this shipment. + + + + + Total of all values under this shipment's dutiesAndTaxes; only provided if estimated duties and taxes were calculated for this shipment. + + + + + This shipment's totalNetCharge + totalDutiesAndTaxes; only provided if estimated duties and taxes were calculated for this shipment AND duties, taxes and transportation charges are all paid by the same sender's account. + + + + + Rate data specific to FedEx Freight and FedEx National Freight services. + + + + + All rate discounts that apply to this shipment. + + + + + All rebates that apply to this shipment. + + + + + All surcharges that apply to this shipment. + + + + + All transportation-based taxes applicable to this shipment. + + + + + All commodity-based duties and taxes applicable to this shipment. + + + + + The "order level" variable handling charges. + + + + + The total of all variable handling charges at both shipment (order) and package level. + + + + + + + This class groups together all shipment-level rate data (across all rate types) as part of the response to a shipping request, which groups shipment-level data together and groups package-level data by package. + + + + + This rate type identifies which entry in the following array is considered as presenting the "actual" rates for the shipment. + + + + + The "list" total net charge minus "actual" total net charge. + + + + + Each element of this field provides shipment-level rate totals for a specific rate type. + + + + + + + + + This indicates the highest level of severity of all the notifications returned in this reply + + + + + The descriptive data regarding the results of the submitted transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + + + Information about the routing, origin, destination and delivery of a shipment. + + + + + The prefix portion of the URSA (Universal Routing and Sort Aid) code. + + 2 + + + + + + The suffix portion of the URSA code. + + 5 + + + + + + The identifier of the origin location of the shipment. Express only. + + 5 + + + + + + + The identifier of the destination location of the shipment. Express only. + + 5 + + + + + + + This is the state of the destination location ID, and is not necessarily the same as the postal state. + + + + + Expected/estimated date of delivery. + + + + + Expected/estimated day of week of delivery. + + + + + Committed date of delivery. + + + + + Committed day of week of delivery. + + + + + Standard transit time per origin, destination, and service. + + + + + Maximum expected transit time + + + + + Text describing planned delivery. + + + + + Currently not supported. + + TBD + + + + + + The postal code of the destination of the shipment. + + 16 + + + + + + The state or province code of the destination of the shipment. + + 14 + + + + + + The country code of the destination of the shipment. + + 2 + + + + + + The identifier for the airport of the destination of the shipment. + + 4 + + + + + + + + Identifies the collection of special service offered by FedEx. BROKER_SELECT_OPTION should be used for Express shipments only. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + These special services are available at the shipment level for some or all service types. If the shipper is requesting a special service which requires additional data (such as the COD amount), the shipment special service type must be present in the specialServiceTypes collection, and the supporting detail must be provided in the appropriate sub-object below. + + + + + The types of all special services requested for the enclosing shipment (or other shipment-level transaction). + + + + + Descriptive data required for a FedEx COD (Collect-On-Delivery) shipment. This element is required when SpecialServiceType.COD is present in the SpecialServiceTypes collection. + + + + + Descriptive data required for a FedEx shipment that is to be held at the destination FedEx location for pickup by the recipient. This element is required when SpecialServiceType.HOLD_AT_LOCATION is present in the SpecialServiceTypes collection. + + + + + Descriptive data required for FedEx to provide email notification to the customer regarding the shipment. This element is required when SpecialServiceType.EMAIL_NOTIFICATION is present in the SpecialServiceTypes collection. + + + + + The descriptive data required for FedEx Printed Return Label. This element is required when SpecialServiceType.PRINTED_RETURN_LABEL is present in the SpecialServiceTypes collection + + + + + This field should be populated for pending shipments (e.g. e-mail label) It is required by a PENDING_SHIPMENT special service type. + + + + + Number of packages in this shipment which contain dry ice and the total weight of the dry ice for this shipment. + + + + + The descriptive data required for FedEx Home Delivery options. This element is required when SpecialServiceType.HOME_DELIVERY_PREMIUM is present in the SpecialServiceTypes collection + + + + + Electronic Trade document references. + + + + + Specification for date or range of dates on which delivery is to be attempted. + + + + + + + All package-level shipping documents (other than labels and barcodes). + + + + + Shipping Document Type + + + + + Specifies how this document image/file is organized. + + + + + + The name under which a STORED or DEFERRED document is written. + + + + + Specifies the image resolution in DPI (dots per inch). + + + + + Can be zero for documents whose disposition implies that no content is included. + + + + + One or more document parts which make up a single logical document, such as multiple pages of a single form. + + + + + + + Each occurrence of this class specifies a particular way in which a kind of shipping document is to be produced and provided. + + + + + Values in this field specify how to create and return the document. + + + + + Specifies how to organize all documents of this type. + + + + + Specifies how to e-mail document images. + + + + + Specifies how a queued document is to be printed. + + + + + + + Specifies how to return a shipping document to the caller. + + + + + + + + + + + + + + Specifies how to e-mail shipping documents. + + + + + Provides the roles and email addresses for e-mail recipients. + + + + + Identifies the convention by which documents are to be grouped as e-mail attachments. + + + + + + + + + + + + + Specifies an individual recipient of e-mailed shipping document(s). + + + + + Identifies the relationship of this recipient in the shipment. + + + + + Address to which the document is to be sent. + + + + + + + Specifies characteristics of a shipping document to be produced. + + + + + Specifies how to create, organize, and return the document. + + + + + Specifies how far down the page to move the beginning of the image; allows for printing on letterhead and other pre-printed stock. + + + + + + + For those shipping document types which have both a "form" and "instructions" component (e.g. NAFTA Certificate of Origin and General Agency Agreement), this field indicates whether to provide the instructions. + + + + + Governs the language to be used for this individual document, independently from other content returned for the same shipment. + + + + + Identifies the individual document specified by the client. + + + + + + + Specifies how to organize all shipping documents of the same type. + + + + + + + + + Specifies the image format used for a shipping document. + + + + + + + + + + + + + + + A single part of a shipping document, such as one page of a multiple-page document whose format requires a separate image per page. + + + + + The one-origin position of this part within a document. + + + + + Graphic or printer commands for this image within a document. + + + + + + + Specifies printing options for a shipping document. + + + + + Provides environment-specific printer identification. + + + + + + + Contains all data required for additional (non-label) shipping documents to be produced in conjunction with a specific shipment. + + + + + Indicates the types of shipping documents requested by the shipper. + + + + + + + Specifies the production of each package-level custom document (the same specification is used for all packages). + + + + + Specifies the production of a shipment-level custom document. + + + + + This element is currently not supported and is for the future use. (Details pertaining to the GAA.) + + + + + + Specifies the production of the OP-900 document for hazardous materials packages. + + + + + Specifies the production of the OP-900 document for hazardous materials. + + + + + + + Specifies the type of paper (stock) on which a document will be printed. + + + + + + + + + + + + + + + + + + The descriptive data required for FedEx delivery signature services. + + + + + Identifies the delivery signature services option selected by the customer for this shipment. See OptionType for the list of valid values. + + + + + Identifies the delivery signature release authorization number. + + 10 + + + + + + + + Identifies the delivery signature services options offered by FedEx. + + + + + + + + + + + + These values are mutually exclusive; at most one of them can be attached to a SmartPost shipment. + + + + + + + + + + + + + + + + + + + + + Data required for shipments handled under the SMART_POST and GROUND_SMART_POST service types. + + + + + + + + + The CustomerManifestId is used to group Smart Post packages onto a manifest for each trailer that is being prepared. If you do not have multiple trailers this field can be omitted. If you have multiple trailers, you + must assign the same Manifest Id to each SmartPost package as determined by its trailer. In other words, all packages on a trailer must have the same Customer Manifest Id. The manifest Id must be unique to your account number for a minimum of 6 months + and cannot exceed 8 characters in length. We recommend you use the day of year + the trailer id (this could simply be a sequential number for that trailer). So if you had 3 trailers that you started loading on Feb 10 + the 3 manifest ids would be 041001, 041002, 041003 (in this case we used leading zeros on the trailer numbers). + + + + + + + + Special circumstance rating used for this shipment. + + + + + + + + + Each instance of this data type represents a barcode whose content must be represented as ASCII text (i.e. not binary data). + + + + + The kind of barcode data in this instance. + + + + + The data content of this instance. + + + + + + + + + + + + + + + + + Identifies each surcharge applied to the shipment. + + + + + The type of surcharge applied to the shipment. + + + + + + + The amount of the surcharge applied to the shipment. + + + + + + + + + + + + + The type of the surcharge. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Identifies each tax applied to the shipment. + + + + + The type of tax applied to the shipment. + + + + + + The amount of the tax applied to the shipment. + + + + + + + The type of the tax. + + + + + + + + + + + + + + The descriptive data for taxpayer identification information. + + + + + Identifies the category of the taxpayer identification number. See TinType for the list of values. + + + + + Identifies the taxpayer identification number. + + 15 + + + + + + Identifies the usage of Tax Identification Number in Shipment processing + + + + + + + + Required for dutiable international express or ground shipment. This field is not applicable to an international PIB (document) or a non-document which does not require a commercial invoice express shipment. + CFR_OR_CPT (Cost and Freight/Carriage Paid TO) + CIF_OR_CIP (Cost Insurance and Freight/Carraige Insurance Paid) + DDP (Delivered Duty Paid) + DDU (Delivered Duty Unpaid) + EXW (Ex Works) + FOB_OR_FCA (Free On Board/Free Carrier) + + + + + + + + + + + + + + Identifies the category of the taxpayer identification number. + + + + + + + + + + + + + + + For use with SmartPost tracking IDs only + + + + + + + + TrackingIdType + + + + + + + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Free form text to be echoed back in the reply. Used to match requests and replies. + + + + + Governs data payload language/translations (contrasted with ClientDetail.localization, which governs Notification.localizedMessage language selection). + + + + + + + Identifies the set of valid shipment transit time values. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Descriptive data sent to FedEx by a customer in order to validate a shipment. + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Descriptive data about the shipment being sent by the requestor. + + + + + + + Documents the kind and quantity of an individual hazardous commodity in a package. + + + + + Identifies and describes an individual hazardous commodity. + + + + + Specifies the amount of the commodity in alternate units. + + + + + Customer-provided specifications for handling individual commodities. + + + + + + + Identifies and describes an individual hazardous commodity. For 201001 load, this is based on data from the FedEx Ground Hazardous Materials Shipping Guide. + + + + + Regulatory identifier for a commodity (e.g. "UN ID" value). + + + + + + + Fully-expanded descriptive text for a hazardous commodity. + + + + + + + + Coded indications for special requirements or constraints. + + + + + + + + Details about how to calculate variable handling charges at the shipment level. + + + + + The type of handling charge to be calculated and returned in the reply. + + + + + + Used with Variable handling charge type of FIXED_VALUE. + Contains the amount to be added to the freight charge. + Contains 2 explicit decimal positions with a total max length of 10 including the decimal. + + + + + + Actual percentage (10 means 10%, which is a mutiplier of 0.1) + + + + + + + The type of handling charge to be calculated and returned in the reply. + + + + + + + + + + + The variable handling charges calculated based on the type variable handling charges requested. + + + + + The variable handling charge amount calculated based on the requested variable handling charge detail. + + + + + The calculated varibale handling charge plus the net charge. + + + + + + + Three-dimensional volume/cubic measurement. + + + + + + + + + Units of three-dimensional volume/cubic measure. + + + + + + + + + The descriptive data for the heaviness of an object. + + + + + Identifies the unit of measure associated with a weight value. + + + + + Identifies the weight value of a package/shipment. + + + + + + + Identifies the unit of measure associated with a weight value. See the list of enumerated types for valid values. + + + + + + + + + Used in authentication of the sender's identity. + + + + + Credential used to authenticate a specific software application. This value is provided by FedEx after registration. + + + + + + + Two part authentication string used for the sender's identity + + + + + Identifying part of authentication credential. This value is provided by FedEx after registration + + + + + Secret part of authentication key. This value is provided by FedEx after registration. + + + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Identifies a system or sub-system which performs an operation. + + + + + Identifies the service business level. + + + + + Identifies the service interface level. + + + + + Identifies the service code level. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git app/code/core/Mage/Usa/etc/wsdl/FedEx/ShipService_v9.wsdl app/code/core/Mage/Usa/etc/wsdl/FedEx/ShipService_v9.wsdl new file mode 100644 index 0000000..b32e571 --- /dev/null +++ app/code/core/Mage/Usa/etc/wsdl/FedEx/ShipService_v9.wsdl @@ -0,0 +1,5472 @@ + + + + + + + + + + + + + + + + + + Specifies additional labels to be produced. All required labels for shipments will be produced without the need to request additional labels. These are only available as thermal labels. + + + + + The type of additional labels to return. + + + + + The number of this type label to return + + + + + + + Identifies the type of additional labels. + + + + + + + + + + + + + + + + Descriptive data for a physical location. May be used as an actual physical address (place to which one could go), or as a container of "address parts" which should be handled as a unit (such as a city-state-ZIP combination within the US). + + + + + Combination of number, street name, etc. At least one line is required for a valid physical address; empty lines should not be included. + + + + + Name of city, town, etc. + + + + + Identifying abbreviation for US state, Canada province, etc. Format and presence of this field will vary, depending on country. + + + + + Identification of a region (usually small) for mail/package delivery. Format and presence of this field will vary, depending on country. + + + + + Relevant only to addresses in Puerto Rico. + + + + + The two-letter code used to identify a country. + + + + + Indicates whether this address residential (as opposed to commercial). + + + + + + + + + Position of Astra element + + + + + Content corresponding to the Astra Element + + + + + + + + Specifies which filing option is being exercised by the customer. + Required for non-document shipments originating in Canada destined for any country other than Canada, the United States, Puerto Rico or the U.S. Virgin Islands. + + + + + + + + + + + + Identification of the type of barcode (symbology) used on FedEx documents and labels. + + + + + + + + + + Each instance of this data type represents a barcode whose content must be represented as binary data (i.e. not ASCII text). + + + + + The kind of barcode data in this instance. + + + + + The data content of this instance. + + + + + + + + + + + + + + + + + + + + Descriptive data sent to FedEx by a customer in order to Cancel a Pending shipment. + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + + + + Identification of a FedEx operating company (transportation). + + + + + + + + + + + + + The instructions indicating how to print the Certificate of Origin ( e.g. whether or not to include the instructions, image type, etc ...) + + + + + Specifies characteristics of a shipping document to be produced. + + + + + Specifies the usage and identification of customer supplied images to be used on this document. + + + + + + + Specifies the type of brokerage to be applied to a shipment. + + + + + + + + + + + + Descriptive data for the client submitting a transaction. + + + + + The FedEx account number associated with this transaction. + + + + + This number is assigned by FedEx and identifies the unique device from which the request is originating + + + + + Only used in transactions which require identification of the Fed Ex Office integrator. + + + + + The language to be used for human-readable Notification.localizedMessages in responses to the request containing this ClientDetail object. Different requests from the same client may contain different Localization data. (Contrast with TransactionDetail.localization, which governs data payload language/translation.) + + + + + + + Identifies what freight charges should be added to the COD collect amount. + + + + + + + + + + + + + + + + + + + Identifies the type of funds FedEx should collect upon shipment delivery. + + + + + + + + + + + + Descriptive data required for a FedEx COD (Collect-On-Delivery) shipment. + + + + + + Identifies if freight charges are to be added to the COD amount. This element determines which freight charges should be added to the COD collect amount. See CodAddTransportationChargesType for a list of valid enumerated values. + + + + + Identifies the type of funds FedEx should collect upon package delivery + + + + + For Express this is the descriptive data that is used for the recipient of the FedEx Letter containing the COD payment. For Ground this is the descriptive data for the party to receive the payment that prints the COD receipt. + + + + + Indicates which type of reference information to include on the COD return shipping label. + + + + + + + + + The COD amount (after any accumulations) that must be collected upon delivery of a package shipped using the COD special service. + + + + + + Contains the data which form the Astra and 2DCommon barcodes that print on the COD return label. + + + + + The label image or printer commands to print the label. + + + + + + + Indicates which type of reference information to include on the COD return shipping label. + + + + + + + + + + + + + The COD amount (after any accumulations) that must be collected upon delivery of a package shipped using the COD special service. + + + + + Currently not supported. + + TBD + + + + + + The description of the FedEx service type used for the COD return shipment. Currently not supported. + + 70 + + + + + + The description of the packaging used for the COD return shipment. + + 40 + + + + + + Currently not supported. + + TBD + + + + + + Currently not supported. + + + + + Currently not supported. + + + + + + The CodRoutingDetail element will contain the COD return tracking number and form id. In the case of a COD multiple piece shipment these will need to be inserted in the request for the last piece of the multiple piece shipment. + The service commitment is the only other element of the RoutingDetail that is used for a CodRoutingDetail. + + + + + + Contains the data which form the Astra and 2DCommon barcodes that print on the COD return label. + + + + + The label image or printer commands to print the label. + + + + + + + CommercialInvoice element is required for electronic upload of CI data. It will serve to create/transmit an Electronic Commercial Invoice through the FedEx Systems. Customers are responsible for printing their own Commercial Invoice.If you would likeFedEx to generate a Commercial Invoice and transmit it to Customs. for clearance purposes, you need to specify that in the ShippingDocumentSpecification element. If you would like a copy of the Commercial Invoice that FedEx generated returned to you in reply it needs to be specified in the ETDDetail/RequestedDocumentCopies element. Commercial Invoice support consists of maximum of 99 commodity line items. + + + + + Any comments that need to be communicated about this shipment. + + + + + Any freight charges that are associated with this shipment. + + + + + Any taxes or miscellaneous charges(other than Freight charges or Insurance charges) that are associated with this shipment. + + + + + Any packing costs that are associated with this shipment. + + + + + Any handling costs that are associated with this shipment. + + + + + Free-form text. + + + + + Free-form text. + + + + + Free-form text. + + + + + The reason for the shipment. Note: SOLD is not a valid purpose for a Proforma Invoice. + + + + + Customer assigned Invoice number + + + + + Name of the International Expert that completed the Commercial Invoice different from Sender. + + + + + Required for dutiable international Express or Ground shipment. This field is not applicable to an international PIB(document) or a non-document which does not require a Commercial Invoice + + + + + + + The instructions indicating how to print the Commercial Invoice( e.g. image type) Specifies characteristics of a shipping document to be produced. + + + + + + Specifies the usage and identification of a customer supplied image to be used on this document. + + + + + + + + For international multiple piece shipments, commodity information must be passed in the Master and on each child transaction. + If this shipment cotains more than four commodities line items, the four highest valued should be included in the first 4 occurances for this request. + + + + + + Name of this commodity. + + + + + Total number of pieces of this commodity + + + + + Complete and accurate description of this commodity. + + 450 + + + + + + Country code where commodity contents were produced or manufactured in their final form. + + 2 + + + + + + + Unique alpha/numeric representing commodity item. + At least one occurrence is required for US Export shipments if the Customs Value is greater than $2500 or if a valid US Export license is required. + + + 14 + + + + + + Total weight of this commodity. 1 explicit decimal position. Max length 11 including decimal. + + + + + Number of units of a commodity in total number of pieces for this line item. Max length is 9 + + + + + Unit of measure used to express the quantity of this commodity line item. + + 3 + + + + + + Contains only additional quantitative information other than weight and quantity to calculate duties and taxes. + + + + + Value of each unit in Quantity. Six explicit decimal positions, Max length 18 including decimal. + + + + + + Total customs value for this line item. + It should equal the commodity unit quantity times commodity unit value. + Six explicit decimal positions, max length 18 including decimal. + + + + + + Defines additional characteristic of commodity used to calculate duties and taxes + + + + + Applicable to US export shipping only. + + 12 + + + + + + + Date of expiration. Must be at least 1 day into future. + The date that the Commerce Export License expires. Export License commodities may not be exported from the U.S. on an expired license. + Applicable to US Export shipping only. + Required only if commodity is shipped on commerce export license, and Export License Number is supplied. + + + + + + + An identifying mark or number used on the packaging of a shipment to help customers identify a particular shipment. + + + 15 + + + + + + All data required for this commodity in NAFTA Certificate of Origin. + + + + + + + + + The identifier for all clearance documents associated with this shipment. + + + + + + + + + + Identifies the branded location name, the hold at location phone number and the address of the location. + + + + + Identifies the type of FedEx location. + + + + + + + + + The package sequence number of this package in a multiple piece shipment. + + + + + The Tracking number and form id for this package. + + + + + Used with request containing PACKAGE_GROUPS, to identify which group of identical packages was used to produce a reply item. + + + + + Oversize class for this package. + + + + + All package-level rating data for this package, which may include data for multiple rate types. + + + + + Associated with package, due to interaction with per-package hazardous materials presence/absence. + + + + + The data that is used to from the Astra and 2DCommon barcodes for the label.. + + + + + The textual description of the special service applied to the package. + + + + + + The label image or printer commands to print the label. + + + + + All package-level shipping documents (other than labels and barcodes). For use in loads after January, 2008. + + + + + Information about the COD return shipment. + + + + + Actual signature option applied, to allow for cases in which the original value conflicted with other service features in the shipment. + + + + + Documents the kinds and quantities of all hazardous commodities in the current package, using updated hazardous commodity description data. + + + + + + + + + Indicates whether or not this is a US Domestic shipment. + + + + + Indicates the carrier that will be used to deliver this shipment. + + + + + The master tracking number and form id of this multiple piece shipment. This information is to be provided for each subsequent of a multiple piece shipment. + + + + + Description of the FedEx service used for this shipment. Currently not supported. + + 70 + + + + + + Description of the packaging used for this shipment. Currently not supported. + + 40 + + + + + + Information about the routing, origin, destination and delivery of a shipment. + + + + + Only used with pending shipments. + + + + + Only used in the reply to tag requests. + + + + + Provides reply information specific to SmartPost shipments. + + + + + All shipment-level rating data for this shipment, which may include data for multiple rate types. + + + + + Information about the COD return shipment. + + + + + Returns the default holding location information when HOLD_AT_LOCATION special service is requested and the client does not specify the hold location address. + + + + + Indicates whether or not this shipment is eligible for a money back guarantee. + + + + + Returns any defaults or updates applied to RequestedShipment.exportDetail.exportComplianceStatement. + + + + + + All shipment-level shipping documents (other than labels and barcodes). + + + + + Package level details about this package. + + + + + + + Provides reply information specific to SmartPost shipments. + + + + + Identifies the carrier that will pick up the SmartPost shipment. + + + + + Indicates whether the shipment is deemed to be machineable, based on dimensions, weight, and packaging. + + + + + + + Provides reply information specific to a tag request. + + + + + . + + + + + As of June 2007, returned only for FedEx Express services. + + + + + As of June 2007, returned only for FedEx Express services. + + + + + As of June 2007, returned only for FedEx Express services. + + + + + As of June 2007, returned only for FedEx Express services. + + + + + FEDEX INTERNAL USE ONLY: for use by INET. + + + + + + + Defines additional data to print in the Configurable portion of the label, this allows you to print the same type information on the label that can also be printed on the doc tab. + + + + + 1 of 12 possible zones to position data. + + + + + The identifiying text for the data in this zone. + + + + + A reference to a field in either the request or reply to print in this zone following the header. + + + + + A literal value to print after the header in this zone. + + + + + + + The descriptive data for a point-of-contact person. + + + + + Client provided identifier corresponding to this contact information. + + + + + Identifies the contact person's name. + + + + + Identifies the contact person's title. + + + + + Identifies the company this contact is associated with. + + + + + Identifies the phone number associated with this contact. + + + + + Identifies the phone extension associated with this contact. + + + + + Identifies the pager number associated with this contact. + + + + + Identifies the fax number associated with this contact. + + + + + Identifies the email address associated with this contact. + + + + + + + + + + + + + Content Record. + + + + + Part Number. + + + + + Item Number. + + + + + Received Quantity. + + + + + Description. + + + + + + + Reply to the Close Request transaction. The Close Reply bring back the ASCII data buffer which will be used to print the Close Manifest. The Manifest is essential at the time of pickup. + + + + + Identifies the highest severity encountered when executing the request; in order from high to low: FAILURE, ERROR, WARNING, NOTE, SUCCESS. + + + + + The descriptive data detailing the status of a sumbitted transaction. + + + + + Descriptive data that governs data payload language/translations. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + The reply payload. All of the returned information about this shipment/package. + + + + + + + Create Pending Shipment Request + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + The descriptive data identifying the client submitting the transaction. + + + + + The descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Descriptive data about the shipment being sent by the requestor. + + + + + + + Currency exchange rate information. + + + + + The currency code for the original (converted FROM) currency. + + + + + The currency code for the final (converted INTO) currency. + + + + + Multiplier used to convert fromCurrency units to intoCurrency units. + + + + + + + + + Indicates the type of custom delivery being requested. + + + + + Time by which delivery is requested. + + + + + Range of dates for custom delivery request; only used if type is BETWEEN. + + + + + Date for custom delivery request; only used for types of ON, BETWEEN, or AFTER. + + + + + + + + + + + + + + + Data required to produce a custom-specified document, either at shipment or package level. + + + + + Common information controlling document production. + + + + + Applicable only to documents produced on thermal printers with roll stock. + + + + + Applicable only to documents produced on thermal printers with roll stock. + + + + + Identifies the formatting specification used to construct this custom document. + + + + + Identifies the individual document specified by the client. + + + + + If provided, thermal documents will include specified doc tab content. If omitted, document will be produced without doc tab content. + + + + + + + Constructed string, based on format and zero or more data fields, printed in specified barcode symbology. + + + + + + + + + Width of thinnest bar/space element in the barcode. + + + + + + + + Solid (filled) rectangular area on label. + + + + + + + + + Valid values for CustomLabelCoordinateUnits + + + + + + + + + + + + + + + + + + Image to be included from printer's memory, or from a local file for offline clients. + + + + + + Printer-specific index of graphic image to be printed. + + + + + Fully-qualified path and file name for graphic image to be printed. + + + + + + + + + Horizontal position, relative to left edge of custom area. + + + + + Vertical position, relative to top edge of custom area. + + + + + + + Constructed string, based on format and zero or more data fields, printed in specified printer font (for thermal labels) or generic font/size (for plain paper labels). + + + + + + + + Printer-specific font name for use with thermal printer labels. + + + + + Generic font name for use with plain paper labels. + + + + + Generic font size for use with plain paper labels. + + + + + + + + + + + + + + + + + + + Reference information to be associated with this package. + + + + + The reference type to be associated with this reference data. + + + + + + + + The types of references available for use. + + + + + + + + + + + + + + + + Allows customer-specified control of label content. + + + + + If omitted, no doc tab will be produced (i.e. default = former NONE type). + + + + + Defines any custom content to print on the label. + + + + + Defines additional data to print in the Configurable portion of the label, this allows you to print the same type information on the label that can also be printed on the doc tab. + + + + + Controls which data/sections will be suppressed. + + + + + Customer-provided SCNC for use with label-data-only processing of FedEx Ground shipments. + + + + + + Controls the number of additional copies of supplemental labels. + + + + + This value reduces the default quantity of destination/consignee air waybill labels. A value of zero indicates no change to default. A minimum of one copy will always be produced. + + + + + + + + + + Interacts both with properties of the shipment and contractual relationship with the shipper. + + + + + + Specifies how the recipient is identified for customs purposes; the requirements on this information vary with destination country. + + + + + + + + Identifies responsibilities with respect to loss, damage, etc. + + + + + Documents amount paid to third party for coverage of shipment content. + + + + + + + + + + + + + + + + + + The descriptive data required for a FedEx shipment containing dangerous goods (hazardous materials). + + + + + Identifies whether or not the products being shipped are required to be accessible during delivery. + + + + + Shipment is packaged/documented for movement ONLY on cargo aircraft. + + + + + Indicates which kinds of hazardous content are in the current package. + + + + + Documents the kinds and quantities of all hazardous commodities in the current package. + + + + + Description of the packaging of this commodity, suitable for use on OP-900 and OP-950 forms. + + + + + Telephone number to use for contact in the event of an emergency. + + + + + Offeror's name or contract number, per DOT regulation. + + + + + + + + + The beginning date in a date range. + + + + + The end date in a date range. + + + + + + + Valid values for DayofWeekType + + + + + + + + + + + + + + Descriptive data sent to FedEx by a customer in order to delete a package. + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + The timestamp of the shipment request. + + + + + Identifies the FedEx tracking number of the package being cancelled. + + + + + Determines the type of deletion to be performed in relation to package level vs shipment level. + + + + + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Only used for tags which had FedEx Express services. + + + + + Only used for tags which had FedEx Express services. + + + + + If the original ProcessTagRequest specified third-party payment, then the delete request must contain the same pay type and payor account number for security purposes. + + + + + Also known as Pickup Confirmation Number or Dispatch Number + + + + + + + Specifies the type of deletion to be performed on a shipment. + + + + + + + + + + Data required to complete the Destionation Control Statement for US exports. + + + + + List of applicable Statment types. + + + + + Comma-separated list of up to four country codes, required for DEPARTMENT_OF_STATE statement. + + + + + Name of end user, required for DEPARTMENT_OF_STATE statement. + + + + + + + Used to indicate whether the Destination Control Statement is of type Department of Commerce, Department of State or both. + + + + + + + + + The dimensions of this package and the unit type used for the measurements. + + + + + + + + + + + + + The DocTabContentType options available. + + + + + The DocTabContentType should be set to ZONE001 to specify additional Zone details. + + + + + The DocTabContentType should be set to BARCODED to specify additional BarCoded details. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Zone number can be between 1 and 12. + + + + + Header value on this zone. + + + + + Reference path to the element in the request/reply whose value should be printed on this zone. + + + + + Free form-text to be printed in this zone. + + + + + Justification for the text printed on this zone. + + + + + + + Identifies the method by which the package is to be tendered to FedEx. This element does not dispatch a courier for package pickup. + + + + + + + + + + + + Describes specific information about the email label shipment. + + + + + Notification email will be sent to this email address + + + + + Message to be sent in the notification email + + + + + + + + + + + + + Information describing email notifications that will be sent in relation to events that occur during package movement + + + + + Specifies whether/how email notifications are grouped. + + + + + A message that will be included in the email notifications + + + + + Information describing the destination of the email, format of the email and events to be notified on + + + + + + + The format of the email + + + + + + + + + + The descriptive data for a FedEx email notification recipient. + + + + + Identifies the relationship this email recipient has to the shipment. + + + + + The email address to send the notification to + + + + + Notify the email recipient when this shipment has been shipped. + + + + + Notify the email recipient if this shipment encounters a problem while in route + + + + + Notify the email recipient when this shipment has been delivered. + + + + + The format of the email notification. + + + + + The language/locale to be used in this email notification. + + + + + + + Identifies the set of valid email notification recipient types. For SHIPPER, RECIPIENT and BROKER the email address asssociated with their definitions will be used, any email address sent with the email notification for these three email notification recipient types will be ignored. + + + + + + + + + + + + + + + + + + + + + Customer-declared value, with data type and legal values depending on excise condition, used in defining the taxable value of the item. + + + + + + + Specifies the types of Estimated Duties and Taxes to be included in a rate quotation for an international shipment. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Specifies the client-requested response in the event of errors within shipment. + PACKAGE_ERROR_LABELS : Return per-package error label in addition to error Notifications. + STANDARD : Return error Notifications only. + + + + + + + + + + Electronic Trade document references used with the ETD special service. + + + + + Indicates the types of shipping documents produced for the shipper by FedEx (see ShippingDocumentSpecification) which should be copied back to the shipper in the shipment result data. + + + + + + + + Country specific details of an International shipment. + + + + + + Specifies which filing option is being exercised by the customer. + Required for non-document shipments originating in Canada destined for any country other than Canada, the United States, Puerto Rico or the U.S. Virgin Islands. + + + + + + General field for exporting-country-specific export data (e.g. B13A for CA, FTSR Exemption or AES Citation for US). + + + + + This field is applicable only to Canada export non-document shipments of any value to any destination. No special characters allowed. + + 10 + + + + + + Department of Commerce/Department of State information about this shipment. + + + + + + + Details specific to an Express freight shipment. + + + + + Indicates whether or nor a packing list is enclosed. + + + + + + Total shipment pieces. + e.g. 3 boxes and 3 pallets of 100 pieces each = Shippers Load and Count of 303. + Applicable to International Priority Freight and International Economy Freight. + Values must be in the range of 1 - 99999 + + + + + + Required for International Freight shipping. Values must be 8- 12 characters in length. + + 12 + + + + + + + + Identifies a kind of FedEx facility. + + + + + + + + + + + + + + + + Data required to produce the Freight handling-unit-level address labels. Note that the number of UNIQUE labels (the N as in 1 of N, 2 of N, etc.) is determined by total handling units. + + + + + + Indicates the number of copies to be produced for each unique label. + + + + + If omitted, no doc tab will be produced (i.e. default = former NONE type). + + + + + + + Individual charge which contributes to the total base charge for the shipment. + + + + + Freight class for this line item. + + + + + Effective freight class used for rating this line item. + + + + + NMFC Code for commodity. + + + + + Customer-provided description for this commodity or class line. + + + + + Weight for this commodity or class line. + + + + + Rate or factor applied to this line item. + + + + + Identifies the manner in which the chargeRate for this line item was applied. + + + + + The net or extended charge for this line item. + + + + + + + + + + + + + + These values represent the industry-standard freight classes used for FedEx Freight and FedEx National Freight shipment description. (Note: The alphabetic prefixes are required to distinguish these values from decimal numbers on some client platforms.) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Identifies responsibilities with respect to loss, damage, etc. + + + + + + + + + Rate data specific to FedEx Freight or FedEx National Freight services. + + + + + A unique identifier for a specific rate quotation. + + + + + Freight charges which accumulate to the total base charge for the shipment. + + + + + Human-readable descriptions of additional information on this shipment rating. + + + + + + + Additional non-monetary data returned with Freight rates. + + + + + Unique identifier for notation. + + + + + Human-readable explanation of notation. + + + + + + + Data applicable to shipments using FEDEX_FREIGHT and FEDEX_NATIONAL_FREIGHT services. + + + + + Account number used with FEDEX_FREIGHT service. + + + + + Used for validating FedEx Freight account number and (optionally) identifying third party payment on the bill of lading. + + + + + Identification values to be printed during creation of a Freight bill of lading. + + + + + Indicates the role of the party submitting the transaction. + + + + + Designates which of the requester's tariffs will be used for rating. + + + + + Designates the terms of the "collect" payment for a Freight Shipment. + + + + + Identifies the declared value for the shipment + + + + + Identifies the declared value units corresponding to the above defined declared value + + + + + + Identifiers for promotional discounts offered to customers. + + + + + Total number of individual handling units in the entire shipment (for unit pricing). + + + + + Estimated discount rate provided by client for unsecured rate quote. + + + + + Total weight of pallets used in shipment. + + + + + Overall shipment dimensions. + + + + + Description for the shipment. + + + + + Specifies which party will pay surcharges for any special services which support split billing. + + + + + Must be populated if any line items contain hazardous materials. + + + + + Details of the commodities in the shipment. + + + + + + + Description of an individual commodity or class of content in a shipment. + + + + + Freight class for this line item. + + + + + FEDEX INTERNAL USE ONLY: for FedEx system that estimate freight class from customer-provided dimensions and weight. + + + + + Number of individual handling units to which this line applies. (NOTE: Total of line-item-level handling units may not balance to shipment-level total handling units.) + + + + + Specification of handling-unit packaging for this commodity or class line. + + + + + Number of pieces for this commodity or class line. + + + + + NMFC Code for commodity. + + + + + Indicates the kind of hazardous material content in this line item. + + + + + For printed reference per line item. + + + + + For printed reference per line item. + + + + + Customer-provided description for this commodity or class line. + + + + + Weight for this commodity or class line. + + + + + FED EX INTERNAL USE ONLY - Individual line item dimensions. + + + + + Volume (cubic measure) for this commodity or class line. + + + + + + + Indicates the role of the party submitting the transaction. + + + + + + + + + + Specifies which party will be responsible for payment of any surcharges for Freight special services for which split billing is allowed. + + + + + Identifies the special service. + + + + + Indicates who will pay for the special service. + + + + + + + Data required to produce a General Agency Agreement document. Remaining content (business data) to be defined once requirements have been completed. + + + + + + + + Documents the kind and quantity of an individual hazardous commodity in a package. + + + + + Identifies and describes an individual hazardous commodity. + + + + + Specifies the amount of the commodity in alternate units. + + + + + Customer-provided specifications for handling individual commodities. + + + + + + + Identifies and describes an individual hazardous commodity. For 201001 load, this is based on data from the FedEx Ground Hazardous Materials Shipping Guide. + + + + + Regulatory identifier for a commodity (e.g. "UN ID" value). + + + + + + + + + + + + + Specifies how the commodity is to be labeled. + + + + + + + + + + Customer-provided specifications for handling individual commodities. + + + + + Specifies how the customer wishes the label text to be handled for this commodity in this package. + + + + + Text used in labeling the commodity under control of the labelTextOption field. + + + + + + + Indicates which kind of hazardous content (as defined by DOT) is being reported. + + + + + + + + + + + + Identifies number and type of packaging units for hazardous commodities. + + + + + Number of units of the type below. + + + + + Units in which the hazardous commodity is packaged. + + + + + + + Identifies DOT packing group for a hazardous commodity. + + + + + + + + + + Identifies amount and units for quantity of hazardous commodities. + + + + + Number of units of the type below. + + + + + Units by which the hazardous commodity is measured. + + + + + + + Descriptive data required for a FedEx shipment that is to be held at the destination FedEx location for pickup by the recipient. + + + + + Contact phone number for recipient of shipment. + + + + + Contact and address of FedEx facility at which shipment is to be held. + + + + + Type of facility at which package/shipment is to be held. + + + + + + + The descriptive data required by FedEx for home delivery services. + + + + + The type of Home Delivery Premium service being requested. + + + + + Required for Date Certain Home Delivery. + + + + + Required for Date Certain and Appointment Home Delivery. + + 15 + + + + + + + + The type of Home Delivery Premium service being requested. + + + + + + + + + + + + + + + + + + + The type of International shipment. + + + + + + + + + + Specifies the type of label to be returned. + + + + + + + + + + + Names for data elements / areas which may be suppressed from printing on labels. + + + + + + + + + + + + This indicates if the top or bottom of the label comes out of the printer first. + + + + + + + + + Relative to normal orientation for the printer. + + + + + + + + + + + Description of shipping label to be returned in the reply + + + + + Specifies how to create, organize, and return the document. + + + + + Specify type of label to be returned + + + + + Specifies the image format used for a shipping document. + + + + + For thermal printer lables this indicates the size of the label and the location of the doc tab if present. + + + + + This indicates if the top or bottom of the label comes out of the printer first. + + + + + If present, this contact and address information will replace the return address information on the label. + + + + + Allows customer-specified control of label content. + + + + + + + For thermal printer labels this indicates the size of the label and the location of the doc tab if present. + + + + + + + + + + + + + + + + + + + + + + + Identifies the Liability Coverage Amount. For Jan 2010 this value represents coverage amount per pound + + + + + + + + + + + + + Represents a one-dimensional measurement in small units (e.g. suitable for measuring a package or document), contrasted with Distance, which represents a large one-dimensional measurement (e.g. distance between cities). + + + + + The numerical quantity of this measurement. + + + + + The units for this measurement. + + + + + + + CM = centimeters, IN = inches + + + + + + + + + Identifies the representation of human-readable text. + + + + + Two-letter code for language (e.g. EN, FR, etc.) + + + + + Two-letter code for the region (e.g. us, ca, etc..). + + + + + + + + + + + + + Identifies which type minimum charge was applied. + + + + + + + + + + + + The descriptive data for the medium of exchange for FedEx services. + + + + + Identifies the currency of the monetary amount. + + 3 + + + + + + Identifies the monetary amount. + + + + + + + Data required to produce a Certificate of Origin document. Remaining content (business data) to be defined once requirements have been completed. + + + + + + + Indicates which Party (if any) from the shipment is to be used as the source of importer data on the NAFTA COO form. + + + + + Contact information for "Authorized Signature" area of form. + + + + + + + + + + This element is currently not supported and is for the future use. + + + + + Defined by NAFTA regulations. + + + + + Defined by NAFTA regulations. + + + + + Identification of which producer is associated with this commodity (if multiple producers are used in a single shipment). + + + + + + Date range over which RVC net cost was calculated. + + + + + + + + + + + + + + + Net cost method used. + + + + + + + + + See instructions for NAFTA Certificate of Origin for code definitions. + + + + + + + + + + + + + This element is currently not supported and is for the future use. + + + + + + + + + See instructions for NAFTA Certificate of Origin for code definitions. + + + + + + + + + + + This element is currently not supported and is for the future use. + + + + + + + + + + + + The descriptive data regarding the result of the submitted transaction. + + + + + The severity of this notification. This can indicate success or failure or some other information about the request. The values that can be returned are SUCCESS - Your transaction succeeded with no other applicable information. NOTE - Additional information that may be of interest to you about your transaction. WARNING - Additional information that you need to know about your transaction that you may need to take action on. ERROR - Information about an error that occurred while processing your transaction. FAILURE - FedEx was unable to process your transaction at this time due to a system failure. Please try again later + + + + + Indicates the source of this notification. Combined with the Code it uniquely identifies this notification + + + + + A code that represents this notification. Combined with the Source it uniquely identifies this notification. + + + + + Human-readable text that explains this notification. + + + + + The translated message. The language and locale specified in the ClientDetail. Localization are used to determine the representation. Currently only supported in a TrackReply. + + + + + A collection of name/value pairs that provide specific data to help the client determine the nature of an error (or warning, etc.) witout having to parse the message string. + + + + + + + + + Identifies the type of data contained in Value (e.g. SERVICE_TYPE, PACKAGE_SEQUENCE, etc..). + + + + + The value of the parameter (e.g. PRIORITY_OVERNIGHT, 2, etc..). + + + + + + + Identifies the set of severity values for a Notification. + + + + + + + + + + + + The instructions indicating how to print the OP-900 form for hazardous materials packages. + + + + + Specifies characteristics of a shipping document to be produced. + + + + + Identifies which reference type (from the package's customer references) is to be used as the source for the reference on this OP-900. + + + + + Specifies the usage and identification of customer supplied images to be used on this document. + + + + + Data field to be used when a name is to be printed in the document instead of (or in addition to) a signature image. + + + + + + + The oversize class types. + + + + + + + + + + Each instance of this data type represents the set of barcodes (of all types) which are associated with a specific package. + + + + + Binary-style barcodes for this package. + + + + + String-style barcodes for this package. + + + + + + + Data for a package's rates, as calculated per a specific rate type. + + + + + Type used for this specific set of rate data. + + + + + Indicates which weight was used. + + + + + INTERNAL FEDEX USE ONLY. + + + + + The weight that was used to calculate the rate. + + + + + The dimensional weight of this package (if greater than actual). + + + + + The oversize weight of this package (if the package is oversize). + + + + + The transportation charge only (prior to any discounts applied) for this package. + + + + + The sum of all discounts on this package. + + + + + This package's baseCharge - totalFreightDiscounts. + + + + + The sum of all surcharges on this package. + + + + + This package's netFreight + totalSurcharges (not including totalTaxes). + + + + + The sum of all taxes on this package. + + + + + This package's netFreight + totalSurcharges + totalTaxes. + + + + + The total sum of all rebates applied to this package. + + + + + All rate discounts that apply to this package. + + + + + All rebates that apply to this package. + + + + + All surcharges that apply to this package (either because of characteristics of the package itself, or because it is carrying per-shipment surcharges for the shipment of which it is a part). + + + + + All taxes applicable (or distributed to) this package. + + + + + The variable handling charges calculated based on the type variable handling charges requested. + + + + + + + This class groups together for a single package all package-level rate data (across all rate types) as part of the response to a shipping request, which groups shipment-level data together and groups package-level data by package. + + + + + This rate type identifies which entry in the following array is considered as presenting the "actual" rates for the package. + + + + + The "list" net charge minus "actual" net charge. + + + + + Each element of this field provides package-level rate data for a specific rate type. + + + + + + + Identifies the collection of special service offered by FedEx. BROKER_SELECT_OPTION should be used for Ground shipments only. + + + + + + + + + + + + + + These special services are available at the package level for some or all service types. If the shipper is requesting a special service which requires additional data, the package special service type must be present in the specialServiceTypes collection, and the supporting detail must be provided in the appropriate sub-object below. + + + + + The types of all special services requested for the enclosing shipment or package. + + + + + For use with FedEx Ground services only; COD must be present in shipment's special services. + + + + + Descriptive data required for a FedEx shipment containing dangerous materials. This element is required when SpecialServiceType.DANGEROUS_GOODS or HAZARDOUS_MATERIAL is present in the SpecialServiceTypes collection. + + + + + Descriptive data required for a FedEx shipment containing dry ice. This element is required when SpecialServiceType.DRY_ICE is present in the SpecialServiceTypes collection. + + + + + The descriptive data required for FedEx signature services. This element is required when SpecialServiceType.SIGNATURE_OPTION is present in the SpecialServiceTypes collection. + + + + + The descriptive data required for FedEx Priority Alert service. This element is required when SpecialServiceType.PRIORITY_ALERT is present in the SpecialServiceTypes collection. + + + + + + + Identifies the collection of available FedEx or customer packaging options. + + + + + + + + + + + + + + The descriptive data for a person or company entitiy doing business with FedEx. + + + + + Identifies the FedEx account number assigned to the customer. + + 12 + + + + + + + Descriptive data identifying the point-of-contact person. + + + + + The descriptive data for a physical location. + + + + + + + The descriptive data for the monetary compensation given to FedEx for services rendered to the customer. + + + + + Identifies the method of payment for a service. See PaymentType for list of valid enumerated values. + + + + + Descriptive data identifying the party responsible for payment for a service. + + + + + + + Identifies the method of payment for a service. + + + + + + + + + + + The descriptive data identifying the party responsible for payment for a service. + + + + + Identifies the FedEx account number assigned to the payor. + + 12 + + + + + + Identifies the country of the payor. + + 2 + + + + + + + + This information describes how and when a pending shipment may be accessed for completion. + + + + + Only for pending shipment type of "EMAIL" + + + + + Only for pending shipment type of "EMAIL" + + + + + Only for pending shipment type of "EMAIL" + + + + + This element is currently not supported and is for the future use. + + + + + + + This information describes the kind of pending shipment being requested. + + + + + Identifies the type of FedEx pending shipment + + + + + Date after which the pending shipment will no longer be available for completion. + + + + + Only used with type of EMAIL. + + + + + + + Identifies the type of service for a pending shipment. + + + + + + + + This enumeration rationalizes the former FedEx Express international "admissibility package" types (based on ANSI X.12) and the FedEx Freight packaging types. The values represented are those common to both carriers. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This class describes the pickup characteristics of a shipment (e.g. for use in a tag request). + + + + + + + + Identifies the type of Pickup request + + + + + Identifies the type of source for Pickup request + + + + + + + Identifies the type of source for pickup request service. + + + + + + + + + Identifies the type of pickup request service. + + + + + + + + + Identifies the type of pricing used for this shipment. + + + + + + + + + + + + + + + + + + + + Represents a reference identifier printed on Freight bills of lading + + + + + + + + + Identifies a particular reference identifier printed on a Freight bill of lading. + + + + + + + + + + + + + + + + This indicates the highest level of severity of all the notifications returned in this reply + + + + + The descriptive data regarding the results of the submitted transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + The reply payload. All of the returned information about this shipment/package. + + + + + Empty unless error label behavior is PACKAGE_ERROR_LABELS and one or more errors occured during transaction processing. + + + + + + + Descriptive data sent to FedEx by a customer in order to ship a package. + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Descriptive data about the shipment being sent by the requestor. + + + + + + + + + + + + + + + + Descriptive data sent to FedEx by a customer in order to ship a package. + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Descriptive data about the shipment being sent by the requestor. + + + + + + + Test for the Commercial Invoice. Note that Sold is not a valid Purpose for a Proforma Invoice. + + + + + + + + + + + + + Indicates the reason that a dim divisor value was chose. + + + + + + + + + + + + Identifies a discount applied to the shipment. + + + + + Identifies the type of discount applied to the shipment. + + + + + + The amount of the discount applied to the shipment. + + + + + The percentage of the discount applied to the shipment. + + + + + + + The type of the discount. + + + + + + + + + + + + + Identifies the type(s) of rates to be returned in the reply. + + + + + + + + + + The weight method used to calculate the rate. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Specifies how the recipient is identified for customs purposes; the requirements on this information vary with destination country. + + + + + Specifies the kind of identification being used. + + + + + Contains the actual ID value, of the type specified above. + + + + + + + Type of Brazilian taxpayer identifier provided in Recipient/TaxPayerIdentification/Number. For shipments bound for Brazil this overrides the value in Recipient/TaxPayerIdentification/TinType + + + + + + + + + + FOOD_OR_PERISHABLE is required by FDA/BTA; must be true for food/perishable items coming to US or PR from non-US/non-PR origin + + + + + + + + + + + + + + + + + This class rationalizes RequestedPackage and RequestedPackageSummary from previous interfaces. The way in which it is uses within a RequestedShipment depends on the RequestedPackageDetailType value specified for that shipment. + + + + + Used only with INDIVIDUAL_PACKAGE, as a unique identifier of each requested package. + + + + + Used only with PACKAGE_GROUPS, as a unique identifier of each group of identical packages. + + + + + Used only with PACKAGE_GROUPS, as a count of packages within a group of identical packages. + + + + + + Only used for INDIVIDUAL_PACKAGES and PACKAGE_GROUPS. Ignored for PACKAGE_SUMMARY, in which case totalInsuredValue and packageCount on the shipment will be used to determine this value. + + + + + Only used for INDIVIDUAL_PACKAGES and PACKAGE_GROUPS. Ignored for PACKAGE_SUMMARY, in which case totalweight and packageCount on the shipment will be used to determine this value. + + + + + + Provides additional detail on how the customer has physically packaged this item. As of June 2009, required for packages moving under international and SmartPost services. + + + + + Human-readable text describing the package. + + + + + + + Only used for INDIVIDUAL_PACKAGES and PACKAGE_GROUPS. + + + + + + + The descriptive data for the shipment being tendered to FedEx. + + + + + Identifies the date and time the package is tendered to FedEx. Both the date and time portions of the string are expected to be used. The date should not be a past date or a date more than 10 days in the future. The time is the local time of the shipment based on the shipper's time zone. The date component must be in the format: YYYY-MM-DD (e.g. 2006-06-26). The time component must be in the format: HH:MM:SS using a 24 hour clock (e.g. 11:00 a.m. is 11:00:00, whereas 5:00 p.m. is 17:00:00). The date and time parts are separated by the letter T (e.g. 2006-06-26T17:00:00). There is also a UTC offset component indicating the number of hours/mainutes from UTC (e.g 2006-06-26T17:00:00-0400 is defined form June 26, 2006 5:00 pm Eastern Time). + + + + + Identifies the method by which the package is to be tendered to FedEx. This element does not dispatch a courier for package pickup. See DropoffType for list of valid enumerated values. + + + + + Identifies the FedEx service to use in shipping the package. See ServiceType for list of valid enumerated values. + + + + + Identifies the packaging used by the requestor for the package. See PackagingType for list of valid enumerated values. + + + + + Identifies the total weight of the shipment being conveyed to FedEx.This is only applicable to International shipments and should only be used on the first package of a mutiple piece shipment.This value contains 1 explicit decimal position + + + + + Total insured amount. + + + + + + Descriptive data identifying the party responsible for shipping the package. Shipper and Origin should have the same address. + + + + + Descriptive data identifying the party receiving the package. + + + + + A unique identifier for a recipient location + + 10 + + + + + + Physical starting address for the shipment, if different from shipper's address. + + + + + Descriptive data indicating the method and means of payment to FedEx for providing shipping services. + + + + + Descriptive data regarding special services requested by the shipper for this shipment. If the shipper is requesting a special service which requires additional data (e.g. COD), the special service type must be present in the specialServiceTypes collection, and the supporting detail must be provided in the appropriate sub-object. For example, to request COD, "COD" must be included in the SpecialServiceTypes collection and the CodDetail object must contain the required data. + + + + + Details specific to an Express freight shipment. + + + + + Data applicable to shipments using FEDEX_FREIGHT and FEDEX_NATIONAL_FREIGHT services. + + + + + Used with Ground Home Delivery and Freight. + + + + + Details about how to calculate variable handling charges at the shipment level. + + + + + Customs clearance data, used for both international and intra-country shipping. + + + + + For use in "process tag" transaction. + + + + + + If true, only the shipper/payor will have visibility of this shipment. + + + + + Specifies the client-requested response in the event of errors within shipment. + + + + + Details about the image format and printer type the label is to returned in. + + + + + Contains data used to create additional (non-label) shipping documents. + + + + + Specifies whether and what kind of rates the customer wishes to have quoted on this shipment. The reply will also be constrained by other data on the shipment and customer. + + + + + Specifies the type of rate the customer wishes to have used as the actual rate type. + + + + + Specifies whether the customer wishes to have Estimated Duties and Taxes provided with the rate quotation on this shipment. Only applies with shipments moving under international services. + + + + + Only used with multiple-transaction shipments. + + + + + Only used with multi-piece COD shipments sent in multiple transactions. Required on last transaction only. + + + + + The total number of packages in the entire shipment (even when the shipment spans multiple transactions.) + + + + + Specifies whether packages are described individually, in groups, or summarized in a single description for total-piece-total-weight. This field controls which fields of the RequestedPackageLineItem will be used, and how many occurrences are expected. + + + + + One or more package-attribute descriptions, each of which describes an individual package, a group of identical packages, or (for the total-piece-total-weight case) common characteristics all packages in the shipment. + + + + + + + + + + + + + + + + + + + + + + + These values are used to control the availability of certain special services at the time when a customer uses the e-mail label link to create a return shipment. + + + + + + + + + Return Email Details + + + + + Phone number of the merchant + + + + + Identifies the allowed (merchant-authorized) special services which may be selected when the subsequent shipment is created. Only services represented in EMailLabelAllowedSpecialServiceType will be controlled by this list. + + + + + + + Information relating to a return shipment. + + + + + The type of return shipment that is being requested. + + + + + Return Merchant Authorization + + + + + Describes specific information about the email label for return shipment. + + + + + + + The type of return shipment that is being requested. + + + + + + + + + + The "PAYOR..." rates are expressed in the currency identified in the payor's rate table(s). The "RATED..." rates are expressed in the currency of the origin country. Former "...COUNTER..." values have become "...RETAIL..." values, except for PAYOR_COUNTER and RATED_COUNTER, which have been removed. + + + + + + + + + + + + + + + + Shipping document type. + + + + + + + + + + + + + + + + + + + + + + + + + + + + Return Merchant Authorization + + + + + The RMA number. + + 20 + + + + + + The reason for the return. + + 60 + + + + + + + + The tracking number information and the data to form the Astra barcode for the label. + + + + + The tracking number information for the shipment. + + + + + + The textual description of the special service applied to the package. + + + + + + + + Information about the routing, origin, destination and delivery of a shipment. + + + + + The routing information detail for this shipment. + + + + + The tracking number information and the data to form the Astra barcode for the label. + + + + + + + Identifies the collection of available FedEx service options. + + + + + + + + + + + + + + + + + + + + + + + + + Shipment-level totals of dry ice data across all packages. + + + + + Total number of packages in the shipment that contain dry ice. + + + + + Total shipment dry ice weight for all packages. + + + + + + + Data for a shipment's total/summary rates, as calculated per a specific rate type. The "total..." fields may differ from the sum of corresponding package data for Multiweight or Express MPS. + + + + + Type used for this specific set of rate data. + + + + + Indicates the rate scale used. + + + + + Indicates the rate zone used (based on origin and destination). + + + + + Identifies the type of pricing used for this shipment. + + + + + Indicates which weight was used. + + + + + INTERNAL FEDEX USE ONLY. + + + + + Specifies the currency exchange performed on financial amounts for this rate. + + + + + Indicates which special rating cases applied to this shipment. + + + + + The value used to calculate the weight based on the dimensions. + + + + + Identifies the type of dim divisor that was applied. + + + + + Specifies a fuel surcharge percentage. + + + + + The weight used to calculate these rates. + + + + + Sum of dimensional weights for all packages. + + + + + The total freight charge that was calculated for this package before surcharges, discounts and taxes. + + + + + The total discounts used in the rate calculation. + + + + + The freight charge minus discounts. + + + + + The total amount of all surcharges applied to this shipment. + + + + + This shipment's totalNetFreight + totalSurcharges (not including totalTaxes). + + + + + Total of the transportation-based taxes. + + + + + The net charge after applying all discounts and surcharges. + + + + + The total sum of all rebates applied to this shipment. + + + + + Total of all values under this shipment's dutiesAndTaxes; only provided if estimated duties and taxes were calculated for this shipment. + + + + + This shipment's totalNetCharge + totalDutiesAndTaxes; only provided if estimated duties and taxes were calculated for this shipment AND duties, taxes and transportation charges are all paid by the same sender's account. + + + + + Rate data specific to FedEx Freight and FedEx National Freight services. + + + + + All rate discounts that apply to this shipment. + + + + + All rebates that apply to this shipment. + + + + + All surcharges that apply to this shipment. + + + + + All transportation-based taxes applicable to this shipment. + + + + + All commodity-based duties and taxes applicable to this shipment. + + + + + The "order level" variable handling charges. + + + + + The total of all variable handling charges at both shipment (order) and package level. + + + + + + + This class groups together all shipment-level rate data (across all rate types) as part of the response to a shipping request, which groups shipment-level data together and groups package-level data by package. + + + + + This rate type identifies which entry in the following array is considered as presenting the "actual" rates for the shipment. + + + + + The "list" total net charge minus "actual" total net charge. + + + + + Each element of this field provides shipment-level rate totals for a specific rate type. + + + + + + + + + This indicates the highest level of severity of all the notifications returned in this reply + + + + + The descriptive data regarding the results of the submitted transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + + + Information about the routing, origin, destination and delivery of a shipment. + + + + + The prefix portion of the URSA (Universal Routing and Sort Aid) code. + + 2 + + + + + + The suffix portion of the URSA code. + + 5 + + + + + + The identifier of the origin location of the shipment. Express only. + + 5 + + + + + + + The identifier of the destination location of the shipment. Express only. + + 5 + + + + + + + This is the state of the destination location ID, and is not necessarily the same as the postal state. + + + + + Expected/estimated date of delivery. + + + + + Expected/estimated day of week of delivery. + + + + + Committed date of delivery. + + + + + Committed day of week of delivery. + + + + + Standard transit time per origin, destination, and service. + + + + + Maximum expected transit time + + + + + Text describing planned delivery. + + + + + Currently not supported. + + TBD + + + + + + The postal code of the destination of the shipment. + + 16 + + + + + + The state or province code of the destination of the shipment. + + 14 + + + + + + The country code of the destination of the shipment. + + 2 + + + + + + The identifier for the airport of the destination of the shipment. + + 4 + + + + + + + + Identifies the collection of special service offered by FedEx. BROKER_SELECT_OPTION should be used for Express shipments only. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + These special services are available at the shipment level for some or all service types. If the shipper is requesting a special service which requires additional data (such as the COD amount), the shipment special service type must be present in the specialServiceTypes collection, and the supporting detail must be provided in the appropriate sub-object below. + + + + + The types of all special services requested for the enclosing shipment (or other shipment-level transaction). + + + + + Descriptive data required for a FedEx COD (Collect-On-Delivery) shipment. This element is required when SpecialServiceType.COD is present in the SpecialServiceTypes collection. + + + + + Descriptive data required for a FedEx shipment that is to be held at the destination FedEx location for pickup by the recipient. This element is required when SpecialServiceType.HOLD_AT_LOCATION is present in the SpecialServiceTypes collection. + + + + + Descriptive data required for FedEx to provide email notification to the customer regarding the shipment. This element is required when SpecialServiceType.EMAIL_NOTIFICATION is present in the SpecialServiceTypes collection. + + + + + The descriptive data required for FedEx Printed Return Label. This element is required when SpecialServiceType.PRINTED_RETURN_LABEL is present in the SpecialServiceTypes collection + + + + + This field should be populated for pending shipments (e.g. e-mail label) It is required by a PENDING_SHIPMENT special service type. + + + + + Number of packages in this shipment which contain dry ice and the total weight of the dry ice for this shipment. + + + + + The descriptive data required for FedEx Home Delivery options. This element is required when SpecialServiceType.HOME_DELIVERY_PREMIUM is present in the SpecialServiceTypes collection + + + + + Electronic Trade document references. + + + + + Specification for date or range of dates on which delivery is to be attempted. + + + + + + + All package-level shipping documents (other than labels and barcodes). + + + + + Shipping Document Type + + + + + Specifies how this document image/file is organized. + + + + + + The name under which a STORED or DEFERRED document is written. + + + + + Specifies the image resolution in DPI (dots per inch). + + + + + Can be zero for documents whose disposition implies that no content is included. + + + + + One or more document parts which make up a single logical document, such as multiple pages of a single form. + + + + + + + Each occurrence of this class specifies a particular way in which a kind of shipping document is to be produced and provided. + + + + + Values in this field specify how to create and return the document. + + + + + Specifies how to organize all documents of this type. + + + + + Specifies how to e-mail document images. + + + + + Specifies how a queued document is to be printed. + + + + + + + Specifies how to return a shipping document to the caller. + + + + + + + + + + + + + + Specifies how to e-mail shipping documents. + + + + + Provides the roles and email addresses for e-mail recipients. + + + + + Identifies the convention by which documents are to be grouped as e-mail attachments. + + + + + + + + + + + + + Specifies an individual recipient of e-mailed shipping document(s). + + + + + Identifies the relationship of this recipient in the shipment. + + + + + Address to which the document is to be sent. + + + + + + + Specifies characteristics of a shipping document to be produced. + + + + + Specifies how to create, organize, and return the document. + + + + + Specifies how far down the page to move the beginning of the image; allows for printing on letterhead and other pre-printed stock. + + + + + + + For those shipping document types which have both a "form" and "instructions" component (e.g. NAFTA Certificate of Origin and General Agency Agreement), this field indicates whether to provide the instructions. + + + + + Governs the language to be used for this individual document, independently from other content returned for the same shipment. + + + + + Identifies the individual document specified by the client. + + + + + + + Specifies how to organize all shipping documents of the same type. + + + + + + + + + Specifies the image format used for a shipping document. + + + + + + + + + + + + + + + A single part of a shipping document, such as one page of a multiple-page document whose format requires a separate image per page. + + + + + The one-origin position of this part within a document. + + + + + Graphic or printer commands for this image within a document. + + + + + + + Specifies printing options for a shipping document. + + + + + Provides environment-specific printer identification. + + + + + + + Contains all data required for additional (non-label) shipping documents to be produced in conjunction with a specific shipment. + + + + + Indicates the types of shipping documents requested by the shipper. + + + + + + + Specifies the production of each package-level custom document (the same specification is used for all packages). + + + + + Specifies the production of a shipment-level custom document. + + + + + This element is currently not supported and is for the future use. (Details pertaining to the GAA.) + + + + + + Specifies the production of the OP-900 document for hazardous materials packages. + + + + + Specifies the production of the OP-900 document for hazardous materials. + + + + + + + Specifies the type of paper (stock) on which a document will be printed. + + + + + + + + + + + + + + + + + + The descriptive data required for FedEx delivery signature services. + + + + + Identifies the delivery signature services option selected by the customer for this shipment. See OptionType for the list of valid values. + + + + + Identifies the delivery signature release authorization number. + + 10 + + + + + + + + Identifies the delivery signature services options offered by FedEx. + + + + + + + + + + + + These values are mutually exclusive; at most one of them can be attached to a SmartPost shipment. + + + + + + + + + + + + + + + + + + + + + Data required for shipments handled under the SMART_POST and GROUND_SMART_POST service types. + + + + + + + + + The CustomerManifestId is used to group Smart Post packages onto a manifest for each trailer that is being prepared. If you do not have multiple trailers this field can be omitted. If you have multiple trailers, you + must assign the same Manifest Id to each SmartPost package as determined by its trailer. In other words, all packages on a trailer must have the same Customer Manifest Id. The manifest Id must be unique to your account number for a minimum of 6 months + and cannot exceed 8 characters in length. We recommend you use the day of year + the trailer id (this could simply be a sequential number for that trailer). So if you had 3 trailers that you started loading on Feb 10 + the 3 manifest ids would be 041001, 041002, 041003 (in this case we used leading zeros on the trailer numbers). + + + + + + + + Special circumstance rating used for this shipment. + + + + + + + + + Each instance of this data type represents a barcode whose content must be represented as ASCII text (i.e. not binary data). + + + + + The kind of barcode data in this instance. + + + + + The data content of this instance. + + + + + + + + + + + + + + + + + Identifies each surcharge applied to the shipment. + + + + + The type of surcharge applied to the shipment. + + + + + + + The amount of the surcharge applied to the shipment. + + + + + + + + + + + + + The type of the surcharge. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Identifies each tax applied to the shipment. + + + + + The type of tax applied to the shipment. + + + + + + The amount of the tax applied to the shipment. + + + + + + + The type of the tax. + + + + + + + + + + + + + + The descriptive data for taxpayer identification information. + + + + + Identifies the category of the taxpayer identification number. See TinType for the list of values. + + + + + Identifies the taxpayer identification number. + + 15 + + + + + + Identifies the usage of Tax Identification Number in Shipment processing + + + + + + + + Required for dutiable international express or ground shipment. This field is not applicable to an international PIB (document) or a non-document which does not require a commercial invoice express shipment. + CFR_OR_CPT (Cost and Freight/Carriage Paid TO) + CIF_OR_CIP (Cost Insurance and Freight/Carraige Insurance Paid) + DDP (Delivered Duty Paid) + DDU (Delivered Duty Unpaid) + EXW (Ex Works) + FOB_OR_FCA (Free On Board/Free Carrier) + + + + + + + + + + + + + + Identifies the category of the taxpayer identification number. + + + + + + + + + + + + + + + For use with SmartPost tracking IDs only + + + + + + + + TrackingIdType + + + + + + + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Free form text to be echoed back in the reply. Used to match requests and replies. + + + + + Governs data payload language/translations (contrasted with ClientDetail.localization, which governs Notification.localizedMessage language selection). + + + + + + + Identifies the set of valid shipment transit time values. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Descriptive data sent to FedEx by a customer in order to validate a shipment. + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Descriptive data about the shipment being sent by the requestor. + + + + + + + Documents the kind and quantity of an individual hazardous commodity in a package. + + + + + Identifies and describes an individual hazardous commodity. + + + + + Specifies the amount of the commodity in alternate units. + + + + + Customer-provided specifications for handling individual commodities. + + + + + + + Identifies and describes an individual hazardous commodity. For 201001 load, this is based on data from the FedEx Ground Hazardous Materials Shipping Guide. + + + + + Regulatory identifier for a commodity (e.g. "UN ID" value). + + + + + + + Fully-expanded descriptive text for a hazardous commodity. + + + + + + + + Coded indications for special requirements or constraints. + + + + + + + + Details about how to calculate variable handling charges at the shipment level. + + + + + The type of handling charge to be calculated and returned in the reply. + + + + + + Used with Variable handling charge type of FIXED_VALUE. + Contains the amount to be added to the freight charge. + Contains 2 explicit decimal positions with a total max length of 10 including the decimal. + + + + + + Actual percentage (10 means 10%, which is a mutiplier of 0.1) + + + + + + + The type of handling charge to be calculated and returned in the reply. + + + + + + + + + + + The variable handling charges calculated based on the type variable handling charges requested. + + + + + The variable handling charge amount calculated based on the requested variable handling charge detail. + + + + + The calculated varibale handling charge plus the net charge. + + + + + + + Three-dimensional volume/cubic measurement. + + + + + + + + + Units of three-dimensional volume/cubic measure. + + + + + + + + + The descriptive data for the heaviness of an object. + + + + + Identifies the unit of measure associated with a weight value. + + + + + Identifies the weight value of a package/shipment. + + + + + + + Identifies the unit of measure associated with a weight value. See the list of enumerated types for valid values. + + + + + + + + + Used in authentication of the sender's identity. + + + + + Credential used to authenticate a specific software application. This value is provided by FedEx after registration. + + + + + + + Two part authentication string used for the sender's identity + + + + + Identifying part of authentication credential. This value is provided by FedEx after registration + + + + + Secret part of authentication key. This value is provided by FedEx after registration. + + + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Identifies a system or sub-system which performs an operation. + + + + + Identifies the service business level. + + + + + Identifies the service interface level. + + + + + Identifies the service code level. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git app/code/core/Mage/Usa/etc/wsdl/FedEx/TrackService_v5.wsdl app/code/core/Mage/Usa/etc/wsdl/FedEx/TrackService_v5.wsdl new file mode 100644 index 0000000..1f275b3 --- /dev/null +++ app/code/core/Mage/Usa/etc/wsdl/FedEx/TrackService_v5.wsdl @@ -0,0 +1,1510 @@ + + + + + + + + + + + + + + Descriptive data for a physical location. May be used as an actual physical address (place to which one could go), or as a container of "address parts" which should be handled as a unit (such as a city-state-ZIP combination within the US). + + + + + Combination of number, street name, etc. At least one line is required for a valid physical address; empty lines should not be included. + + + + + Name of city, town, etc. + + + + + Identifying abbreviation for US state, Canada province, etc. Format and presence of this field will vary, depending on country. + + + + + Identification of a region (usually small) for mail/package delivery. Format and presence of this field will vary, depending on country. + + + + + Relevant only to addresses in Puerto Rico. + + + + + The two-letter code used to identify a country. + + + + + Indicates whether this address residential (as opposed to commercial). + + + + + + + Identifies where a tracking event occurs. + + + + + + + + + + + + + + + + + + + + + + + + + + + Identification of a FedEx operating company (transportation). + + + + + + + + + + + + + Descriptive data for the client submitting a transaction. + + + + + The FedEx account number associated with this transaction. + + + + + This number is assigned by FedEx and identifies the unique device from which the request is originating + + + + + Only used in transactions which require identification of the Fed Ex Office integrator. + + + + + The language to be used for human-readable Notification.localizedMessages in responses to the request containing this ClientDetail object. Different requests from the same client may contain different Localization data. (Contrast with TransactionDetail.localization, which governs data payload language/translation.) + + + + + + + The descriptive data for a point-of-contact person. + + + + + Identifies the contact person's name. + + + + + Identifies the contact person's title. + + + + + Identifies the company this contact is associated with. + + + + + Identifies the phone number associated with this contact. + + + + + Identifies the phone extension associated with this contact. + + + + + Identifies the pager number associated with this contact. + + + + + Identifies the fax number associated with this contact. + + + + + Identifies the email address associated with this contact. + + + + + + + + + + + + + The dimensions of this package and the unit type used for the measurements. + + + + + + + + + + + Driving or other transportation distances, distinct from dimension measurements. + + + + + Identifies the distance quantity. + + + + + Identifies the unit of measure for the distance value. + + + + + + + Identifies the collection of units of measure that can be associated with a distance value. + + + + + + + + + Information describing email notifications that will be sent in relation to events that occur during package movement + + + + + A message that will be included in the email notifications + + + + + Information describing the destination of the email, format of the email and events to be notified on + + + + + + + + + + + + + + + The format of the email + + + + + + + + + + + + Identifies the relationship this email recipient has to the shipment. + + + + + The email address to send the notification to + + + + + The types of email notifications being requested for this recipient. + + + + + The format of the email notification. + + + + + The language/locale to be used in this email notification. + + + + + + + + + + + + + + + CM = centimeters, IN = inches + + + + + + + + + Identifies the representation of human-readable text. + + + + + Two-letter code for language (e.g. EN, FR, etc.) + + + + + Two-letter code for the region (e.g. us, ca, etc..). + + + + + + + The descriptive data regarding the result of the submitted transaction. + + + + + The severity of this notification. This can indicate success or failure or some other information about the request. The values that can be returned are SUCCESS - Your transaction succeeded with no other applicable information. NOTE - Additional information that may be of interest to you about your transaction. WARNING - Additional information that you need to know about your transaction that you may need to take action on. ERROR - Information about an error that occurred while processing your transaction. FAILURE - FedEx was unable to process your transaction at this time due to a system failure. Please try again later + + + + + Indicates the source of this notification. Combined with the Code it uniquely identifies this notification + + + + + A code that represents this notification. Combined with the Source it uniquely identifies this notification. + + + + + Human-readable text that explains this notification. + + + + + The translated message. The language and locale specified in the ClientDetail. Localization are used to determine the representation. Currently only supported in a TrackReply. + + + + + A collection of name/value pairs that provide specific data to help the client determine the nature of an error (or warning, etc.) witout having to parse the message string. + + + + + + + + + Identifies the type of data contained in Value (e.g. SERVICE_TYPE, PACKAGE_SEQUENCE, etc..). + + + + + The value of the parameter (e.g. PRIORITY_OVERNIGHT, 2, etc..). + + + + + + + Identifies the set of severity values for a Notification. + + + + + + + + + + + + + + + + + + + + Identification for a FedEx operating company (transportation and non-transportation). + + + + + + + + The enumerated packaging type used for this package. + + + + + + + + + + + + + + Tracking number and additional shipment data used to identify a unique shipment for proof of delivery. + + + + + FedEx assigned identifier for a package/shipment. + + + + + The date the package was shipped. + + + + + If the account number used to ship the package is provided in the request the shipper and recipient information is included on the letter or fax. + + + + + FedEx operating company that delivered the package. + + + + + Only country is used for elimination of duplicate tracking numbers. + + + + + + + + + + + + + + The service type of the package/shipment. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + FedEx Signature Proof Of Delivery Fax reply. + + + + + This contains the severity type of the most severe Notification in the Notifications array. + + + + + Information about the request/reply such was the transaction successful or not, and any additional information relevant to the request and/or reply. There may be multiple Notifications in a reply. + + + + + Contains the CustomerTransactionDetail that is echoed back to the caller for matching requests and replies and a Localization element for defining the language/translation used in the reply data. + + + + + Contains the version of the reply being used. + + + + + Confirmation of fax transmission. + + + + + + + FedEx Signature Proof Of Delivery Fax request. + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Contains a free form field that is echoed back in the reply to match requests with replies and data that governs the data payload language/translations. + + + + + The version of the request being used. + + + + + Tracking number and additional shipment data used to identify a unique shipment for proof of delivery. + + + + + Additional customer-supplied text to be added to the body of the letter. + + + + + Contact and address information about the person requesting the fax to be sent. + + + + + Contact and address information, including the fax number, about the person to receive the fax. + + + + + + + Identifies the set of SPOD image types. + + + + + + + + FedEx Signature Proof Of Delivery Letter reply. + + + + + This contains the severity type of the most severe Notification in the Notifications array. + + + + + Information about the request/reply such was the transaction successful or not, and any additional information relevant to the request and/or reply. There may be multiple Notifications in a reply. + + + + + Contains the CustomerTransactionDetail that is echoed back to the caller for matching requests and replies and a Localization element for defining the language/translation used in the reply data. + + + + + Image of letter encoded in Base64 format. + + + + + Image of letter encoded in Base64 format. + + + + + + + FedEx Signature Proof Of Delivery Letter request. + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Contains a free form field that is echoed back in the reply to match requests with replies and data that governs the data payload language/translations. + + + + + The version of the request being used. + + + + + Tracking number and additional shipment data used to identify a unique shipment for proof of delivery. + + + + + Additional customer-supplied text to be added to the body of the letter. + + + + + Identifies the set of SPOD image types. + + + + + If provided this information will be print on the letter. + + + + + + + Each instance of this data type represents a barcode whose content must be represented as ASCII text (i.e. not binary data). + + + + + The kind of barcode data in this instance. + + + + + The data content of this instance. + + + + + + + + + + + + + + + + + The delivery location at the delivered to address. + + + + + + + + + + + + + + + + Detailed tracking information about a particular package. + + + + + To report soft error on an individual track detail. + + + + + The FedEx package identifier. + + + + + + When duplicate tracking numbers exist this data is returned with summary information for each of the duplicates. The summary information is used to determine which of the duplicates the intended tracking number is. This identifier is used on a subsequent track request to retrieve the tracking data for the desired tracking number. + + + + + A code that identifies this type of status. This is the most recent status. + + + + + A human-readable description of this status. + + + + + Used to report the status of a piece of a multiple piece shipment which is no longer traveling with the rest of the packages in the shipment or has not been accounted for. + + + + + Used to convey information such as. 1. FedEx has received information about a package but has not yet taken possession of it. 2. FedEx has handed the package off to a third party for final delivery. 3. The package delivery has been cancelled + + + + + Identifies a FedEx operating company (transportation). + + + + + Identifies operating transportation company that is the specific to the carrier code. + + + + + Specifies the FXO production centre contact and address. + + + + + Other related identifiers for this package such as reference numbers. + + + + + Retained for legacy compatibility only. User/screen friendly description of the Service type (e.g. Priority Overnight). + + + + + Strict representation of the Service type (e.g. PRIORITY_OVERNIGHT). + + + + + The weight of this package. + + + + + Physical dimensions of the package. + + + + + The dimensional weight of the package. + + + + + The weight of the entire shipment. + + + + + Retained for legacy compatibility only. + + + + + Strict representation of the Packaging type (e.g. FEDEX_BOX, YOUR_PACKAGING). + + + + + The sequence number of this package in a shipment. This would be 2 if it was package number 2 of 4. + + + + + The number of packages in this shipment. + + + + + + + The address information for the shipper. + + + + + The address of the FedEx pickup location/facility. + + + + + Estimated package pickup time for shipments that haven't been picked up. + + + + + Time package was shipped/tendered over to FedEx. Time portion will be populated if available, otherwise will be set to midnight. + + + + + The distance from the origin to the destination. Returned for Custom Critical shipments. + + + + + Total distance package still has to travel. Returned for Custom Critical shipments. + + + + + The address this package is to be (or has been) delivered. + + + + + The address of the FedEx delivery location/facility. + + + + + Projected package delivery time based on ship time stamp, service and destination. Not populated if delivery has already occurred. + + + + + The time the package was actually delivered. + + + + + Actual address where package was delivered. Differs from destinationAddress, which indicates where the package was to be delivered; This field tells where delivery actually occurred (next door, at station, etc.) + + + + + Identifies the method of office order delivery. + + + + + Strict text indicating the delivery location at the delivered to address. + + + + + User/screen friendly representation of the DeliveryLocationType (delivery location at the delivered to address). Can be returned in localized text. + + + + + This is either the name of the person that signed for the package or "Signature not requested" or "Signature on file". + + + + + True if signed for by signature image is available. + + + + + The types of email notifications that are available for the package. + + + + + Returned for cargo shipments only when they are currently split across vehicles. + + + + + Indicates redirection eligibility as determined by tracking service, subject to refinement/override by redirect-to-hold service. + + + + + Event information for a tracking number. + + + + + + + FedEx scanning information about a package. + + + + + The time this event occurred. + + + + + Carrier's scan code. Pairs with EventDescription. + + + + + Literal description that pairs with the EventType. + + + + + Further defines the Scan Type code's specific type (e.g., DEX08 business closed). Pairs with StatusExceptionDescription. + + + + + Literal description that pairs with the StatusExceptionCode. + + + + + Address information of the station that is responsible for the scan. + + + + + Indicates where the arrival actually occurred. + + + + + + + The type of track to be performed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + FedEx assigned identifier for a package/shipment. + + + + + When duplicate tracking numbers exist this data is returned with summary information for each of the duplicates. The summary information is used to determine which of the duplicates the intended tracking number is. This identifier is used on a subsequent track request to retrieve the tracking data for the desired tracking number. + + + + + Identification of a FedEx operating company (transportation). + + + + + The date the package was shipped (tendered to FedEx). + + + + + The destination address of this package. Only city, state/province, and country are returned. + + + + + Options available for a tracking notification recipient. + + + + + + + Options available for a tracking notification recipient. + + + + + The types of email notifications available for this recipient. + + + + + + + FedEx Track Notification reply. + + + + + This contains the severity type of the most severe Notification in the Notifications array. + + + + + Information about the request/reply such was the transaction successful or not, and any additional information relevant to the request and/or reply. There may be multiple Notifications in a reply. + + + + + Contains the CustomerTransactionDetail that is echoed back to the caller for matching requests and replies and a Localization element for defining the language/translation used in the reply data. + + + + + Contains the version of the reply being used. + + + + + True if duplicate packages (more than one package with the same tracking number) have been found, the packages array contains information about each duplicate. Use this information to determine which of the tracking numbers is the one you need and resend your request using the tracking number and TrackingNumberUniqueIdentifier for that package. + + + + + True if additional packages remain to be retrieved. + + + + + Value that must be passed in a TrackNotification request to retrieve the next set of packages (when MoreDataAvailable = true). + + + + + Information about the notifications that are available for this tracking number. If there are duplicates the ship date and destination address information is returned for determining which TrackingNumberUniqueIdentifier to use on a subsequent request. + + + + + + + FedEx Track Notification request. + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Contains a free form field that is echoed back in the reply to match requests with replies and data that governs the data payload language/translations + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + The tracking number to which the notifications will be triggered from. + + + + + Indicates whether to return tracking information for all associated packages. + + + + + When the MoreDataAvailable field is true in a TrackNotificationReply the PagingToken must be sent in the subsequent TrackNotificationRequest to retrieve the next page of data. + + + + + Use this field when your original request informs you that there are duplicates of this tracking number. If you get duplicates you will also receive some information about each of the duplicate tracking numbers to enable you to chose one and resend that number along with the TrackingNumberUniqueId to get notifications for that tracking number. + + + + + To narrow the search to a period in time the ShipDateRangeBegin and ShipDateRangeEnd can be used to help eliminate duplicates. + + + + + To narrow the search to a period in time the ShipDateRangeBegin and ShipDateRangeEnd can be used to help eliminate duplicates. + + + + + Included in the email notification identifying the requester of this notification. + + + + + Included in the email notification identifying the requester of this notification. + + + + + Who to send the email notifications to and for which events. The notificationRecipientType and NotifyOnShipment fields are not used in this request. + + + + + + + The type and value of the package identifier that is to be used to retrieve the tracking information for a package. + + + + + The value to be used to retrieve tracking information for a package. + + + + + The type of the Value to be used to retrieve tracking information for a package (e.g. SHIPPER_REFERENCE, PURCHASE_ORDER, TRACKING_NUMBER_OR_DOORTAG, etc..) . + + + + + + + Used to report the status of a piece of a multiple piece shipment which is no longer traveling with the rest of the packages in the shipment or has not been accounted for. + + + + + An identifier for this type of status. + + + + + A human-readable description of this status. + + + + + + + The descriptive data returned from a FedEx package tracking request. + + + + + This contains the severity type of the most severe Notification in the Notifications array. + + + + + Information about the request/reply such was the transaction successful or not, and any additional information relevant to the request and/or reply. There may be multiple Notifications in a reply. + + + + + Contains the CustomerTransactionDetail that is echoed back to the caller for matching requests and replies and a Localization element for defining the language/translation used in the reply data. + + + + + Contains the version of the reply being used. + + + + + True if duplicate packages (more than one package with the same tracking number) have been found, and only limited data will be provided for each one. + + + + + True if additional packages remain to be retrieved. + + + + + Value that must be passed in a TrackNotification request to retrieve the next set of packages (when MoreDataAvailable = true). + + + + + Contains detailed tracking information for the requested packages(s). + + + + + + + The descriptive data sent by a client to track a FedEx package. + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + Descriptive data identifying the client submitting the transaction. + + + + + Contains a free form field that is echoed back in the reply to match requests with replies and data that governs the data payload language/translations. + + + + + The version of the request being used. + + + + + The FedEx operating company (transportation) used for this package's delivery. + + + + + Identifies operating transportation company that is the specific to the carrier code. + + + + + The type and value of the package identifier that is to be used to retrieve the tracking information for a package or group of packages. + + + + + Used to distinguish duplicate FedEx tracking numbers. + + + + + To narrow the search to a period in time the ShipDateRangeBegin and ShipDateRangeEnd can be used to help eliminate duplicates. + + + + + To narrow the search to a period in time the ShipDateRangeBegin and ShipDateRangeEnd can be used to help eliminate duplicates. + + + + + For tracking by references information either the account number or destination postal code and country must be provided. + + + + + For tracking by references information either the account number or destination postal code and country must be provided. + + + + + If false the reply will contain summary/profile data including current status. If true the reply contains profile + detailed scan activity for each package. + + + + + When the MoreData field = true in a TrackReply the PagingToken must be sent in the subsequent TrackRequest to retrieve the next page of data. + + + + + + + + + + + + + Used when a cargo shipment is split across vehicles. This is used to give the status of each part of the shipment. + + + + + The number of pieces in this part. + + + + + The date and time this status began. + + + + + A code that identifies this type of status. + + + + + A human-readable description of this status. + + + + + + + Descriptive data that governs data payload language/translations. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. + + + + + Free form text to be echoed back in the reply. Used to match requests and replies. + + + + + Governs data payload language/translations (contrasted with ClientDetail.localization, which governs Notification.localizedMessage language selection). + + + + + + + The descriptive data for the heaviness of an object. + + + + + Identifies the unit of measure associated with a weight value. + + + + + Identifies the weight value of a package/shipment. + + + + + + + Identifies the collection of units of measure that can be associated with a weight value. + + + + + + + + + Used in authentication of the sender's identity. + + + + + Credential used to authenticate a specific software application. This value is provided by FedEx after registration. + + + + + + + Two part authentication string used for the sender's identity + + + + + Identifying part of authentication credential. This value is provided by FedEx after registration + + + + + Secret part of authentication key. This value is provided by FedEx after registration. + + + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Identifies a system or sub-system which performs an operation. + + + + + Identifies the service business level. + + + + + Identifies the service interface level. + + + + + Identifies the service code level. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git app/code/core/Mage/Usa/sql/usa_setup/mysql4-install-1.6.0.0.php app/code/core/Mage/Usa/sql/usa_setup/mysql4-install-1.6.0.0.php new file mode 100644 index 0000000..8ce1063 --- /dev/null +++ app/code/core/Mage/Usa/sql/usa_setup/mysql4-install-1.6.0.0.php @@ -0,0 +1,26 @@ + array( + 'EUROPEFIRSTINTERNATIONALPRIORITY' => 'EUROPE_FIRST_INTERNATIONAL_PRIORITY', + 'FEDEX1DAYFREIGHT' => 'FEDEX_1_DAY_FREIGHT', + 'FEDEX2DAYFREIGHT' => 'FEDEX_2_DAY_FREIGHT', + 'FEDEX2DAY' => 'FEDEX_2_DAY', + 'FEDEX3DAYFREIGHT' => 'FEDEX_3_DAY_FREIGHT', + 'FEDEXEXPRESSSAVER' => 'FEDEX_EXPRESS_SAVER', + 'FEDEXGROUND' => 'FEDEX_GROUND', + 'FIRSTOVERNIGHT' => 'FIRST_OVERNIGHT', + 'GROUNDHOMEDELIVERY' => 'GROUND_HOME_DELIVERY', + 'INTERNATIONALECONOMY' => 'INTERNATIONAL_ECONOMY', + 'INTERNATIONALECONOMY FREIGHT' => 'INTERNATIONAL_ECONOMY_FREIGHT', + 'INTERNATIONALFIRST' => 'INTERNATIONAL_FIRST', + 'INTERNATIONALGROUND' => 'INTERNATIONAL_GROUND', + 'INTERNATIONALPRIORITY' => 'INTERNATIONAL_PRIORITY', + 'INTERNATIONALPRIORITY FREIGHT' => 'INTERNATIONAL_PRIORITY_FREIGHT', + 'PRIORITYOVERNIGHT' => 'PRIORITY_OVERNIGHT', + 'SMARTPOST' => 'SMART_POST', + 'STANDARDOVERNIGHT' => 'STANDARD_OVERNIGHT', + 'FEDEXFREIGHT' => 'FEDEX_FREIGHT', + 'FEDEXNATIONALFREIGHT' => 'FEDEX_NATIONAL_FREIGHT', + ), + 'dropoff' => array( + 'REGULARPICKUP' => 'REGULAR_PICKUP', + 'REQUESTCOURIER' => 'REQUEST_COURIER', + 'DROPBOX' => 'DROP_BOX', + 'BUSINESSSERVICECENTER' => 'BUSINESS_SERVICE_CENTER', + 'STATION' => 'STATION' + ), + 'packaging' => array( + 'FEDEXENVELOPE' => 'FEDEX_ENVELOPE', + 'FEDEXPAK' => 'FEDEX_PAK', + 'FEDEXBOX' => 'FEDEX_BOX', + 'FEDEXTUBE' => 'FEDEX_TUBE', + 'FEDEX10KGBOX' => 'FEDEX_10KG_BOX', + 'FEDEX25KGBOX' => 'FEDEX_25KG_BOX', + 'YOURPACKAGING' => 'YOUR_PACKAGING' + ), +); + +/* @var $installer Mage_Core_Model_Resource_Setup */ +$installer = $this; +$configDataTable = $installer->getTable('core/config_data'); +$conn = $installer->getConnection(); + +$select = $conn->select() + ->from($configDataTable) + ->where('path IN (?)', + array( + 'carriers/fedex/packaging', + 'carriers/fedex/dropoff', + 'carriers/fedex/free_method', + 'carriers/fedex/allowed_methods' + ) + ); +$mapsOld = $conn->fetchAll($select); +foreach ($mapsOld as $mapOld) { + $mapNew = ''; + if (stripos($mapOld['path'], 'packaging') && isset($codes['packaging'][$mapOld['value']])) { + $mapNew = $codes['packaging'][$mapOld['value']]; + } else if (stripos($mapOld['path'], 'dropoff') && isset($codes['dropoff'][$mapOld['value']])) { + $mapNew = $codes['dropoff'][$mapOld['value']]; + } else if (stripos($mapOld['path'], 'free_method') && isset($codes['method'][$mapOld['value']])) { + $mapNew = $codes['method'][$mapOld['value']]; + } else if (stripos($mapOld['path'], 'allowed_methods')) { + foreach (explode(',', $mapOld['value']) as $shippingMethod) { + if (isset($codes['method'][$shippingMethod])) { + $mapNew[] = $codes['method'][$shippingMethod]; + } else { + $mapNew[] = $shippingMethod; + } + } + $mapNew = implode($mapNew, ','); + } else { + continue; + } + + if (!empty($mapNew) && $mapNew != $mapOld['value']) { + $whereConfigId = $conn->quoteInto('config_id = ?', $mapOld['config_id']); + $conn->update($configDataTable, + array('value' => $mapNew), + $whereConfigId + ); + } +} diff --git app/design/adminhtml/default/default/template/catalog/product/tab/inventory.phtml app/design/adminhtml/default/default/template/catalog/product/tab/inventory.phtml index 14f1477..5b9f631 100644 --- app/design/adminhtml/default/default/template/catalog/product/tab/inventory.phtml +++ app/design/adminhtml/default/default/template/catalog/product/tab/inventory.phtml @@ -107,6 +107,15 @@ __('[GLOBAL]') ?> + + + + + __('[GLOBAL]') ?> + @@ -226,6 +235,22 @@ Event.observe($('inventory_enable_qty_increments'), 'change', applyEnableQtyIncrements); Event.observe($('inventory_use_config_enable_qty_increments'), 'change', applyEnableQtyIncrements); applyEnableQtyIncrements(); + + function applyEnableDecimalDivided() { + $('inventory_is_decimal_divided').up('tr').hide(); + $('inventory_qty_increments').removeClassName('validate-digits').removeClassName('validate-number'); + $('inventory_min_sale_qty').removeClassName('validate-digits').removeClassName('validate-number'); + if ($('inventory_is_qty_decimal').value == 1) { + $('inventory_is_decimal_divided').up('tr').show(); + $('inventory_qty_increments').addClassName('validate-number'); + $('inventory_min_sale_qty').addClassName('validate-number'); + } else { + $('inventory_qty_increments').addClassName('validate-digits'); + $('inventory_min_sale_qty').addClassName('validate-digits'); + } + } + Event.observe($('inventory_is_qty_decimal'), 'change', applyEnableDecimalDivided); + applyEnableDecimalDivided(); //]]> diff --git app/design/adminhtml/default/default/template/system/shipping/ups.phtml app/design/adminhtml/default/default/template/system/shipping/ups.phtml index dc48e83..4603978 100644 --- app/design/adminhtml/default/default/template/system/shipping/ups.phtml +++ app/design/adminhtml/default/default/template/system/shipping/ups.phtml @@ -20,203 +20,176 @@ * * @category design * @package default_default - * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ +/** @var $upsModel Mage_Usa_Model_Shipping_Carrier_Ups */ +$upsModel = Mage::getSingleton('usa/shipping_carrier_ups'); +$orShipArr = $upsModel->getCode('originShipment'); +$defShipArr = $upsModel->getCode('method'); -$orShipArr = Mage::getSingleton('usa/shipping_carrier_ups')->getCode('originShipment'); - -$defShipArr = Mage::getSingleton('usa/shipping_carrier_ups')->getCode('method'); - +/** @var $this Mage_Adminhtml_Block_Template */ $sectionCode = $this->getRequest()->getParam('section'); $websiteCode = $this->getRequest()->getParam('website'); $storeCode = $this->getRequest()->getParam('store'); - -if(!$storeCode && $websiteCode){ +if (!$storeCode && $websiteCode) { + /** @var $web Mage_Core_Model_Website */ $web = Mage::getModel('Mage_Core_Model_Website')->load($websiteCode); - $stroredAllowedMethods = $web->getConfig('carriers/ups/allowed_methods'); - $stroredAllowedMethods = explode(',',$stroredAllowedMethods); - $stroredOriginShipment = $web->getConfig('carriers/ups/origin_shipment'); - $stroredFreeShipment = $web->getConfig('carriers/ups/free_method'); + $storedAllowedMethods = explode(',', $web->getConfig('carriers/ups/allowed_methods')); + $storedOriginShipment = $web->getConfig('carriers/ups/origin_shipment'); + $storedFreeShipment = $web->getConfig('carriers/ups/free_method'); + $storedUpsType = $web->getConfig('carriers/ups/type'); } elseif ($storeCode) { - $stroredAllowedMethods = Mage::getStoreConfig('carriers/ups/allowed_methods',$storeCode); - $stroredAllowedMethods = explode(',',$stroredAllowedMethods); - $stroredOriginShipment = Mage::getStoreConfig('carriers/ups/origin_shipment',$storeCode); - $stroredFreeShipment = Mage::getStoreConfig('carriers/ups/free_method',$storeCode); + $storedAllowedMethods = explode(',', Mage::getStoreConfig('carriers/ups/allowed_methods', $storeCode)); + $storedOriginShipment = Mage::getStoreConfig('carriers/ups/origin_shipment', $storeCode); + $storedFreeShipment = Mage::getStoreConfig('carriers/ups/free_method', $storeCode); + $storedUpsType = Mage::getStoreConfig('carriers/ups/type', $storeCode); } else { - $stroredAllowedMethods = Mage::getStoreConfig('carriers/ups/allowed_methods'); - $stroredAllowedMethods = explode(',',$stroredAllowedMethods); - $stroredOriginShipment = Mage::getStoreConfig('carriers/ups/origin_shipment'); - $stroredFreeShipment = Mage::getStoreConfig('carriers/ups/free_method'); + $storedAllowedMethods = explode(',', Mage::getStoreConfig('carriers/ups/allowed_methods')); + $storedOriginShipment = Mage::getStoreConfig('carriers/ups/origin_shipment'); + $storedFreeShipment = Mage::getStoreConfig('carriers/ups/free_method'); + $storedUpsType = Mage::getStoreConfig('carriers/ups/type'); } ?> diff --git app/design/adminhtml/default/default/template/usa/dhl/unitofmeasure.phtml app/design/adminhtml/default/default/template/usa/dhl/unitofmeasure.phtml new file mode 100644 index 0000000..29ed62f --- /dev/null +++ app/design/adminhtml/default/default/template/usa/dhl/unitofmeasure.phtml @@ -0,0 +1,53 @@ + + + diff --git lib/Varien/Date.php lib/Varien/Date.php index 621e9bb..bac2ed3 100644 --- lib/Varien/Date.php +++ lib/Varien/Date.php @@ -40,6 +40,9 @@ class Varien_Date const DATETIME_INTERNAL_FORMAT = 'yyyy-MM-dd HH:mm:ss'; const DATE_INTERNAL_FORMAT = 'yyyy-MM-dd'; + const DATETIME_PHP_FORMAT = 'Y-m-d H:i:s'; + const DATE_PHP_FORMAT = 'Y-m-d'; + private static $_convertZendToStrftimeDate = array( 'yyyy-MM-ddTHH:mm:ssZZZZ' => '%c', 'EEEE' => '%A', @@ -85,4 +88,16 @@ class Varien_Date } return $value; } + + /** + * Retrieve current date in internal format + * + * @param boolean $withoutTime day only flag + * @return string + */ + public static function now($withoutTime = false) + { + $format = $withoutTime ? self::DATE_PHP_FORMAT : self::DATETIME_PHP_FORMAT; + return date($format); + } } \n\ No newline at end of filediff --git media/dhl/logo.jpg media/dhl/logo.jpg new file mode 100644 index 0000000..4f80976 --- /dev/null +++ media/dhl/logo.jpg @@ -0,0 +1,29 @@ +JFIFHHC  +   $.' ",#(7),01444'9=82<.342C  2!!22222222222222222222222222222222222222222222222222v"E QT!1ARUa"Sq#24Br3$bCE8 +R!1QS2Aaq"#Bb$3r ?&IDǒI%a͡?gQ+q~gc6-Vkm"&ym+Xshg6p "lgL8-VkmD2p[a͡56kbz3muKRoW=݂hMDc2<Ya͡9 XCum,x~΋YVuTya͡9 XCum,x~cSUI.aͣpέ8gVLJ-f>5Tya͡9 XCum,x~cSUI.aͣpέziUI:h?0k1)Jkm VJnZcDXRp 6+Xsh3iclԇDʜYRoԡ𷏐]#?93ZÛFd͔o]J⿰d3"#3;L<׶YU/kaͣ픢 {<>Tj3ic[MXE2" 6+Xsh3icմtZ}JUI.aͣ5k/&V̒|^JZT+mR3l6VkmG]*DdJs%f*3ic\kwV4 .aͣpέ8gVLJ$k1*MU'^+Xshg6i:}OO[a?;ϐl5q8,/ct̯0̯0}A#Q} čZBk!Dw!ΜqnQj35(L48((iIvq`_ 6 1CwՓj#ci{66;䦬7h2Q/Ii\."Q 4RgDC*զٙEk!Y6S{ر#c&v{tT&9%^'11, }ӏAŞJR\:u"4W^!dhyEQp'SZ}VYͷpX9g6g,DDD?./T˵ U>11j?*@. +ϐNW=gMY}?%'JƩaҼ16j;=Hmo%':YOZв&7$)N<[X1YJarCeřRD\gtuK%H"ZWq*hOp' Jĭ~L`X-Zi\.$-1Z.b.nTʽJb3v}T'$3#1΢w"(ٔ\.~6e /΢w+:/9{?!D ]T$OJs]j:}{f#(I%$D+gUg~Bd;3%#_VKh+ϷG.^N\)JyZm4ZVI2E$է`gQW};…Dܷ8\w% bnpQ%1YUNgQW};Ɔ~,CWb@ ~ VuwӼ81YUNňs Kb΢w~,CLX5_E] VuwӼ3bg9*xpb់?!i)T7W̔P#qNKh+u&8Vm +RWd5]F~@Ɲz ;=U_\|gu;0L*Vֵ-p֥(35= VuwӼi`ØZp!`hp@ ~ VuwӼ81YUN6~,CR9`LJ^pڲ|dZ>ZF(R!w)jRLZxt(q'%)V5ɌܕRfLf0"""" kk*B  +v_h궂=Hn9.{(UEB/^ujD&dvU~`?4^cvAڎsUq[ mn 9rs^cvAڎsUq[ mn ag4YyڎsU *T8(7JKIXW}TMħ-${ +])H`IE)kO r=?,̕!eOafyպKYޥ)۫TݫO\8:)!/SYyޯSYyހ-hyaVmqW^ XEx,8BC+ XCum,x~!4Xpa[Kفi+)5KόA)28?ŸHGmS\j?.N, :Oh.[%JVR1\TR?Ey$$v Ӹ_s]qV55)Gb .p6* .plS3icմ M!jh +:VnO*:ut ~䰍%i-jDh +~Ey$έA>[Ψԥ9cv*(.VTQ18\ XCum,x~M!IÄ+ XEJNr RIu7)2ё}/RII$"&M?Ƌ/W.D]) ω9_1nsďyY&֬)WWEy+ܪw\V 2 +FUE"ִX-CE WP WP:uBYɄ.aU#Zq$!3Nf + y +o +E[;GUwEy}YZSKeONЀsO>dr2r\SoYɄ+zL!r?lګ! Gqic^Z a7R\gΣ3@9.7+9ĸܨRi4-{n*ORY +umhQ;Eb +anf!nNVIpɼyug'fUUL!r? ?LYɄ&\Sra Y780hJ_[Mgՙu 8O$o|g$x8Wb6U_B)[WZS|N#kuUWiMښS|N#kuUWiMښS|N#kuU:Ng\c7P$4)hdV[o.>1 v +״ۿt%״Gg ЭU67\nHA>O$qr h;|26>ƚa*2 WJڨZe-zWJLH$fg@fT.1(v+qe6D[$i1.mtz%],^JJ[w^Ewj &i%2u$O. k~ި!#2))o\w^ewj "K-I&ɖ#?1. MaG D@Q 'vt[z /9zOq-;K^Uwao n7A݅4_QZ?=Z:jm(#3%&s'ٳvrrY9^[ @@hR{-JTY@[[}RkV&ܔ5EeI1@ktSezC)I]!62Iq"Q9q(sirRPO[Mwd\Ua=6[Q-k'oW݈RIiʴ5-iY[3W\DD_#1Je dy8m:>b\}jݬZ-MJI4nCq{L2WGj>"R˴̈hg@ٽO&aɔKME jf.UJ<[%{22Q+o3!MVuau\f}#/?YZFTa F2T QGJ?DXS}363)em%*2"_}%nŋӮI *4=~C΀Z2ٳꯍa9Xk2͍7ir\9ͥƨiu+Eܧw5a ǧQbD}>rՖwey*hPhxX˭:R35Z4?6sEIh$%ffw5 L*{zo3g! 8}~6wXkAÅB?R Jg=l6|;5! +~o */[dC!B?RIEq 3@u `&']lwxj~wtϿ |']3az=|'wLlwxaz=>`&']lwxj~wtϿ |0=beﳓ~{W]fjpr6%2 ^RHRI"-n#R];/XP)ӝG}Ex$"è`q}\϶Q +bf1Sxܑ~U軔1Mt'-> +ۈzh;{]Pd{MJǝZlwuޛP@7\2VGgYFZ 9DGy^WiM-PϷj7 ^D\\}C=׭gvQ&6Wk(VAdĵ2ɽLCn]ffvX,A{2 9etjgԴ&>33<=JbRT"YHQ)&wIŜ3..;( 3Nd4\{.Eoǒ⤫>gDgGxK}e-|']# lwxaz=>`&']lwxj~wtϿ |']3az=|'wLlwxaz=>`&']lwxj~wtϿ |']3az=|'wLlwxBM(JL3CM$ R|~ \ No newline at end of file