本文整理汇总了PHP中Mage_Shipping_Model_Rate_Request::getDestRegionId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Shipping_Model_Rate_Request::getDestRegionId方法的具体用法?PHP Mage_Shipping_Model_Rate_Request::getDestRegionId怎么用?PHP Mage_Shipping_Model_Rate_Request::getDestRegionId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Shipping_Model_Rate_Request
的用法示例。
在下文中一共展示了Mage_Shipping_Model_Rate_Request::getDestRegionId方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRate
public function getRate(Mage_Shipping_Model_Rate_Request $request)
{
$read = $this->_getReadAdapter();
$write = $this->_getWriteAdapter();
$select = $read->select()->from($this->getMainTable());
/*
//commented out code since we don't want to get state by using zip code
if (!$request->getDestCountryId() && !$request->getDestRegionId()) {
// assuming that request is coming from shopping cart
// for shipping prices pre-estimation...
// also probably it will be required to move this part to
// Sales/Model/Quote/Address.php !
$selectCountry = $read->select()->from(Mage::getSingleton('core/resource')->getTableName('usa/postcode'), array('country_id', 'region_id'));
$selectCountry->where('postcode=?', $request->getDestPostcode());
$selectCountry->limit(1);
$countryRegion = $read->fetchRow($selectCountry);
$region = $read->quote($countryRegion['region_id']);
$country = $read->quote($countryRegion['country_id']);
} else {
$region = $read->quote($request->getDestRegionId());
$country = $read->quote($request->getDestCountryId());
}
*/
$region = $read->quote($request->getDestRegionId());
$country = $read->quote($request->getDestCountryId());
$zip = $read->quote($request->getDestPostcode());
$select->where("(dest_zip={$zip})\n OR (dest_region_id={$region} AND dest_zip='')\n OR (dest_country_id={$country} AND dest_region_id='0' AND dest_zip='')\n OR (dest_country_id='0' AND dest_region_id='0' AND dest_zip='')");
if (is_array($request->getConditionName())) {
$i = 0;
foreach ($request->getConditionName() as $conditionName) {
if ($i == 0) {
$select->where('condition_name=?', $conditionName);
} else {
$select->orWhere('condition_name=?', $conditionName);
}
$select->where('condition_value<=?', $request->getData($conditionName));
$i++;
}
} else {
$select->where('condition_name=?', $request->getConditionName());
$select->where('condition_value<=?', $request->getData($request->getConditionName()));
}
$select->where('website_id=?', $request->getWebsiteId());
$select->order('condition_value DESC')->limit(1);
$row = $read->fetchRow($select);
return $row;
}
示例2: getShippingRate
/**
* @param Mage_Shipping_Model_Rate_Request $request
* @return false|Mage_Core_Model_Abstract
*/
protected function getShippingRate(Mage_Shipping_Model_Rate_Request $request)
{
$helper = Mage::helper('etrans');
$address = $helper->formatAddress($request->getDestStreet());
if ($request->getDestCity()) {
$city = $request->getDestCity();
} else {
$city = '-';
}
$data = array('calle' => $address['street'], 'numero_puerta' => $address['number'], 'piso' => '', 'dpto_oficina' => '', 'bque_torre' => '', 'cp' => $request->getDestPostcode(), 'localidad' => $city, 'partido' => '', 'provincia' => $this->getRegionName($request->getDestRegionId()), 'email' => 'guest@example.com', 'celular' => '', 'nombre_razon_social' => 'Guest', 'dni_cuit' => '', 'telefono' => '', 'seguro' => $this->getConfigData('insurance'), 'horario_retiro' => $this->getConfigData('pickup_time'), 'horario_entrega' => $this->getConfigData('delivery_time'));
$items = $request->getAllItems();
if ($items) {
$i = 1;
foreach ($items as $item) {
$item_qty = (int) $item->getQty();
$dimensions = $helper->getProductDimensions($item->getProductId());
if ($item_qty > 1) {
$item_number = 1;
while ($item_number <= $item_qty) {
$data['bulto_' . $i] = array('alto' => $dimensions['height'], 'ancho' => $dimensions['width'], 'profundidad' => $dimensions['depth'], 'peso' => $dimensions['weight'], 'valor_declarado' => $dimensions['price']);
$i++;
$item_number++;
}
} else {
$data['bulto_' . $i] = array('alto' => $dimensions['height'], 'ancho' => $dimensions['width'], 'profundidad' => $dimensions['depth'], 'peso' => $dimensions['weight'], 'valor_declarado' => $dimensions['price']);
}
$i++;
}
}
$etrans = new Dc_Etrans_Client($this->getConfigData('api_key'), $this->getConfigData('api_secret'));
$response = $etrans->crear_parametros($data);
if (is_array($response) && !empty($response['response']['response']['Costo'])) {
$rate = Mage::getModel('shipping/rate_result_method');
$rate->setCarrier($this->_code);
$rate->setCarrierTitle($this->getConfigData('title'));
$rate->setMethod('standand');
$rate->setMethodTitle($this->getConfigData('name'));
$rate->setPrice($response['response']['response']['Costo']);
$rate->setCost(0);
return $rate;
} else {
return false;
}
}
示例3: getRate
/**
* Fetch rate from the table for selected shipping address.
*
* @param Mage_Shipping_Model_Rate_Request $request
* @return array
*/
public function getRate(Mage_Shipping_Model_Rate_Request $request)
{
$adapter = $this->_getReadAdapter();
$bind = array(':website_id' => (int) $request->getWebsiteId(), ':country_id' => $request->getDestCountryId(), ':region_id' => (int) $request->getDestRegionId(), ':postcode' => $request->getDestPostcode());
$select = $adapter->select()->from($this->getMainTable())->where('website_id = :website_id')->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'condition_value DESC'))->limit(1);
// Render destination condition
$orWhere = '(' . implode(') OR (', array("dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode", "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''", "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = '*'", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'", "dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = '*'", "dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'")) . ')';
$select->where($orWhere);
// Render condition by condition name
if (is_array($request->getConditionName())) {
$orWhere = array();
$i = 0;
foreach ($request->getConditionName() as $conditionName) {
$bindNameKey = sprintf(':condition_name_%d', $i);
$bindValueKey = sprintf(':condition_value_%d', $i);
$orWhere[] = "(condition_name = {$bindNameKey} AND condition_value <= {$bindValueKey})";
$bind[$bindNameKey] = $conditionName;
$bind[$bindValueKey] = $request->getData($conditionName);
$i++;
}
if ($orWhere) {
$select->where(implode(' OR ', $orWhere));
}
} else {
$bind[':condition_name'] = $request->getConditionName();
$bind[':condition_value'] = $request->getData($request->getConditionName());
$select->where('condition_name = :condition_name');
$select->where('condition_value <= :condition_value');
}
$result = $adapter->fetchRow($select, $bind);
// Normalize destination zip code
if ($result && $result['dest_zip'] == '*') {
$result['dest_zip'] = '';
}
return $result;
}
示例4: getRate
/**
* Return table rate array or false by rate request
*
* @param Mage_Shipping_Model_Rate_Request $request
* @return array|false
*/
public function getRate(Mage_Shipping_Model_Rate_Request $request)
{
$adapter = $this->_getReadAdapter();
$bind = array(':website_id' => (int) $request->getWebsiteId(), ':country_id' => $request->getDestCountryId(), ':region_id' => $request->getDestRegionId());
$select = $adapter->select()->from($this->getMainTable())->where('website_id=:website_id')->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC'))->limit(1);
// render destination condition
$orWhere = '(' . implode(') OR (', array("dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip like '{$request->getDestPostcode()}%'", "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip like '{$request->getDestPostcode()}%'", "dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = ''")) . ')';
$select->where($orWhere);
// render condition by condition name
if (is_array($request->getConditionName())) {
$orWhere = array();
$i = 0;
foreach ($request->getConditionName() as $conditionName) {
$bindNameKey = sprintf(':condition_name_%d', $i);
$bindValueKey = sprintf(':condition_value_%d', $i);
$orWhere[] = "(condition_name = {$bindNameKey} AND condition_value <= {$bindValueKey})";
$bind[$bindNameKey] = $conditionName;
$bind[$bindValueKey] = $request->getData($conditionName);
$i++;
}
if ($orWhere) {
$select->where(implode(' OR ', $orWhere));
}
} else {
$bind[':condition_name'] = $request->getConditionName();
$bind[':condition_value'] = $request->getData($request->getConditionName());
$select->where('condition_name = :condition_name');
$select->where('condition_value <= :condition_value');
}
//if( $_SERVER['REMOTE_ADDR'] == '193.108.122.187') { mage::D($bind ); mage::d($select->__toString()); }
return $adapter->fetchRow($select, $bind);
}
示例5: getRate
public function getRate(Mage_Shipping_Model_Rate_Request $request)
{
$read = $this->_getReadAdapter();
$postcode = $request->getDestPostcode();
$table = $this->getMainTable();
$storeId = $request->getStoreId();
$insuranceStep = (double) Mage::getStoreConfig('carriers/eparcel/insurance_step', $storeId);
$insuranceCostPerStep = (double) Mage::getStoreConfig('carriers/eparcel/insurance_cost_per_step', $storeId);
$signatureRequired = Mage::getStoreConfigFlag('carriers/eparcel/signature_required', $storeId);
if ($signatureRequired) {
$signatureCost = (double) Mage::getStoreConfig('carriers/eparcel/signature_cost', $storeId);
} else {
$signatureCost = 0;
}
for ($j = 0; $j < 5; $j++) {
$select = $read->select()->from($table);
// Support for Multi Warehouse Extension.
if ($request->getWarehouseId() > 0) {
$select->where('stock_id = ?', $request->getWarehouseId());
}
switch ($j) {
case 0:
$select->where($read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()) . $read->quoteInto(" AND dest_region_id=? ", $request->getDestRegionId()) . $read->quoteInto(" AND dest_zip=?) ", $postcode));
break;
case 1:
$select->where($read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()) . $read->quoteInto(" AND dest_region_id=? AND dest_zip='0000') ", $request->getDestRegionId()));
break;
case 2:
$select->where($read->quoteInto(" (dest_country_id=? AND dest_region_id='0' AND dest_zip='0000') ", $request->getDestCountryId()));
break;
case 3:
$select->where($read->quoteInto(" (dest_country_id=? AND dest_region_id='0' ", $request->getDestCountryId()) . $read->quoteInto(" AND dest_zip=?) ", $postcode));
break;
case 4:
$select->where(" (dest_country_id='0' AND dest_region_id='0' AND dest_zip='0000')");
break;
}
if (is_array($request->getConditionName())) {
$i = 0;
foreach ($request->getConditionName() as $conditionName) {
if ($i == 0) {
$select->where('condition_name=?', $conditionName);
} else {
$select->orWhere('condition_name=?', $conditionName);
}
$select->where('condition_from_value<=?', $request->getData($conditionName));
$select->where('condition_to_value>=?', $request->getData($conditionName));
$i++;
}
} else {
$select->where('condition_name=?', $request->getConditionName());
$select->where('condition_from_value<=?', $request->getData($request->getConditionName()));
$select->where('condition_to_value>=?', $request->getData($request->getConditionName()));
}
$select->where('website_id=?', $request->getWebsiteId());
$select->order('dest_country_id DESC');
$select->order('dest_region_id DESC');
$select->order('dest_zip DESC');
$select->order('condition_from_value DESC');
// pdo has an issue. we cannot use bind
$newdata = array();
$row = $read->fetchAll($select);
if (!empty($row) && $j < 5) {
// have found a result or found nothing and at end of list!
foreach ($row as $data) {
try {
$price = (double) $data['price'];
// add per-Kg cost
$conditionValue = (double) $request->getData($request->getConditionName());
$price += (double) $data['price_per_kg'] * $conditionValue;
// add signature cost
$price += $signatureCost;
// add version without insurance
$data['price'] = (string) $price;
$newdata[] = $data;
if (Mage::getStoreConfig('carriers/eparcel/insurance_enable', $storeId)) {
// add version with insurance
// work out how many insurance 'steps' we have
$steps = ceil($request->getPackageValue() / $insuranceStep);
// add on number of 'steps' multiplied by the
// insurance cost per step
$insuranceCost = $insuranceCostPerStep * $steps;
$price += $insuranceCost;
$data['price'] = (string) $price;
$data['delivery_type'] .= " with TransitCover";
$newdata[] = $data;
}
} catch (Exception $e) {
Mage::log($e->getMessage());
}
}
break;
}
}
return $newdata;
}
示例6: getNewRate
public function getNewRate(Mage_Shipping_Model_Rate_Request $request, $zipRangeSet = 0)
{
$read = $this->_getReadAdapter();
$write = $this->_getWriteAdapter();
$postcode = $request->getDestPostcode();
$table = Mage::getSingleton('core/resource')->getTableName('matrixrate_shipping/matrixrate');
if ($zipRangeSet && is_numeric($postcode)) {
# Want to search for postcodes within a range
$zipSearchString = ' AND ' . $postcode . ' BETWEEN dest_zip AND dest_zip_to )';
} else {
$zipSearchString = $read->quoteInto(" AND ? LIKE dest_zip )", $postcode);
}
for ($j = 0; $j < 10; $j++) {
$select = $read->select()->from($table);
switch ($j) {
case 0:
$select->where($read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()) . $read->quoteInto(" AND dest_region_id=? ", $request->getDestRegionId()) . $read->quoteInto(" AND STRCMP(LOWER(dest_city),LOWER(?)) = 0 ", $request->getDestCity()) . $zipSearchString);
break;
case 1:
$select->where($read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()) . $read->quoteInto(" AND dest_region_id=? AND dest_city=''", $request->getDestRegionId()) . $zipSearchString);
break;
case 2:
$select->where($read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()) . $read->quoteInto(" AND dest_region_id=? ", $request->getDestRegionId()) . $read->quoteInto(" AND STRCMP(LOWER(dest_city),LOWER(?)) = 0 AND dest_zip='')", $request->getDestCity()));
break;
case 3:
$select->where($read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()) . $read->quoteInto(" AND STRCMP(LOWER(dest_city),LOWER(?)) = 0 AND dest_region_id='0'", $request->getDestCity()) . $zipSearchString);
break;
case 4:
$select->where($read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()) . $read->quoteInto(" AND STRCMP(LOWER(dest_city),LOWER(?)) = 0 AND dest_region_id='0' AND dest_zip='') ", $request->getDestCity()));
break;
case 5:
$select->where($read->quoteInto(" (dest_country_id=? AND dest_region_id='0' AND dest_city='' ", $request->getDestCountryId()) . $zipSearchString);
break;
case 6:
$select->where($read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()) . $read->quoteInto(" AND dest_region_id=? AND dest_city='' AND dest_zip='') ", $request->getDestRegionId()));
break;
case 7:
$select->where($read->quoteInto(" (dest_country_id=? AND dest_region_id='0' AND dest_city='' AND dest_zip='') ", $request->getDestCountryId()));
break;
case 8:
$select->where(" (dest_country_id='0' AND dest_region_id='0'" . $zipSearchString);
break;
case 9:
$select->where(" (dest_country_id='0' AND dest_region_id='0' AND dest_zip='')");
break;
}
if (is_array($request->getMRConditionName())) {
$i = 0;
foreach ($request->getMRConditionName() as $conditionName) {
if ($i == 0) {
$select->where('condition_name=?', $conditionName);
} else {
$select->orWhere('condition_name=?', $conditionName);
}
$select->where('condition_from_value<=?', $request->getData($conditionName));
$i++;
}
} else {
$select->where('condition_name=?', $request->getMRConditionName());
$select->where('condition_from_value<=?', $request->getData($request->getMRConditionName()));
$select->where('condition_to_value>=?', $request->getData($request->getMRConditionName()));
}
$select->where('website_id=?', $request->getWebsiteId());
if ($filter = $request->getData('filter')) {
$select->where('filter IN (?)', $filter);
}
$select->order('dest_country_id DESC');
$select->order('dest_region_id DESC');
$select->order('dest_zip DESC');
$select->order('condition_from_value DESC');
/*
pdo has an issue. we cannot use bind
*/
$newdata = array();
$row = $read->fetchAll($select);
if (!empty($row)) {
// have found a result or found nothing and at end of list!
foreach ($row as $data) {
$newdata[] = $data;
}
break;
}
}
return $newdata;
}
示例7: getRate
/**
* Return table rate array or false by rate request
*
* @param Mage_Shipping_Model_Rate_Request $request
*
* @return array|false
*/
public function getRate(Mage_Shipping_Model_Rate_Request $request)
{
$adapter = $this->_getReadAdapter();
$bind = array(':website_id' => (int) $request->getWebsiteId(), ':country_id' => $request->getDestCountryId(), ':region_id' => $request->getDestRegionId(), ':postcode' => $request->getDestPostcode(), ':weight' => (double) $request->getPackageWeight(), ':price' => (double) $request->getData('zitec_table_price'));
$select = $adapter->select()->from($this->getMainTable())->where('website_id=:website_id')->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'method DESC', 'price_vs_dest DESC', 'weight DESC'));
// render destination condition
$orWhere = '(' . implode(') OR (', array("dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode", "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode", "dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = ''")) . ')';
$select->where($orWhere);
$select->where('((weight <= :weight and price_vs_dest = 0) or (weight <= :price and price_vs_dest = 1))');
$rates = $adapter->fetchAll($select, $bind);
if (empty($rates)) {
$rates = Mage::getModel('zitec_dpd/config_source_service')->getDefaultShipingRates();
}
return $rates;
}
示例8: collectRates
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->getConfigFlag('active')) {
return false;
}
if ($request->getDestCountry()) {
$destCountry = $request->getDestCountry();
}
$zip = substr($request->getDestPostcode(), 0, 8);
//echo "zip=(".$zip.")";
//$request->getDestCity() - ???????? ?????: "???????????"
//$request->getDestCountryId(); //RU
//echo '<br>****destCountry='.$destCountry,'<br>****getDestCity='.$request->getDestCity().' getDestRegionId='.$request->getDestRegionId();
//return $this->PrintDebug( '<br>****destCountry='.$request->getDestCountryId() ); //????? ?????????? ??????????
$county_edost = array(1960 => 'AU', 1961 => 'AT', 1962 => 'AZ', 1963 => 'AL', 1964 => 'DZ', 1965 => 'AS', 1966 => 'AI', 1968 => 'AO', 1969 => 'AD', 1970 => 'AG', 1971 => 'AN', 1972 => 'AR', 1973 => 'AM', 1974 => 'AW', 1975 => 'AF', 1976 => 'BS', 1977 => 'BD', 1978 => 'BB', 1979 => 'BH', 1980 => 'BY', 1981 => 'BZ', 1982 => 'BE', 1983 => 'BJ', 1984 => 'BM', 1985 => 'BG', 1986 => 'BO', 1988 => 'BA', 1989 => 'BW', 1990 => 'BR', 1991 => 'BN', 1992 => 'BF', 1993 => 'BI', 1994 => 'BT', 1995 => 'WF', 1996 => 'VU', 1997 => 'GB', 1998 => 'HU', 1999 => 'VE', 2000 => 'VG', 2001 => 'VI', 2002 => 'TL', 2003 => 'VN', 2004 => 'GA', 2005 => 'HT', 2006 => 'GY', 2007 => 'GM', 2008 => 'GH', 2009 => 'GP', 2010 => 'GT', 2011 => 'GN', 2012 => 'GQ', 2013 => 'GW', 2014 => 'DE', 2016 => 'GI', 2017 => 'HN', 2018 => 'HK', 2019 => 'GD', 2020 => 'GL', 2021 => 'GR', 2022 => 'GE', 2023 => 'GU', 2024 => 'DK', 2026 => 'DJ', 2027 => 'DM', 2028 => 'DO', 2029 => 'EG', 2030 => 'ZM', 2031 => 'CV', 2032 => 'ZW', 2033 => 'IL', 2034 => 'IN', 2035 => 'ID', 2036 => 'JO', 2037 => 'IQ', 2038 => 'IR', 2039 => 'IE', 2040 => 'IS', 2041 => 'ES', 2042 => 'IT', 2043 => 'YE', 2044 => 'KZ', 2045 => 'KY', 2046 => 'KH', 2047 => 'CM', 2048 => 'CA', 2049 => 'EQ', 2050 => 'QA', 2051 => 'KE', 2052 => 'CY', 2053 => 'KI', 2054 => 'CN', 2055 => 'CO', 2056 => 'KM', 2057 => 'CG', 2058 => 'CD', 2059 => 'KP', 2060 => 'KR', 2062 => 'CR', 2063 => 'CI', 2064 => 'CU', 2065 => 'KW', 2066 => 'CK', 2067 => 'KG', 2069 => 'LA', 2070 => 'LV', 2071 => 'LS', 2072 => 'LR', 2073 => 'LB', 2074 => 'LY', 2075 => 'LT', 2076 => 'LI', 2077 => 'LU', 2078 => 'MU', 2079 => 'MR', 2080 => 'MG', 2081 => 'YT', 2082 => 'MO', 2083 => 'MK', 2084 => 'MW', 2085 => 'MY', 2086 => 'ML', 2087 => 'MV', 2088 => 'MT', 2089 => 'MA', 2090 => 'MQ', 2091 => 'MH', 2092 => 'MX', 2093 => 'FM', 2094 => 'MZ', 2095 => 'MD', 2096 => 'MC', 2097 => 'MN', 2098 => 'MS', 2099 => 'MM', 2100 => 'NA', 2101 => 'NR', 2102 => 'KN', 2103 => 'NP', 2104 => 'NE', 2105 => 'NG', 2106 => 'NL', 2107 => 'NI', 2108 => 'NU', 2109 => 'NZ', 2110 => 'NC', 2111 => 'NO', 2112 => 'AE', 2113 => 'OM', 2114 => 'PK', 2115 => 'PW', 2116 => 'PA', 2117 => 'PG', 2118 => 'PY', 2119 => 'PE', 2120 => 'PL', 2121 => 'PT', 2122 => 'PR', 2123 => 'RE', 2124 => 'RW', 2125 => 'RO', 2126 => 'MP', 2127 => 'SV', 2128 => 'WS', 2129 => 'SM', 2130 => 'ST', 2131 => 'SA', 2132 => 'SZ', 2134 => 'SC', 2136 => 'SN', 2137 => 'VC', 2138 => 'KN', 2139 => 'KN', 2140 => 'LC', 2145 => 'SG', 2146 => 'SY', 2147 => 'SK', 2148 => 'SI', 2149 => 'SB', 2150 => 'SO', 2152 => 'SD', 2153 => 'SR', 2154 => 'US', 2155 => 'SL', 2156 => 'TJ', 2157 => 'TH', 2158 => 'PF', 2159 => 'TW', 2160 => 'TZ', 2161 => 'TG', 2162 => 'TO', 2163 => 'TT', 2164 => 'TV', 2165 => 'TN', 2166 => 'TM', 2167 => 'TC', 2168 => 'TR', 2169 => 'UG', 2170 => 'UZ', 2171 => 'UA', 2172 => 'UY', 2174 => 'FO', 2175 => 'FJ', 2176 => 'PH', 2177 => 'FI', 2178 => 'FK', 2179 => 'FR', 2180 => 'GF', 2181 => 'PF', 2182 => 'HR', 2183 => 'CF', 2184 => 'TD', 2186 => 'CZ', 2187 => 'CL', 2188 => 'CH', 2189 => 'SE', 2191 => 'LK', 2192 => 'EC', 2193 => 'ER', 2194 => 'EE', 2195 => 'ET', 2196 => 'ZA', 2197 => 'JM', 2198 => 'JP', 0 => 'RU');
$country = array_search($request->getDestCountryId(), $county_edost);
//echo '<br>****getDestCountryId='.$request->getDestCountryId().' - edost_id='.$country; //RU
//echo '<br>****getDestRegionId='.$request->getDestRegionId(); //??? ?????? ??? ??????? edost
$edost_calc = new edost_class();
//?????? ? id ????????
$edost_calc->edost_id = $this->getConfigData('id');
$edost_calc->edost_pswd = $this->getConfigData('password');
$edost_calc->SetSiteUTF();
$strah = $request->getPackageValue();
//??????
$host = trim(strtolower($this->getConfigData('gateway_url')));
if (substr($host, 0, 7) == "http://") {
$host = substr($host, 7, 100);
}
//if (substr($host,0,4) == "www.") $host = substr($host,4,100);
if ($host == '') {
$edost_calc->adr = EDOST_ADDR;
} else {
$edost_calc->adr = "http://" . $host . "/" . EDOST_PAGE;
}
//?????????? ?????? ? ????? ???????
$country_hide = false;
if ($country_hide) {
$country = 0;
}
//?.?. ?? ????????? ??????????? US, ???? ?? ??????? ??????
if (!$country) {
$country = 0;
}
//RU
if (isset($_SESSION['city_for_cart'])) {
$to_city = Mage::getModel('directory/region')->load($_SESSION['city_for_cart'])->getCode();
//????? ??? ??????
$city_code = Mage::getModel('directory/region')->load($_SESSION['city_for_cart'])->getCdekCode();
} else {
if ($country == 0) {
$to_city = Mage::getModel('directory/region')->load($request->getDestRegionId())->getCode();
//????? ??? ??????
$city_code = Mage::getModel('directory/region')->load($request->getDestRegionId())->getCdekCode();
} else {
$to_city = $country;
$city_code = '0';
}
}
/* if($country==0)
$to_city = Mage::getModel('directory/region')->load( $request->getDestRegionId() )->getCode(); //????? ??? ??????
else
$to_city = $country;
*/
//$weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
/* $packageParams = $request->getPackageParams();
$height = $packageParams->getHeight();
$width = $packageParams->getWidth();
$length = $packageParams->getLength();
echo "<br>*** height=$height, width=$width, length=$length";
*/
//echo $cart = Mage::helper('checkout/cart')->getCart()->getItemsCount();
/* Mage::getSingleton('core/session', array('name'=>'frontend'));
$cart = Mage::getModel('checkout/cart');
$ids = $cart->getProductIds();
print_r($ids);
foreach ($ids as $i=>$productId) {
echo "<br>id=$id ($i)";
$product = Mage::getModel('catalog/product')->load($productId);
$attributes = $product->getAttributes();
foreach ($attributes as $attribute) {
$attributeCode = $attribute->getAttributeCode();
if ($attributeCode == 'length') {
$value = $attribute->getFrontend()->getValue($product);
echo $attributeCode . '-' . '-' . $value;
}
}
}
*/
$session = Mage::getSingleton('checkout/session');
$output = "<br>";
$weight = 0;
$size_in = null;
$weight_zero = false;
$k = 0;
if (isset($_SESSION['product_for_cart'])) {
$products_in_session[0] = $_SESSION['product_for_cart'];
} else {
//.........这里部分代码省略.........
示例9: getMethods
/**
* Collect rates for this shipping method based on information in $request
*
* @param Mage_Shipping_Model_Rate_Request $data
* @return Mage_Shipping_Model_Rate_Result
*/
public function getMethods(Mage_Shipping_Model_Rate_Request $request, $my_code = false)
{
$dest_country = $request->getDestCountryId();
$dest_region = $request->getDestRegionId();
$package_value = $request->getPackageValue();
$shipping_price = 0;
// Mage::log($request->debug(), null, 'test.log');
// Mage::log($exception_regions, null, 'test.log');
// Mage::log($dest_country, null, 'test.log');
// Mage::log($dest_region, null, 'test.log');
$i = 1;
$max_price = 0;
$items = array();
$cart_products_price_reduction = 0;
if ($_items = $request->getAllItems()) {
foreach ($_items as $item) {
// if($item->getProductType() != 'simple') continue;
// Mage::log($i++, null, 'test.log');
// Mage::log($item->debug(), null, 'test.log');
if ($parent_item_id = $item->getParentItemId()) {
continue;
// $items[$item_id]['free_shipping'] = $item->getMaxFreeShipping();
// $items[$item_id]['primary_shipping'] = $item->getMaxPrimaryShip();
// $items[$item_id]['secondary_shipping'] = $item->getMaxSecondaryShip();
} elseif ($item->getProductType() == 'cartproduct') {
continue;
}
$p = Mage::getModel('catalog/product')->load($item->getProductId());
$item_id = $item->getItemId();
$items[$item_id]['price'] = $item->getPrice();
$items[$item_id]['sku'] = $item->getSku();
$items[$item_id]['qty'] = $item->getQty();
$items[$item_id]['free_shipping'] = $p->getMaxFreeShipping();
$items[$item_id]['primary_shipping'] = $p->getMaxPrimaryShip();
$items[$item_id]['secondary_shipping'] = $p->getMaxSecondaryShip();
if ($item->getPrice() >= $max_price) {
$max_price = $item->getPrice();
$max_id = $item_id;
}
// $p = Mage::getModel('catalog/product')->load($item->getProductId());
// $tmp_price = (float) $p->getFreightShipTotal();
// Mage::log($p->getData(), null, 'test.log');
// Mage::log($item->debug(), null, 'test.log');
}
}
foreach ($items as $item_id => $item) {
$qty = (int) $item['qty'];
$max_done = false;
for ($i = 1; $i <= $qty; $i++) {
if (!$max_done && $item_id == $max_id) {
$shipping_price += $item['free_shipping'] ? 0 : (double) $item['primary_shipping'];
$max_done = true;
continue;
}
$shipping_price += $item['free_shipping'] ? 0 : (double) $item['secondary_shipping'];
}
}
// 199.5 + 105 + 210
if ($dest_country == 'CA') {
$item_percent = (double) Mage::getStoreConfig('carriers/maxshipping/canadian_percent') / 100;
$duty = (double) Mage::getStoreConfig('carriers/maxshipping/canadian_duty') / 100;
$tax = (double) Mage::getStoreConfig('carriers/maxshipping/canadian_tax') / 100;
$shipping_price += $request->getPackagePhysicalValue() * $item_percent;
$shipping_price += $request->getPackagePhysicalValue() * $duty;
$shipping_price += $request->getPackagePhysicalValue() * $tax;
$shipping_price += (double) Mage::getStoreConfig('carriers/maxshipping/canadian_border_fee');
}
$methods = array();
// $label = Mage::getStoreConfig('carriers/maxshipping/title');
$method = Mage::getModel('shipping/rate_result_method');
$method->setMethodTitle('');
$method->setCarrier($this->_code);
$method->setMethod('standard');
$method->setPrice($shipping_price);
$methods[] = $method;
// Mage::log($methods, null, 'methods.log');
return $methods;
}
示例10: collectRates
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->getConfigFlag('active')) {
return false;
}
if ($request->getDestCountry()) {
$destCountry = $request->getDestCountry();
}
$zip = substr($request->getDestPostcode(), 0, 8);
//echo "zip=(".$zip.")";
//$request->getDestCity() - Ââåäåíûé Ãîðîä: "Âëàäèâîñòîê"
//$request->getDestCountryId(); //RU
//echo '<br>****destCountry='.$destCountry,'<br>****getDestCity='.$request->getDestCity().' getDestRegionId='.$request->getDestRegionId();
//return $this->PrintDebug( '<br>****destCountry='.$request->getDestCountryId() ); //Âûâîä îòëàäî÷íîé èíôîðìàöèè
$county_edost = array(1960 => 'AU', 1961 => 'AT', 1962 => 'AZ', 1963 => 'AL', 1964 => 'DZ', 1965 => 'AS', 1966 => 'AI', 1968 => 'AO', 1969 => 'AD', 1970 => 'AG', 1971 => 'AN', 1972 => 'AR', 1973 => 'AM', 1974 => 'AW', 1975 => 'AF', 1976 => 'BS', 1977 => 'BD', 1978 => 'BB', 1979 => 'BH', 1980 => 'BY', 1981 => 'BZ', 1982 => 'BE', 1983 => 'BJ', 1984 => 'BM', 1985 => 'BG', 1986 => 'BO', 1988 => 'BA', 1989 => 'BW', 1990 => 'BR', 1991 => 'BN', 1992 => 'BF', 1993 => 'BI', 1994 => 'BT', 1995 => 'WF', 1996 => 'VU', 1997 => 'GB', 1998 => 'HU', 1999 => 'VE', 2000 => 'VG', 2001 => 'VI', 2002 => 'TL', 2003 => 'VN', 2004 => 'GA', 2005 => 'HT', 2006 => 'GY', 2007 => 'GM', 2008 => 'GH', 2009 => 'GP', 2010 => 'GT', 2011 => 'GN', 2012 => 'GQ', 2013 => 'GW', 2014 => 'DE', 2016 => 'GI', 2017 => 'HN', 2018 => 'HK', 2019 => 'GD', 2020 => 'GL', 2021 => 'GR', 2022 => 'GE', 2023 => 'GU', 2024 => 'DK', 2026 => 'DJ', 2027 => 'DM', 2028 => 'DO', 2029 => 'EG', 2030 => 'ZM', 2031 => 'CV', 2032 => 'ZW', 2033 => 'IL', 2034 => 'IN', 2035 => 'ID', 2036 => 'JO', 2037 => 'IQ', 2038 => 'IR', 2039 => 'IE', 2040 => 'IS', 2041 => 'ES', 2042 => 'IT', 2043 => 'YE', 2044 => 'KZ', 2045 => 'KY', 2046 => 'KH', 2047 => 'CM', 2048 => 'CA', 2049 => 'EQ', 2050 => 'QA', 2051 => 'KE', 2052 => 'CY', 2053 => 'KI', 2054 => 'CN', 2055 => 'CO', 2056 => 'KM', 2057 => 'CG', 2058 => 'CD', 2059 => 'KP', 2060 => 'KR', 2062 => 'CR', 2063 => 'CI', 2064 => 'CU', 2065 => 'KW', 2066 => 'CK', 2067 => 'KG', 2069 => 'LA', 2070 => 'LV', 2071 => 'LS', 2072 => 'LR', 2073 => 'LB', 2074 => 'LY', 2075 => 'LT', 2076 => 'LI', 2077 => 'LU', 2078 => 'MU', 2079 => 'MR', 2080 => 'MG', 2081 => 'YT', 2082 => 'MO', 2083 => 'MK', 2084 => 'MW', 2085 => 'MY', 2086 => 'ML', 2087 => 'MV', 2088 => 'MT', 2089 => 'MA', 2090 => 'MQ', 2091 => 'MH', 2092 => 'MX', 2093 => 'FM', 2094 => 'MZ', 2095 => 'MD', 2096 => 'MC', 2097 => 'MN', 2098 => 'MS', 2099 => 'MM', 2100 => 'NA', 2101 => 'NR', 2102 => 'KN', 2103 => 'NP', 2104 => 'NE', 2105 => 'NG', 2106 => 'NL', 2107 => 'NI', 2108 => 'NU', 2109 => 'NZ', 2110 => 'NC', 2111 => 'NO', 2112 => 'AE', 2113 => 'OM', 2114 => 'PK', 2115 => 'PW', 2116 => 'PA', 2117 => 'PG', 2118 => 'PY', 2119 => 'PE', 2120 => 'PL', 2121 => 'PT', 2122 => 'PR', 2123 => 'RE', 2124 => 'RW', 2125 => 'RO', 2126 => 'MP', 2127 => 'SV', 2128 => 'WS', 2129 => 'SM', 2130 => 'ST', 2131 => 'SA', 2132 => 'SZ', 2134 => 'SC', 2136 => 'SN', 2137 => 'VC', 2138 => 'KN', 2139 => 'KN', 2140 => 'LC', 2145 => 'SG', 2146 => 'SY', 2147 => 'SK', 2148 => 'SI', 2149 => 'SB', 2150 => 'SO', 2152 => 'SD', 2153 => 'SR', 2154 => 'US', 2155 => 'SL', 2156 => 'TJ', 2157 => 'TH', 2158 => 'PF', 2159 => 'TW', 2160 => 'TZ', 2161 => 'TG', 2162 => 'TO', 2163 => 'TT', 2164 => 'TV', 2165 => 'TN', 2166 => 'TM', 2167 => 'TC', 2168 => 'TR', 2169 => 'UG', 2170 => 'UZ', 2171 => 'UA', 2172 => 'UY', 2174 => 'FO', 2175 => 'FJ', 2176 => 'PH', 2177 => 'FI', 2178 => 'FK', 2179 => 'FR', 2180 => 'GF', 2181 => 'PF', 2182 => 'HR', 2183 => 'CF', 2184 => 'TD', 2186 => 'CZ', 2187 => 'CL', 2188 => 'CH', 2189 => 'SE', 2191 => 'LK', 2192 => 'EC', 2193 => 'ER', 2194 => 'EE', 2195 => 'ET', 2196 => 'ZA', 2197 => 'JM', 2198 => 'JP', 0 => 'RU');
$country = array_search($request->getDestCountryId(), $county_edost);
//echo '<br>****getDestCountryId='.$request->getDestCountryId().' - edost_id='.$country; //RU
//echo '<br>****getDestRegionId='.$request->getDestRegionId(); //êîä ãîðîäà èëè ðåãèîíà edost
$edost_calc = new edost_class();
//ïàðîëü è id ìàãàçèíà
$edost_calc->edost_id = $this->getConfigData('id');
$edost_calc->edost_pswd = $this->getConfigData('password');
$edost_calc->SetSiteUTF();
$strah = $request->getPackageValue();
//îöåíêà
$host = trim(strtolower($this->getConfigData('gateway_url')));
if (substr($host, 0, 7) == "http://") {
$host = substr($host, 7, 100);
}
//if (substr($host,0,4) == "www.") $host = substr($host,4,100);
if ($host == '') {
$edost_calc->adr = EDOST_ADDR;
} else {
$edost_calc->adr = "http://" . $host . "/" . EDOST_PAGE;
}
//îïðåäåëÿåì ñòðàíó è ãîðîä êëèåíòà
$country_hide = false;
if ($country_hide) {
$country = 0;
}
//ò.ê. ïî óìîë÷àíèþ ïðèñâàèâàåò US, åñëè íå âûáðàíà ñòðàíà
if (!$country) {
$country = 0;
}
//RU
if (isset($_SESSION['city_for_cart'])) {
$to_city = Mage::getModel('directory/region')->load($_SESSION['city_for_cart'])->getCode();
//ãîðîä èëè ðåãèîí
$city_code = Mage::getModel('directory/region')->load($_SESSION['city_for_cart'])->getCdekCode();
} else {
if ($country == 0) {
$to_city = Mage::getModel('directory/region')->load($request->getDestRegionId())->getCode();
//ãîðîä èëè ðåãèîí
$city_code = Mage::getModel('directory/region')->load($request->getDestRegionId())->getCdekCode();
} else {
$to_city = $country;
$city_code = '0';
}
}
/* if($country==0)
$to_city = Mage::getModel('directory/region')->load( $request->getDestRegionId() )->getCode(); //ãîðîä èëè ðåãèîí
else
$to_city = $country;
*/
//$weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
/* $packageParams = $request->getPackageParams();
$height = $packageParams->getHeight();
$width = $packageParams->getWidth();
$length = $packageParams->getLength();
echo "<br>*** height=$height, width=$width, length=$length";
*/
//echo $cart = Mage::helper('checkout/cart')->getCart()->getItemsCount();
/* Mage::getSingleton('core/session', array('name'=>'frontend'));
$cart = Mage::getModel('checkout/cart');
$ids = $cart->getProductIds();
print_r($ids);
foreach ($ids as $i=>$productId) {
echo "<br>id=$id ($i)";
$product = Mage::getModel('catalog/product')->load($productId);
$attributes = $product->getAttributes();
foreach ($attributes as $attribute) {
$attributeCode = $attribute->getAttributeCode();
if ($attributeCode == 'length') {
$value = $attribute->getFrontend()->getValue($product);
echo $attributeCode . '-' . '-' . $value;
}
}
}
*/
$session = Mage::getSingleton('checkout/session');
$output = "<br>";
$weight = 0;
$size_in = null;
$weight_zero = false;
$k = 0;
if (isset($_SESSION['product_for_cart'])) {
$products_in_session[0] = $_SESSION['product_for_cart'];
} else {
//.........这里部分代码省略.........
示例11: _getProductionShipmentFields
private function _getProductionShipmentFields(Mage_Shipping_Model_Rate_Request $mgrequest)
{
$regionId = $mgrequest->getRegionId();
$region = Mage::getModel('directory/region')->load($regionId);
$request->Shipment->SenderInformation->Address->Name = "Aaron Summer";
//$request->Shipment->SenderInformation->Address->StreetNumber = "1234";
$request->Shipment->SenderInformation->Address->StreetName = $mgrequest->getStreet();
$request->Shipment->SenderInformation->Address->City = $mgrequest->getCity();
$request->Shipment->SenderInformation->Address->Province = $region->getCode();
$request->Shipment->SenderInformation->Address->Country = $mgrequest->getCountryId();
$request->Shipment->SenderInformation->Address->PostalCode = $mgrequest->getPostcode();
$request->Shipment->SenderInformation->Address->PhoneNumber->CountryCode = "1";
$request->Shipment->SenderInformation->Address->PhoneNumber->AreaCode = "905";
$request->Shipment->SenderInformation->Address->PhoneNumber->Phone = substr("123456789", -7);
//Populate the Desination Information
$request->Shipment->ReceiverInformation->Address->Name = "Aaron Summer";
$request->Shipment->ReceiverInformation->Address->StreetName = $mgrequest->getDestStreet();
$request->Shipment->ReceiverInformation->Address->City = $mgrequest->getDestCity();
$regionId = $mgrequest->getDestRegionId();
$region = Mage::getModel('directory/region')->load($regionId);
$request->Shipment->ReceiverInformation->Address->Province = $region->getCode();
$request->Shipment->ReceiverInformation->Address->Country = $mgrequest->getDestCountryId();
$request->Shipment->ReceiverInformation->Address->PostalCode = $mgrequest->getDestPostcode();
$request->Shipment->ReceiverInformation->Address->PhoneNumber->CountryCode = "1";
$request->Shipment->ReceiverInformation->Address->PhoneNumber->AreaCode = "604";
$request->Shipment->ReceiverInformation->Address->PhoneNumber->Phone = substr("123456789", -7);
//Future Dated Shipments - YYYY-MM-DD format
$request->Shipment->ShipmentDate = Mage::getModel('core/date')->date('Y-m-d');
//Populate the Package Information
$request->Shipment->PackageInformation->TotalWeight->Value = $mgrequest->getPackageWeight();
$request->Shipment->PackageInformation->TotalWeight->WeightUnit = "lb";
$request->Shipment->PackageInformation->TotalPieces = $mgrequest->getPackageQty();
$request->Shipment->PackageInformation->ServiceID = "PurolatorExpress";
//Populate the Payment Information
$request->Shipment->PaymentInformation->PaymentType = "Sender";
$request->Shipment->PaymentInformation->BillingAccountNumber = $this->BILLING_ACCOUNT;
$request->Shipment->PaymentInformation->RegisteredAccountNumber = $this->REGISTERED_ACCOUNT;
//Populate the Pickup Information
$request->Shipment->PickupInformation->PickupType = "DropOff";
$request->ShowAlternativeServicesIndicator = "true";
//OriginSignatureNotRequired
$request->Shipment->PackageInformation->OptionsInformation->Options->OptionIDValuePair->ID = "OriginSignatureNotRequired";
$request->Shipment->PackageInformation->OptionsInformation->Options->OptionIDValuePair->Value = "true";
return $request;
}
示例12: collectRates
/**
* @param Mage_Shipping_Model_Rate_Request $request
* @return Mage_Shipping_Model_Rate_Result
*/
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->_isCarrierAvailable()) {
return false;
}
/** @var Mage_Directory_Model_Region $storeRegion */
// $storeRegion = Mage::getModel('directory/region');
// $storeRegion->load(Mage::getStoreConfig('shipping/origin/region_id'));
$country_hide = false;
if ($country_hide) {
$country = 0;
}
if (!$country) {
$country = 0;
}
$county_edost = array(1960 => 'AU', 1961 => 'AT', 1962 => 'AZ', 1963 => 'AL', 1964 => 'DZ', 1965 => 'AS', 1966 => 'AI', 1968 => 'AO', 1969 => 'AD', 1970 => 'AG', 1971 => 'AN', 1972 => 'AR', 1973 => 'AM', 1974 => 'AW', 1975 => 'AF', 1976 => 'BS', 1977 => 'BD', 1978 => 'BB', 1979 => 'BH', 1980 => 'BY', 1981 => 'BZ', 1982 => 'BE', 1983 => 'BJ', 1984 => 'BM', 1985 => 'BG', 1986 => 'BO', 1988 => 'BA', 1989 => 'BW', 1990 => 'BR', 1991 => 'BN', 1992 => 'BF', 1993 => 'BI', 1994 => 'BT', 1995 => 'WF', 1996 => 'VU', 1997 => 'GB', 1998 => 'HU', 1999 => 'VE', 2000 => 'VG', 2001 => 'VI', 2002 => 'TL', 2003 => 'VN', 2004 => 'GA', 2005 => 'HT', 2006 => 'GY', 2007 => 'GM', 2008 => 'GH', 2009 => 'GP', 2010 => 'GT', 2011 => 'GN', 2012 => 'GQ', 2013 => 'GW', 2014 => 'DE', 2016 => 'GI', 2017 => 'HN', 2018 => 'HK', 2019 => 'GD', 2020 => 'GL', 2021 => 'GR', 2022 => 'GE', 2023 => 'GU', 2024 => 'DK', 2026 => 'DJ', 2027 => 'DM', 2028 => 'DO', 2029 => 'EG', 2030 => 'ZM', 2031 => 'CV', 2032 => 'ZW', 2033 => 'IL', 2034 => 'IN', 2035 => 'ID', 2036 => 'JO', 2037 => 'IQ', 2038 => 'IR', 2039 => 'IE', 2040 => 'IS', 2041 => 'ES', 2042 => 'IT', 2043 => 'YE', 2044 => 'KZ', 2045 => 'KY', 2046 => 'KH', 2047 => 'CM', 2048 => 'CA', 2049 => 'EQ', 2050 => 'QA', 2051 => 'KE', 2052 => 'CY', 2053 => 'KI', 2054 => 'CN', 2055 => 'CO', 2056 => 'KM', 2057 => 'CG', 2058 => 'CD', 2059 => 'KP', 2060 => 'KR', 2062 => 'CR', 2063 => 'CI', 2064 => 'CU', 2065 => 'KW', 2066 => 'CK', 2067 => 'KG', 2069 => 'LA', 2070 => 'LV', 2071 => 'LS', 2072 => 'LR', 2073 => 'LB', 2074 => 'LY', 2075 => 'LT', 2076 => 'LI', 2077 => 'LU', 2078 => 'MU', 2079 => 'MR', 2080 => 'MG', 2081 => 'YT', 2082 => 'MO', 2083 => 'MK', 2084 => 'MW', 2085 => 'MY', 2086 => 'ML', 2087 => 'MV', 2088 => 'MT', 2089 => 'MA', 2090 => 'MQ', 2091 => 'MH', 2092 => 'MX', 2093 => 'FM', 2094 => 'MZ', 2095 => 'MD', 2096 => 'MC', 2097 => 'MN', 2098 => 'MS', 2099 => 'MM', 2100 => 'NA', 2101 => 'NR', 2102 => 'KN', 2103 => 'NP', 2104 => 'NE', 2105 => 'NG', 2106 => 'NL', 2107 => 'NI', 2108 => 'NU', 2109 => 'NZ', 2110 => 'NC', 2111 => 'NO', 2112 => 'AE', 2113 => 'OM', 2114 => 'PK', 2115 => 'PW', 2116 => 'PA', 2117 => 'PG', 2118 => 'PY', 2119 => 'PE', 2120 => 'PL', 2121 => 'PT', 2122 => 'PR', 2123 => 'RE', 2124 => 'RW', 2125 => 'RO', 2126 => 'MP', 2127 => 'SV', 2128 => 'WS', 2129 => 'SM', 2130 => 'ST', 2131 => 'SA', 2132 => 'SZ', 2134 => 'SC', 2136 => 'SN', 2137 => 'VC', 2138 => 'KN', 2139 => 'KN', 2140 => 'LC', 2145 => 'SG', 2146 => 'SY', 2147 => 'SK', 2148 => 'SI', 2149 => 'SB', 2150 => 'SO', 2152 => 'SD', 2153 => 'SR', 2154 => 'US', 2155 => 'SL', 2156 => 'TJ', 2157 => 'TH', 2158 => 'PF', 2159 => 'TW', 2160 => 'TZ', 2161 => 'TG', 2162 => 'TO', 2163 => 'TT', 2164 => 'TV', 2165 => 'TN', 2166 => 'TM', 2167 => 'TC', 2168 => 'TR', 2169 => 'UG', 2170 => 'UZ', 2171 => 'UA', 2172 => 'UY', 2174 => 'FO', 2175 => 'FJ', 2176 => 'PH', 2177 => 'FI', 2178 => 'FK', 2179 => 'FR', 2180 => 'GF', 2181 => 'PF', 2182 => 'HR', 2183 => 'CF', 2184 => 'TD', 2186 => 'CZ', 2187 => 'CL', 2188 => 'CH', 2189 => 'SE', 2191 => 'LK', 2192 => 'EC', 2193 => 'ER', 2194 => 'EE', 2195 => 'ET', 2196 => 'ZA', 2197 => 'JM', 2198 => 'JP', 0 => 'RU');
$country = array_search($request->getDestCountryId(), $county_edost);
if (isset($_SESSION['city_for_cart'])) {
$to_city = Mage::getModel('directory/region')->load($_SESSION['city_for_cart'])->getCode();
$city_code = Mage::getModel('directory/region')->load($_SESSION['city_for_cart'])->getEmsCode();
} else {
if ($country == 0) {
$to_city = Mage::getModel('directory/region')->load($request->getDestRegionId())->getCode();
$city_code = Mage::getModel('directory/region')->load($request->getDestRegionId())->getEmsCode();
} else {
$to_city = $country;
$city_code = '0';
}
}
// $emsFrom = $this->_getEmsLocation($storeRegion->getId(), $storeRegion->getCode());
// $emsTo = $this->_getEmsLocation($request->getDestRegionId(), $request->getDestRegionCode());
$emsFrom = 'region--rostovskaja-oblast';
$emsTo = 'region--' . $city_code;
$packageWeight = $request->getPackageWeight();
if (!$emsFrom || !$emsTo) {
return false;
}
$emsWeightInfo = $this->getApi()->makeRequest(array('method' => Ch_Ems_Model_Api_Ru::REST_METHOD_GET_MAX_WEIGHT, 'from' => $emsFrom, 'to' => $emsTo));
if ($packageWeight > $emsWeightInfo['max_weight']) {
return false;
}
/** @var $result Mage_Shipping_Model_Rate_Result */
$result = Mage::getModel('shipping/rate_result');
$emsResponse = $this->getApi()->makeRequest(array('method' => Ch_Ems_Model_Api_Ru::REST_METHOD_CALCULATE, 'from' => $emsFrom, 'to' => $emsTo, 'weight' => $packageWeight));
/** @var $method Mage_Shipping_Model_Rate_Result_Method */
$method = Mage::getModel('shipping/rate_result_method');
$method->addData(array('carrier' => $this->_code, 'carrier_title' => $this->getConfigData('name'), 'method' => 'default', 'method_title' => Mage::helper('ch_ems')->__('Delivery %d - %d day(s)', $emsResponse['term']['min'], $emsResponse['term']['max']), 'price' => (double) $emsResponse['price'], 'cost' => (double) $emsResponse['price']));
$result->append($method);
return $result;
}