Version Notes
Completed
Download this release
Release Info
| Developer | OMS |
| Extension | OMS_Global_Freight_Estimator |
| Version | 2.0.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.2 to 2.0.0
- app/code/local/OMS/Shippingimport/Helper/Data.php +66 -0
- app/code/local/OMS/Shippingimport/Model/Alternatemethods.php +15 -0
- app/code/local/OMS/Shippingimport/Model/Carrier/Localdelivery.php +98 -10
- app/code/local/OMS/Shippingimport/Model/Carrier/Tablerate.php +192 -0
- app/code/local/OMS/Shippingimport/Model/Shipping.php +510 -0
- app/code/local/OMS/Shippingimport/etc/adminhtml.xml +1 -1
- app/code/local/OMS/Shippingimport/etc/config.xml +9 -0
- app/code/local/OMS/Shippingimport/etc/system.xml +131 -4
- package.xml +4 -4
app/code/local/OMS/Shippingimport/Helper/Data.php
CHANGED
|
@@ -2,6 +2,72 @@
|
|
| 2 |
|
| 3 |
class OMS_Shippingimport_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
}
|
| 7 |
|
| 2 |
|
| 3 |
class OMS_Shippingimport_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
{
|
| 5 |
+
public function sendEmail($data)
|
| 6 |
+
{
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
$email_arr = array();
|
| 10 |
+
$email_arr['host'] =
|
| 11 |
+
Mage::getStoreConfig('webservice/email_settings/hostname',Mage::app()->getStore());
|
| 12 |
+
|
| 13 |
+
$email_arr['username'] =
|
| 14 |
+
Mage::getStoreConfig('webservice/email_settings/username',Mage::app()->getStore());
|
| 15 |
+
|
| 16 |
+
$email_arr['password'] =
|
| 17 |
+
Mage::getStoreConfig('webservice/email_settings/password',Mage::app()->getStore());
|
| 18 |
+
|
| 19 |
+
$email_arr['port'] =
|
| 20 |
+
Mage::getStoreConfig('webservice/email_settings/port',Mage::app()->getStore());
|
| 21 |
+
|
| 22 |
+
$senders =array();
|
| 23 |
+
$send_to= Mage::getStoreConfig('webservice/email_settings/send_to',Mage::app()->getStore());
|
| 24 |
+
|
| 25 |
+
$senders=explode(',',$send_to);
|
| 26 |
+
|
| 27 |
+
$email_arr['store_name'] =
|
| 28 |
+
Mage::getStoreConfig('webservice/email_settings/from_name',Mage::app()->getStore());
|
| 29 |
+
|
| 30 |
+
$email_arr['store_email'] =
|
| 31 |
+
Mage::getStoreConfig('webservice/email_settings/from_email',Mage::app()->getStore());
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
/*Send email*/
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
$settings = array(
|
| 42 |
+
'port' => $email_arr['port'],
|
| 43 |
+
'auth' => 'login',
|
| 44 |
+
'username' => $email_arr['username'],
|
| 45 |
+
'password' => $email_arr['password']
|
| 46 |
+
);
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
$transport = new Zend_Mail_Transport_Smtp($email_arr['host'], $settings);
|
| 50 |
+
$email_from = $email_arr['store_email'];
|
| 51 |
+
$name_from = $email_arr['store_name'];
|
| 52 |
+
$email_to = "muhammad.mubashir@OMS.com";
|
| 53 |
+
$name_to = "Mubashir Qayyum";
|
| 54 |
+
$Body = '<p>Dear OMS Support Team,</p><p>We have recieved a new exception:</p><p>Exception Details:<br/><b>'.$data['exception'].'<b></p>';
|
| 55 |
+
$mail = new Zend_Mail ();
|
| 56 |
+
|
| 57 |
+
$mail->setReplyTo($email_from, $name_from);
|
| 58 |
+
$mail->setFrom ($email_from, $name_from);
|
| 59 |
+
foreach($senders as $send)
|
| 60 |
+
{
|
| 61 |
+
$mail->addTo ($send, '');
|
| 62 |
+
}
|
| 63 |
+
$mail->setSubject ('OMS Global Freight Estimator -'.$email_arr['storename']."- Error");
|
| 64 |
+
$mail->setBodyHtml($Body);
|
| 65 |
+
|
| 66 |
+
$mail->send($transport);
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
|
| 72 |
}
|
| 73 |
|
app/code/local/OMS/Shippingimport/Model/Alternatemethods.php
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class OMS_Shippingimport_Model_Alternatemethods
|
| 3 |
+
{
|
| 4 |
+
public function toOptionArray()
|
| 5 |
+
{
|
| 6 |
+
|
| 7 |
+
return array(
|
| 8 |
+
array('value' => 'tablerates', 'label'=>Mage::helper('adminhtml')->__('Use Failsafe Table Rates')),
|
| 9 |
+
array('value' => 'flatrates', 'label'=>Mage::helper('adminhtml')->__('Use Failsafe Flat Rates'))
|
| 10 |
+
|
| 11 |
+
);
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
}
|
| 15 |
+
|
app/code/local/OMS/Shippingimport/Model/Carrier/Localdelivery.php
CHANGED
|
@@ -40,6 +40,7 @@ class OMS_Shippingimport_Model_Carrier_Localdelivery extends Mage_Shipping_Model
|
|
| 40 |
$username=Mage::getStoreConfig('webservice/webservice_group/webservice_username',Mage::app()->getStore());
|
| 41 |
$password=Mage::getStoreConfig('webservice/webservice_group/webservice_password',Mage::app()->getStore());
|
| 42 |
$allowedMethods=Mage::getStoreConfig('carriers/customshiping/allowedmethods',Mage::app()->getStore());
|
|
|
|
| 43 |
$allMethods=Mage::getModel("shippingimport/import")->getAllMethods();
|
| 44 |
$methods=array();
|
| 45 |
foreach($allMethods as $method)
|
|
@@ -86,7 +87,12 @@ class OMS_Shippingimport_Model_Carrier_Localdelivery extends Mage_Shipping_Model
|
|
| 86 |
$allowedMethodsArr=split(",",$allowedMethods);
|
| 87 |
|
| 88 |
$importModel= Mage::getModel('shippingimport/import');
|
| 89 |
-
$result = Mage::getModel('shipping/rate_result');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
$client = new SoapClient($url, array('trace' => TRUE));
|
| 92 |
|
|
@@ -241,10 +247,18 @@ class OMS_Shippingimport_Model_Carrier_Localdelivery extends Mage_Shipping_Model
|
|
| 241 |
try
|
| 242 |
{
|
| 243 |
$rateresult=$result1->EstimateFreightResult->EstimateFreight->RateReplyDetails;
|
|
|
|
| 244 |
}
|
| 245 |
catch(Exception $e)
|
| 246 |
{
|
| 247 |
-
Mage::getSingleton('core/session')->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
}
|
| 249 |
/*echo "<pre/>";
|
| 250 |
print_r($methods);
|
|
@@ -252,8 +266,9 @@ echo "<br/>";
|
|
| 252 |
print_r($rateresult);
|
| 253 |
exit;*/
|
| 254 |
if(!empty($rateresult))
|
| 255 |
-
{
|
| 256 |
$config_methods="";
|
|
|
|
| 257 |
foreach($rateresult as $rate)
|
| 258 |
{
|
| 259 |
// echo $rate->ServiceType;
|
|
@@ -271,7 +286,15 @@ exit;*/
|
|
| 271 |
}
|
| 272 |
catch(Exception $e)
|
| 273 |
{
|
| 274 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
}
|
| 276 |
}
|
| 277 |
|
|
@@ -279,7 +302,7 @@ exit;*/
|
|
| 279 |
{
|
| 280 |
$method = Mage::getModel('shipping/rate_result_method');
|
| 281 |
$method->setCarrier($this->_code);
|
| 282 |
-
$method->setCarrierTitle($
|
| 283 |
$method->setMethod($rate->ServiceType);
|
| 284 |
$method->setMethodTitle($rate->ServiceType);
|
| 285 |
$method->setCost($rate->TotalCharge->Amount);
|
|
@@ -306,18 +329,35 @@ exit;*/
|
|
| 306 |
}
|
| 307 |
}
|
| 308 |
}
|
| 309 |
-
|
| 310 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 311 |
|
| 312 |
|
| 313 |
-
|
| 314 |
|
| 315 |
|
| 316 |
}
|
| 317 |
catch(Exception $e)
|
| 318 |
{
|
| 319 |
-
|
| 320 |
-
exit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
}
|
| 322 |
|
| 323 |
|
|
@@ -335,6 +375,54 @@ exit;*/
|
|
| 335 |
return array('customshiping'=>$this->getConfigData('name'));
|
| 336 |
}
|
| 337 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
public function _getISO3Code($szISO2Code)
|
| 339 |
{
|
| 340 |
$boFound = false;
|
| 40 |
$username=Mage::getStoreConfig('webservice/webservice_group/webservice_username',Mage::app()->getStore());
|
| 41 |
$password=Mage::getStoreConfig('webservice/webservice_group/webservice_password',Mage::app()->getStore());
|
| 42 |
$allowedMethods=Mage::getStoreConfig('carriers/customshiping/allowedmethods',Mage::app()->getStore());
|
| 43 |
+
$shipping_title = Mage::getStoreConfig('carriers/customshiping/title',Mage::app()->getStore());
|
| 44 |
$allMethods=Mage::getModel("shippingimport/import")->getAllMethods();
|
| 45 |
$methods=array();
|
| 46 |
foreach($allMethods as $method)
|
| 87 |
$allowedMethodsArr=split(",",$allowedMethods);
|
| 88 |
|
| 89 |
$importModel= Mage::getModel('shippingimport/import');
|
| 90 |
+
$result = Mage::getModel('shipping/rate_result');
|
| 91 |
+
$result->reset();
|
| 92 |
+
/* $methods = get_class_methods($result);
|
| 93 |
+
echo "<pre/>";
|
| 94 |
+
print_r($methods);
|
| 95 |
+
exit;*/
|
| 96 |
|
| 97 |
$client = new SoapClient($url, array('trace' => TRUE));
|
| 98 |
|
| 247 |
try
|
| 248 |
{
|
| 249 |
$rateresult=$result1->EstimateFreightResult->EstimateFreight->RateReplyDetails;
|
| 250 |
+
|
| 251 |
}
|
| 252 |
catch(Exception $e)
|
| 253 |
{
|
| 254 |
+
Mage::getSingleton('core/session')->setData('Webservice',0);
|
| 255 |
+
if($debug=="true")
|
| 256 |
+
{
|
| 257 |
+
Mage::log("SOAP Error:", null, 'OMS_Shipping.log');
|
| 258 |
+
Mage::log($result1->EstimateFreightResult->WSMessage, null, 'OMS_Shipping.log');
|
| 259 |
+
}
|
| 260 |
+
$data['exception'] = $result1->EstimateFreightResult->WSMessage;
|
| 261 |
+
Mage::helper('Shippingimport')->sendEmail($data);
|
| 262 |
}
|
| 263 |
/*echo "<pre/>";
|
| 264 |
print_r($methods);
|
| 266 |
print_r($rateresult);
|
| 267 |
exit;*/
|
| 268 |
if(!empty($rateresult))
|
| 269 |
+
{
|
| 270 |
$config_methods="";
|
| 271 |
+
Mage::getSingleton('core/session')->setData('Webservice',1);
|
| 272 |
foreach($rateresult as $rate)
|
| 273 |
{
|
| 274 |
// echo $rate->ServiceType;
|
| 286 |
}
|
| 287 |
catch(Exception $e)
|
| 288 |
{
|
| 289 |
+
// echo $e->getMessage();
|
| 290 |
+
if($debug=="true")
|
| 291 |
+
{
|
| 292 |
+
Mage::log("Code Error:", null, 'OMS_Shipping.log');
|
| 293 |
+
Mage::log($e->getMessage(), null, 'OMS_Shipping.log');
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
$data['exception'] = $e->getMessage();
|
| 297 |
+
Mage::helper('Shippingimport')->sendEmail($data);
|
| 298 |
}
|
| 299 |
}
|
| 300 |
|
| 302 |
{
|
| 303 |
$method = Mage::getModel('shipping/rate_result_method');
|
| 304 |
$method->setCarrier($this->_code);
|
| 305 |
+
$method->setCarrierTitle($shipping_title);
|
| 306 |
$method->setMethod($rate->ServiceType);
|
| 307 |
$method->setMethodTitle($rate->ServiceType);
|
| 308 |
$method->setCost($rate->TotalCharge->Amount);
|
| 329 |
}
|
| 330 |
}
|
| 331 |
}
|
| 332 |
+
|
| 333 |
+
}
|
| 334 |
+
}
|
| 335 |
+
else /*Enhancement: Add the Failsafe rates. Updated on 11/10/2012*/
|
| 336 |
+
{
|
| 337 |
+
Mage::getSingleton('core/session')->setData('Webservice',0);
|
| 338 |
+
$result = $this->failSafeRates($_iso3countrycode,$OriginCountry);
|
| 339 |
+
|
| 340 |
+
}
|
| 341 |
|
| 342 |
|
| 343 |
+
|
| 344 |
|
| 345 |
|
| 346 |
}
|
| 347 |
catch(Exception $e)
|
| 348 |
{
|
| 349 |
+
// echo $e->getMessage();
|
| 350 |
+
//exit;
|
| 351 |
+
Mage::getSingleton('core/session')->setData('Webservice',0);
|
| 352 |
+
$result = $this->failSafeRates($_iso3countrycode,$OriginCountry);
|
| 353 |
+
if($debug=="true")
|
| 354 |
+
{
|
| 355 |
+
Mage::log("Code Error:", null, 'OMS_Shipping.log');
|
| 356 |
+
Mage::log($e->getMessage(), null, 'OMS_Shipping.log');
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
$data['exception'] = $e->getMessage();
|
| 360 |
+
Mage::helper('Shippingimport')->sendEmail($data);
|
| 361 |
}
|
| 362 |
|
| 363 |
|
| 375 |
return array('customshiping'=>$this->getConfigData('name'));
|
| 376 |
}
|
| 377 |
|
| 378 |
+
public function failSafeRates($destination_country,$origin_country)
|
| 379 |
+
{
|
| 380 |
+
|
| 381 |
+
$result = Mage::getModel('shipping/rate_result');
|
| 382 |
+
//$result->reset();
|
| 383 |
+
|
| 384 |
+
$alternatemethod =
|
| 385 |
+
Mage::getStoreConfig('webservice/webservice_group/webservice_alternate',Mage::app()->getStore());
|
| 386 |
+
|
| 387 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
| 388 |
+
|
| 389 |
+
$method->setCarrier($this->_code);
|
| 390 |
+
|
| 391 |
+
$method->setCarrierTitle($this->_code);
|
| 392 |
+
|
| 393 |
+
if($alternatemethod=="flatrates")
|
| 394 |
+
{
|
| 395 |
+
$domestic_rate =
|
| 396 |
+
Mage::getStoreConfig('carriers/customshiping/domestic_fail_safe_rate',Mage::app()->getStore());
|
| 397 |
+
|
| 398 |
+
|
| 399 |
+
$international_rate =
|
| 400 |
+
Mage::getStoreConfig('carriers/customshiping/international_fail_safe_rate',Mage::app()->getStore());
|
| 401 |
+
if($origin_country==$destination_country)
|
| 402 |
+
{
|
| 403 |
+
|
| 404 |
+
$method->setMethod("Domestic Rate");
|
| 405 |
+
$method->setMethodTitle("Domestic Rate");
|
| 406 |
+
$method->setCost($domestic_rate);
|
| 407 |
+
$method->setPrice($domestic_rate);
|
| 408 |
+
$result->append($method);
|
| 409 |
+
|
| 410 |
+
}
|
| 411 |
+
else
|
| 412 |
+
{
|
| 413 |
+
|
| 414 |
+
$method->setMethod("International Rate");
|
| 415 |
+
$method->setMethodTitle("International Rate");
|
| 416 |
+
$method->setCost($international_rate);
|
| 417 |
+
$method->setPrice($international_rate);
|
| 418 |
+
$result->append($method);
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
return $result;
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
public function _getISO3Code($szISO2Code)
|
| 427 |
{
|
| 428 |
$boFound = false;
|
app/code/local/OMS/Shippingimport/Model/Carrier/Tablerate.php
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Shipping
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class OMS_Shippingimport_Model_Carrier_Tablerate
|
| 29 |
+
extends Mage_Shipping_Model_Carrier_Abstract
|
| 30 |
+
implements Mage_Shipping_Model_Carrier_Interface
|
| 31 |
+
{
|
| 32 |
+
|
| 33 |
+
protected $_code = 'tablerate';
|
| 34 |
+
protected $_isFixed = true;
|
| 35 |
+
protected $_default_condition_name = 'package_weight';
|
| 36 |
+
|
| 37 |
+
protected $_conditionNames = array();
|
| 38 |
+
|
| 39 |
+
public function __construct()
|
| 40 |
+
{
|
| 41 |
+
parent::__construct();
|
| 42 |
+
foreach ($this->getCode('condition_name') as $k=>$v) {
|
| 43 |
+
$this->_conditionNames[] = $k;
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* Enter description here...
|
| 49 |
+
*
|
| 50 |
+
* @param Mage_Shipping_Model_Rate_Request $data
|
| 51 |
+
* @return Mage_Shipping_Model_Rate_Result
|
| 52 |
+
*/
|
| 53 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
| 54 |
+
{
|
| 55 |
+
$show=Mage::getSingleton('core/session')->getData('Webservice');
|
| 56 |
+
$alternatemethod =
|
| 57 |
+
Mage::getStoreConfig('webservice/webservice_group/webservice_alternate',Mage::app()->getStore());
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
if ( $alternatemethod=="flatrates" || $show){
|
| 61 |
+
return false;
|
| 62 |
+
}
|
| 63 |
+
//Mage::getSingleton('core/session')->setData('Webservice','0');
|
| 64 |
+
|
| 65 |
+
// exclude Virtual products price from Package value if pre-configured
|
| 66 |
+
if (!$this->getConfigFlag('include_virtual_price') && $request->getAllItems()) {
|
| 67 |
+
foreach ($request->getAllItems() as $item) {
|
| 68 |
+
if ($item->getParentItem()) {
|
| 69 |
+
continue;
|
| 70 |
+
}
|
| 71 |
+
if ($item->getHasChildren() && $item->isShipSeparately()) {
|
| 72 |
+
foreach ($item->getChildren() as $child) {
|
| 73 |
+
if ($child->getProduct()->isVirtual()) {
|
| 74 |
+
$request->setPackageValue($request->getPackageValue() - $child->getBaseRowTotal());
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
} elseif ($item->getProduct()->isVirtual()) {
|
| 78 |
+
$request->setPackageValue($request->getPackageValue() - $item->getBaseRowTotal());
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
// Free shipping by qty
|
| 84 |
+
$freeQty = 0;
|
| 85 |
+
if ($request->getAllItems()) {
|
| 86 |
+
foreach ($request->getAllItems() as $item) {
|
| 87 |
+
if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
|
| 88 |
+
continue;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
if ($item->getHasChildren() && $item->isShipSeparately()) {
|
| 92 |
+
foreach ($item->getChildren() as $child) {
|
| 93 |
+
if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
|
| 94 |
+
$freeQty += $item->getQty() * ($child->getQty() - (is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0));
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
} elseif ($item->getFreeShipping()) {
|
| 98 |
+
$freeQty += ($item->getQty() - (is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0));
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
if (!$request->getConditionName()) {
|
| 104 |
+
$request->setConditionName($this->getConfigData('condition_name') ? $this->getConfigData('condition_name') : $this->_default_condition_name);
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
// Package weight and qty free shipping
|
| 108 |
+
$oldWeight = $request->getPackageWeight();
|
| 109 |
+
$oldQty = $request->getPackageQty();
|
| 110 |
+
|
| 111 |
+
$request->setPackageWeight($request->getFreeMethodWeight());
|
| 112 |
+
$request->setPackageQty($oldQty - $freeQty);
|
| 113 |
+
|
| 114 |
+
$result = Mage::getModel('shipping/rate_result');
|
| 115 |
+
$rate = $this->getRate($request);
|
| 116 |
+
|
| 117 |
+
$request->setPackageWeight($oldWeight);
|
| 118 |
+
$request->setPackageQty($oldQty);
|
| 119 |
+
|
| 120 |
+
if (!empty($rate) && $rate['price'] >= 0) {
|
| 121 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
| 122 |
+
|
| 123 |
+
$method->setCarrier('tablerate');
|
| 124 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
| 125 |
+
|
| 126 |
+
$method->setMethod('bestway');
|
| 127 |
+
$method->setMethodTitle($this->getConfigData('name'));
|
| 128 |
+
|
| 129 |
+
if ($request->getFreeShipping() === true || ($request->getPackageQty() == $freeQty)) {
|
| 130 |
+
$shippingPrice = 0;
|
| 131 |
+
} else {
|
| 132 |
+
$shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
$method->setPrice($shippingPrice);
|
| 136 |
+
$method->setCost($rate['cost']);
|
| 137 |
+
|
| 138 |
+
$result->append($method);
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
return $result;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
public function getRate(Mage_Shipping_Model_Rate_Request $request)
|
| 145 |
+
{
|
| 146 |
+
return Mage::getResourceModel('shipping/carrier_tablerate')->getRate($request);
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
public function getCode($type, $code='')
|
| 150 |
+
{
|
| 151 |
+
$codes = array(
|
| 152 |
+
|
| 153 |
+
'condition_name'=>array(
|
| 154 |
+
'package_weight' => Mage::helper('shipping')->__('Weight vs. Destination'),
|
| 155 |
+
'package_value' => Mage::helper('shipping')->__('Price vs. Destination'),
|
| 156 |
+
'package_qty' => Mage::helper('shipping')->__('# of Items vs. Destination'),
|
| 157 |
+
),
|
| 158 |
+
|
| 159 |
+
'condition_name_short'=>array(
|
| 160 |
+
'package_weight' => Mage::helper('shipping')->__('Weight (and above)'),
|
| 161 |
+
'package_value' => Mage::helper('shipping')->__('Order Subtotal (and above)'),
|
| 162 |
+
'package_qty' => Mage::helper('shipping')->__('# of Items (and above)'),
|
| 163 |
+
),
|
| 164 |
+
|
| 165 |
+
);
|
| 166 |
+
|
| 167 |
+
if (!isset($codes[$type])) {
|
| 168 |
+
throw Mage::exception('Mage_Shipping', Mage::helper('shipping')->__('Invalid Table Rate code type: %s', $type));
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
if (''===$code) {
|
| 172 |
+
return $codes[$type];
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
if (!isset($codes[$type][$code])) {
|
| 176 |
+
throw Mage::exception('Mage_Shipping', Mage::helper('shipping')->__('Invalid Table Rate code for type %s: %s', $type, $code));
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
return $codes[$type][$code];
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
/**
|
| 183 |
+
* Get allowed shipping methods
|
| 184 |
+
*
|
| 185 |
+
* @return array
|
| 186 |
+
*/
|
| 187 |
+
public function getAllowedMethods()
|
| 188 |
+
{
|
| 189 |
+
return array('bestway'=>$this->getConfigData('name'));
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
}
|
app/code/local/OMS/Shippingimport/Model/Shipping.php
ADDED
|
@@ -0,0 +1,510 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Shipping
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class OMS_Shippingimport_Model_Shipping
|
| 29 |
+
{
|
| 30 |
+
/**
|
| 31 |
+
* Store address
|
| 32 |
+
*/
|
| 33 |
+
const XML_PATH_STORE_ADDRESS1 = 'shipping/origin/street_line1';
|
| 34 |
+
const XML_PATH_STORE_ADDRESS2 = 'shipping/origin/street_line2';
|
| 35 |
+
const XML_PATH_STORE_CITY = 'shipping/origin/city';
|
| 36 |
+
const XML_PATH_STORE_REGION_ID = 'shipping/origin/region_id';
|
| 37 |
+
const XML_PATH_STORE_ZIP = 'shipping/origin/postcode';
|
| 38 |
+
const XML_PATH_STORE_COUNTRY_ID = 'shipping/origin/country_id';
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* Default shipping orig for requests
|
| 42 |
+
*
|
| 43 |
+
* @var array
|
| 44 |
+
*/
|
| 45 |
+
protected $_orig = null;
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* Cached result
|
| 49 |
+
*
|
| 50 |
+
* @var Mage_Sales_Model_Shipping_Method_Result
|
| 51 |
+
*/
|
| 52 |
+
protected $_result = null;
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* Part of carrier xml config path
|
| 56 |
+
*
|
| 57 |
+
* @var string
|
| 58 |
+
*/
|
| 59 |
+
protected $_availabilityConfigField = 'active';
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* Get shipping rate result model
|
| 63 |
+
*
|
| 64 |
+
* @return Mage_Shipping_Model_Rate_Result
|
| 65 |
+
*/
|
| 66 |
+
public function getResult()
|
| 67 |
+
{
|
| 68 |
+
if (empty($this->_result)) {
|
| 69 |
+
$this->_result = Mage::getModel('shipping/rate_result');
|
| 70 |
+
}
|
| 71 |
+
return $this->_result;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
* Set shipping orig data
|
| 76 |
+
*
|
| 77 |
+
* @param array $data
|
| 78 |
+
* @return null
|
| 79 |
+
*/
|
| 80 |
+
public function setOrigData($data)
|
| 81 |
+
{
|
| 82 |
+
$this->_orig = $data;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* Reset cached result
|
| 87 |
+
*
|
| 88 |
+
* @return Mage_Shipping_Model_Shipping
|
| 89 |
+
*/
|
| 90 |
+
public function resetResult()
|
| 91 |
+
{
|
| 92 |
+
$this->getResult()->reset();
|
| 93 |
+
return $this;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* Retrieve configuration model
|
| 98 |
+
*
|
| 99 |
+
* @return Mage_Shipping_Model_Config
|
| 100 |
+
*/
|
| 101 |
+
public function getConfig()
|
| 102 |
+
{
|
| 103 |
+
return Mage::getSingleton('shipping/config');
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
/**
|
| 107 |
+
* Retrieve all methods for supplied shipping data
|
| 108 |
+
*
|
| 109 |
+
* @todo make it ordered
|
| 110 |
+
* @param Mage_Shipping_Model_Shipping_Method_Request $data
|
| 111 |
+
* @return Mage_Shipping_Model_Shipping
|
| 112 |
+
*/
|
| 113 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
| 114 |
+
{
|
| 115 |
+
$storeId = $request->getStoreId();
|
| 116 |
+
if (!$request->getOrig()) {
|
| 117 |
+
$request
|
| 118 |
+
->setCountryId(Mage::getStoreConfig(self::XML_PATH_STORE_COUNTRY_ID, $request->getStore()))
|
| 119 |
+
->setRegionId(Mage::getStoreConfig(self::XML_PATH_STORE_REGION_ID, $request->getStore()))
|
| 120 |
+
->setCity(Mage::getStoreConfig(self::XML_PATH_STORE_CITY, $request->getStore()))
|
| 121 |
+
->setPostcode(Mage::getStoreConfig(self::XML_PATH_STORE_ZIP, $request->getStore()));
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
$limitCarrier = $request->getLimitCarrier();
|
| 125 |
+
if (!$limitCarrier) {
|
| 126 |
+
$carriers = Mage::getStoreConfig('carriers', $storeId);
|
| 127 |
+
ksort($carriers);
|
| 128 |
+
|
| 129 |
+
foreach ($carriers as $carrierCode => $carrierConfig) {
|
| 130 |
+
$this->collectCarrierRates($carrierCode, $request);
|
| 131 |
+
}
|
| 132 |
+
} else {
|
| 133 |
+
if (!is_array($limitCarrier)) {
|
| 134 |
+
$limitCarrier = array($limitCarrier);
|
| 135 |
+
}
|
| 136 |
+
foreach ($limitCarrier as $carrierCode) {
|
| 137 |
+
$carrierConfig = Mage::getStoreConfig('carriers/' . $carrierCode, $storeId);
|
| 138 |
+
if (!$carrierConfig) {
|
| 139 |
+
continue;
|
| 140 |
+
}
|
| 141 |
+
$this->collectCarrierRates($carrierCode, $request);
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
return $this;
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
/**
|
| 149 |
+
* Collect rates of given carrier
|
| 150 |
+
*
|
| 151 |
+
* @param string $carrierCode
|
| 152 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
| 153 |
+
* @return Mage_Shipping_Model_Shipping
|
| 154 |
+
*/
|
| 155 |
+
public function collectCarrierRates($carrierCode, $request)
|
| 156 |
+
{
|
| 157 |
+
|
| 158 |
+
/* @var $carrier Mage_Shipping_Model_Carrier_Abstract */
|
| 159 |
+
$carrier = $this->getCarrierByCode($carrierCode, $request->getStoreId());
|
| 160 |
+
if (!$carrier) {
|
| 161 |
+
return $this;
|
| 162 |
+
}
|
| 163 |
+
$carrier->setActiveFlag($this->_availabilityConfigField);
|
| 164 |
+
$result = $carrier->checkAvailableShipCountries($request);
|
| 165 |
+
if (false !== $result && !($result instanceof Mage_Shipping_Model_Rate_Result_Error)) {
|
| 166 |
+
$result = $carrier->proccessAdditionalValidation($request);
|
| 167 |
+
}
|
| 168 |
+
/*
|
| 169 |
+
* Result will be false if the admin set not to show the shipping module
|
| 170 |
+
* if the delivery country is not within specific countries
|
| 171 |
+
*/
|
| 172 |
+
if (false !== $result){
|
| 173 |
+
if (!$result instanceof Mage_Shipping_Model_Rate_Result_Error) {
|
| 174 |
+
if ($carrier->getConfigData('shipment_requesttype')) {
|
| 175 |
+
$packages = $this->composePackagesForCarrier($carrier, $request);
|
| 176 |
+
if (!empty($packages)) {
|
| 177 |
+
$sumResults = array();
|
| 178 |
+
foreach ($packages as $weight => $packageCount) {
|
| 179 |
+
$request->setPackageWeight($weight);
|
| 180 |
+
$result = $carrier->collectRates($request);
|
| 181 |
+
if (!$result) {
|
| 182 |
+
return $this;
|
| 183 |
+
} else {
|
| 184 |
+
$result->updateRatePrice($packageCount);
|
| 185 |
+
}
|
| 186 |
+
$sumResults[] = $result;
|
| 187 |
+
}
|
| 188 |
+
if (!empty($sumResults) && count($sumResults) > 1) {
|
| 189 |
+
$result = array();
|
| 190 |
+
foreach ($sumResults as $res) {
|
| 191 |
+
if (empty($result)) {
|
| 192 |
+
$result = $res;
|
| 193 |
+
continue;
|
| 194 |
+
}
|
| 195 |
+
foreach ($res->getAllRates() as $method) {
|
| 196 |
+
foreach ($result->getAllRates() as $resultMethod) {
|
| 197 |
+
if ($method->getMethod() == $resultMethod->getMethod()) {
|
| 198 |
+
$resultMethod->setPrice($method->getPrice() + $resultMethod->getPrice());
|
| 199 |
+
continue;
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
} else {
|
| 206 |
+
$result = $carrier->collectRates($request);
|
| 207 |
+
}
|
| 208 |
+
} else {
|
| 209 |
+
$result = $carrier->collectRates($request);
|
| 210 |
+
}
|
| 211 |
+
if (!$result) {
|
| 212 |
+
return $this;
|
| 213 |
+
}
|
| 214 |
+
}
|
| 215 |
+
if ($carrier->getConfigData('showmethod') == 0 && $result->getError()) {
|
| 216 |
+
return $this;
|
| 217 |
+
}
|
| 218 |
+
// sort rates by price
|
| 219 |
+
if (method_exists($result, 'sortRatesByPrice')) {
|
| 220 |
+
$result->sortRatesByPrice();
|
| 221 |
+
}
|
| 222 |
+
$this->getResult()->append($result);
|
| 223 |
+
}
|
| 224 |
+
return $this;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
/**
|
| 228 |
+
* Compose Packages For Carrier.
|
| 229 |
+
* Devides order into items and items into parts if it's neccesary
|
| 230 |
+
*
|
| 231 |
+
* @param Mage_Shipping_Model_Carrier_Abstract $carrier
|
| 232 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
| 233 |
+
* @return array [int, float]
|
| 234 |
+
*/
|
| 235 |
+
public function composePackagesForCarrier($carrier, $request)
|
| 236 |
+
{
|
| 237 |
+
$allItems = $request->getAllItems();
|
| 238 |
+
$fullItems = array();
|
| 239 |
+
|
| 240 |
+
$maxWeight = (float) $carrier->getConfigData('max_package_weight');
|
| 241 |
+
|
| 242 |
+
foreach ($allItems as $item) {
|
| 243 |
+
if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE
|
| 244 |
+
&& $item->getProduct()->getShipmentType()
|
| 245 |
+
) {
|
| 246 |
+
continue;
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
$qty = $item->getQty();
|
| 250 |
+
$changeQty = true;
|
| 251 |
+
$checkWeight = true;
|
| 252 |
+
$decimalItems = array();
|
| 253 |
+
|
| 254 |
+
if ($item->getParentItem()) {
|
| 255 |
+
if (!$item->getParentItem()->getProduct()->getShipmentType()) {
|
| 256 |
+
continue;
|
| 257 |
+
}
|
| 258 |
+
$qty = $item->getIsQtyDecimal()
|
| 259 |
+
? $item->getParentItem()->getQty()
|
| 260 |
+
: $item->getParentItem()->getQty() * $item->getQty();
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
$itemWeight = $item->getWeight();
|
| 264 |
+
if ($item->getIsQtyDecimal() && $item->getProductType() != Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
|
| 265 |
+
$stockItem = $item->getProduct()->getStockItem();
|
| 266 |
+
if ($stockItem->getIsDecimalDivided()) {
|
| 267 |
+
if ($stockItem->getEnableQtyIncrements() && $stockItem->getQtyIncrements()) {
|
| 268 |
+
$itemWeight = $itemWeight * $stockItem->getQtyIncrements();
|
| 269 |
+
$qty = round(($item->getWeight() / $itemWeight) * $qty);
|
| 270 |
+
$changeQty = false;
|
| 271 |
+
} else {
|
| 272 |
+
$itemWeight = $itemWeight * $item->getQty();
|
| 273 |
+
if ($itemWeight > $maxWeight) {
|
| 274 |
+
$qtyItem = floor($itemWeight / $maxWeight);
|
| 275 |
+
$decimalItems[] = array('weight' => $maxWeight, 'qty' => $qtyItem);
|
| 276 |
+
$weightItem = Mage::helper('core')->getExactDivision($itemWeight, $maxWeight);
|
| 277 |
+
if ($weightItem) {
|
| 278 |
+
$decimalItems[] = array('weight' => $weightItem, 'qty' => 1);
|
| 279 |
+
}
|
| 280 |
+
$checkWeight = false;
|
| 281 |
+
} else {
|
| 282 |
+
$itemWeight = $itemWeight * $item->getQty();
|
| 283 |
+
}
|
| 284 |
+
}
|
| 285 |
+
} else {
|
| 286 |
+
$itemWeight = $itemWeight * $item->getQty();
|
| 287 |
+
}
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
if ($checkWeight && $maxWeight && $itemWeight > $maxWeight) {
|
| 291 |
+
return array();
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
if ($changeQty && !$item->getParentItem() && $item->getIsQtyDecimal()
|
| 295 |
+
&& $item->getProductType() != Mage_Catalog_Model_Product_Type::TYPE_BUNDLE
|
| 296 |
+
) {
|
| 297 |
+
$qty = 1;
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
if (!empty($decimalItems)) {
|
| 301 |
+
foreach ($decimalItems as $decimalItem) {
|
| 302 |
+
$fullItems = array_merge($fullItems,
|
| 303 |
+
array_fill(0, $decimalItem['qty'] * $qty, $decimalItem['weight'])
|
| 304 |
+
);
|
| 305 |
+
}
|
| 306 |
+
} else {
|
| 307 |
+
$fullItems = array_merge($fullItems, array_fill(0, $qty, $itemWeight));
|
| 308 |
+
}
|
| 309 |
+
}
|
| 310 |
+
sort($fullItems);
|
| 311 |
+
|
| 312 |
+
return $this->_makePieces($fullItems, $maxWeight);
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
/**
|
| 316 |
+
* Make pieces
|
| 317 |
+
* Compose packeges list based on given items, so that each package is as heavy as possible
|
| 318 |
+
*
|
| 319 |
+
* @param array $items
|
| 320 |
+
* @param float $maxWeight
|
| 321 |
+
* @return array
|
| 322 |
+
*/
|
| 323 |
+
protected function _makePieces($items, $maxWeight)
|
| 324 |
+
{
|
| 325 |
+
$pieces = array();
|
| 326 |
+
if (!empty($items)) {
|
| 327 |
+
$sumWeight = 0;
|
| 328 |
+
|
| 329 |
+
$reverseOrderItems = $items;
|
| 330 |
+
arsort($reverseOrderItems);
|
| 331 |
+
|
| 332 |
+
foreach ($reverseOrderItems as $key => $weight) {
|
| 333 |
+
if (!isset($items[$key])) {
|
| 334 |
+
continue;
|
| 335 |
+
}
|
| 336 |
+
unset($items[$key]);
|
| 337 |
+
$sumWeight = $weight;
|
| 338 |
+
foreach ($items as $key => $weight) {
|
| 339 |
+
if (($sumWeight + $weight) < $maxWeight) {
|
| 340 |
+
unset($items[$key]);
|
| 341 |
+
$sumWeight += $weight;
|
| 342 |
+
} elseif (($sumWeight + $weight) > $maxWeight) {
|
| 343 |
+
$pieces[] = (string)(float)$sumWeight;
|
| 344 |
+
break;
|
| 345 |
+
} else {
|
| 346 |
+
unset($items[$key]);
|
| 347 |
+
$pieces[] = (string)(float)($sumWeight + $weight);
|
| 348 |
+
$sumWeight = 0;
|
| 349 |
+
break;
|
| 350 |
+
}
|
| 351 |
+
}
|
| 352 |
+
}
|
| 353 |
+
if ($sumWeight > 0) {
|
| 354 |
+
$pieces[] = (string)(float)$sumWeight;
|
| 355 |
+
}
|
| 356 |
+
$pieces = array_count_values($pieces);
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
return $pieces;
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
/**
|
| 363 |
+
* Collect rates by address
|
| 364 |
+
*
|
| 365 |
+
* @param Varien_Object $address
|
| 366 |
+
* @param null|bool|array $limitCarrier
|
| 367 |
+
* @return Mage_Shipping_Model_Shipping
|
| 368 |
+
*/
|
| 369 |
+
public function collectRatesByAddress(Varien_Object $address, $limitCarrier = null)
|
| 370 |
+
{
|
| 371 |
+
/** @var $request Mage_Shipping_Model_Rate_Request */
|
| 372 |
+
$request = Mage::getModel('shipping/rate_request');
|
| 373 |
+
$request->setAllItems($address->getAllItems());
|
| 374 |
+
$request->setDestCountryId($address->getCountryId());
|
| 375 |
+
$request->setDestRegionId($address->getRegionId());
|
| 376 |
+
$request->setDestPostcode($address->getPostcode());
|
| 377 |
+
$request->setPackageValue($address->getBaseSubtotal());
|
| 378 |
+
$request->setPackageValueWithDiscount($address->getBaseSubtotalWithDiscount());
|
| 379 |
+
$request->setPackageWeight($address->getWeight());
|
| 380 |
+
$request->setFreeMethodWeight($address->getFreeMethodWeight());
|
| 381 |
+
$request->setPackageQty($address->getItemQty());
|
| 382 |
+
$request->setStoreId(Mage::app()->getStore()->getId());
|
| 383 |
+
$request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
|
| 384 |
+
$request->setBaseCurrency(Mage::app()->getStore()->getBaseCurrency());
|
| 385 |
+
$request->setPackageCurrency(Mage::app()->getStore()->getCurrentCurrency());
|
| 386 |
+
$request->setLimitCarrier($limitCarrier);
|
| 387 |
+
|
| 388 |
+
$request->setBaseSubtotalInclTax($address->getBaseSubtotalInclTax());
|
| 389 |
+
|
| 390 |
+
return $this->collectRates($request);
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
/**
|
| 394 |
+
* Set part of carrier xml config path
|
| 395 |
+
*
|
| 396 |
+
* @param string $code
|
| 397 |
+
* @return Mage_Shipping_Model_Shipping
|
| 398 |
+
*/
|
| 399 |
+
public function setCarrierAvailabilityConfigField($code = 'active')
|
| 400 |
+
{
|
| 401 |
+
$this->_availabilityConfigField = $code;
|
| 402 |
+
return $this;
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
/**
|
| 406 |
+
* Get carrier by its code
|
| 407 |
+
*
|
| 408 |
+
* @param string $carrierCode
|
| 409 |
+
* @param null|int $storeId
|
| 410 |
+
* @return bool|Mage_Core_Model_Abstract
|
| 411 |
+
*/
|
| 412 |
+
public function getCarrierByCode($carrierCode, $storeId = null)
|
| 413 |
+
{
|
| 414 |
+
//echo $carrierCode."<br/>";
|
| 415 |
+
if($carrierCode!="tablerate")
|
| 416 |
+
{
|
| 417 |
+
if (!Mage::getStoreConfigFlag('carriers/'.$carrierCode.'/'.$this->_availabilityConfigField, $storeId)) {
|
| 418 |
+
return false;
|
| 419 |
+
}
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
+
$className = Mage::getStoreConfig('carriers/'.$carrierCode.'/model', $storeId);
|
| 423 |
+
if (!$className) {
|
| 424 |
+
return false;
|
| 425 |
+
}
|
| 426 |
+
$obj = Mage::getModel($className);
|
| 427 |
+
if ($storeId) {
|
| 428 |
+
$obj->setStore($storeId);
|
| 429 |
+
}
|
| 430 |
+
return $obj;
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
/**
|
| 434 |
+
* Prepare and do request to shipment
|
| 435 |
+
*
|
| 436 |
+
* @param Mage_Sales_Model_Order_Shipment $orderShipment
|
| 437 |
+
* @return Varien_Object
|
| 438 |
+
*/
|
| 439 |
+
public function requestToShipment(Mage_Sales_Model_Order_Shipment $orderShipment)
|
| 440 |
+
{
|
| 441 |
+
$admin = Mage::getSingleton('admin/session')->getUser();
|
| 442 |
+
$order = $orderShipment->getOrder();
|
| 443 |
+
$address = $order->getShippingAddress();
|
| 444 |
+
$shippingMethod = $order->getShippingMethod(true);
|
| 445 |
+
$shipmentStoreId = $orderShipment->getStoreId();
|
| 446 |
+
$shipmentCarrier = $order->getShippingCarrier();
|
| 447 |
+
$baseCurrencyCode = Mage::app()->getStore($shipmentStoreId)->getBaseCurrencyCode();
|
| 448 |
+
if (!$shipmentCarrier) {
|
| 449 |
+
Mage::throwException('Invalid carrier: ' . $shippingMethod->getCarrierCode());
|
| 450 |
+
}
|
| 451 |
+
$shipperRegionCode = Mage::getStoreConfig(self::XML_PATH_STORE_REGION_ID, $shipmentStoreId);
|
| 452 |
+
if (is_numeric($shipperRegionCode)) {
|
| 453 |
+
$shipperRegionCode = Mage::getModel('directory/region')->load($shipperRegionCode)->getCode();
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
$recipientRegionCode = Mage::getModel('directory/region')->load($address->getRegionId())->getCode();
|
| 457 |
+
|
| 458 |
+
$originStreet1 = Mage::getStoreConfig(self::XML_PATH_STORE_ADDRESS1, $shipmentStoreId);
|
| 459 |
+
$originStreet2 = Mage::getStoreConfig(self::XML_PATH_STORE_ADDRESS2, $shipmentStoreId);
|
| 460 |
+
$storeInfo = new Varien_Object(Mage::getStoreConfig('general/store_information', $shipmentStoreId));
|
| 461 |
+
|
| 462 |
+
if (!$admin->getFirstname() || !$admin->getLastname() || !$storeInfo->getName() || !$storeInfo->getPhone()
|
| 463 |
+
|| !$originStreet1 || !Mage::getStoreConfig(self::XML_PATH_STORE_CITY, $shipmentStoreId)
|
| 464 |
+
|| !$shipperRegionCode || !Mage::getStoreConfig(self::XML_PATH_STORE_ZIP, $shipmentStoreId)
|
| 465 |
+
|| !Mage::getStoreConfig(self::XML_PATH_STORE_COUNTRY_ID, $shipmentStoreId)
|
| 466 |
+
) {
|
| 467 |
+
Mage::throwException(
|
| 468 |
+
Mage::helper('sales')->__('Insufficient information to create shipping label(s). Please verify your Store Information and Shipping Settings.')
|
| 469 |
+
);
|
| 470 |
+
}
|
| 471 |
+
|
| 472 |
+
/** @var $request Mage_Shipping_Model_Shipment_Request */
|
| 473 |
+
$request = Mage::getModel('shipping/shipment_request');
|
| 474 |
+
$request->setOrderShipment($orderShipment);
|
| 475 |
+
$request->setShipperContactPersonName($admin->getName());
|
| 476 |
+
$request->setShipperContactPersonFirstName($admin->getFirstname());
|
| 477 |
+
$request->setShipperContactPersonLastName($admin->getLastname());
|
| 478 |
+
$request->setShipperContactCompanyName($storeInfo->getName());
|
| 479 |
+
$request->setShipperContactPhoneNumber($storeInfo->getPhone());
|
| 480 |
+
$request->setShipperEmail($admin->getEmail());
|
| 481 |
+
$request->setShipperAddressStreet(trim($originStreet1 . ' ' . $originStreet2));
|
| 482 |
+
$request->setShipperAddressStreet1($originStreet1);
|
| 483 |
+
$request->setShipperAddressStreet2($originStreet2);
|
| 484 |
+
$request->setShipperAddressCity(Mage::getStoreConfig(self::XML_PATH_STORE_CITY, $shipmentStoreId));
|
| 485 |
+
$request->setShipperAddressStateOrProvinceCode($shipperRegionCode);
|
| 486 |
+
$request->setShipperAddressPostalCode(Mage::getStoreConfig(self::XML_PATH_STORE_ZIP, $shipmentStoreId));
|
| 487 |
+
$request->setShipperAddressCountryCode(Mage::getStoreConfig(self::XML_PATH_STORE_COUNTRY_ID, $shipmentStoreId));
|
| 488 |
+
$request->setRecipientContactPersonName(trim($address->getFirstname() . ' ' . $address->getLastname()));
|
| 489 |
+
$request->setRecipientContactPersonFirstName($address->getFirstname());
|
| 490 |
+
$request->setRecipientContactPersonLastName($address->getLastname());
|
| 491 |
+
$request->setRecipientContactCompanyName($address->getCompany());
|
| 492 |
+
$request->setRecipientContactPhoneNumber($address->getTelephone());
|
| 493 |
+
$request->setRecipientEmail($address->getEmail());
|
| 494 |
+
$request->setRecipientAddressStreet(trim($address->getStreet1() . ' ' . $address->getStreet2()));
|
| 495 |
+
$request->setRecipientAddressStreet1($address->getStreet1());
|
| 496 |
+
$request->setRecipientAddressStreet2($address->getStreet2());
|
| 497 |
+
$request->setRecipientAddressCity($address->getCity());
|
| 498 |
+
$request->setRecipientAddressStateOrProvinceCode($address->getRegionCode());
|
| 499 |
+
$request->setRecipientAddressRegionCode($recipientRegionCode);
|
| 500 |
+
$request->setRecipientAddressPostalCode($address->getPostcode());
|
| 501 |
+
$request->setRecipientAddressCountryCode($address->getCountryId());
|
| 502 |
+
$request->setShippingMethod($shippingMethod->getMethod());
|
| 503 |
+
$request->setPackageWeight($order->getWeight());
|
| 504 |
+
$request->setPackages($orderShipment->getPackages());
|
| 505 |
+
$request->setBaseCurrencyCode($baseCurrencyCode);
|
| 506 |
+
$request->setStoreId($shipmentStoreId);
|
| 507 |
+
|
| 508 |
+
return $shipmentCarrier->requestToShipment($request);
|
| 509 |
+
}
|
| 510 |
+
}
|
app/code/local/OMS/Shippingimport/etc/adminhtml.xml
CHANGED
|
@@ -9,7 +9,7 @@
|
|
| 9 |
<config>
|
| 10 |
<children>
|
| 11 |
<webservice translate="title" module="shipping">
|
| 12 |
-
<title>
|
| 13 |
<sort_order>100</sort_order>
|
| 14 |
</webservice>
|
| 15 |
</children>
|
| 9 |
<config>
|
| 10 |
<children>
|
| 11 |
<webservice translate="title" module="shipping">
|
| 12 |
+
<title>Shipping SOAP Web Service</title>
|
| 13 |
<sort_order>100</sort_order>
|
| 14 |
</webservice>
|
| 15 |
</children>
|
app/code/local/OMS/Shippingimport/etc/config.xml
CHANGED
|
@@ -63,6 +63,15 @@
|
|
| 63 |
<class>OMS_Shippingimport_Model</class>
|
| 64 |
<resourceModel>shippingimport_mysql4</resourceModel>
|
| 65 |
</shippingimport>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
<shippingimport_mysql4>
|
| 67 |
<class>OMS_Shippingimport_Model_Mysql4</class>
|
| 68 |
<entities>
|
| 63 |
<class>OMS_Shippingimport_Model</class>
|
| 64 |
<resourceModel>shippingimport_mysql4</resourceModel>
|
| 65 |
</shippingimport>
|
| 66 |
+
<shipping>
|
| 67 |
+
<rewrite>
|
| 68 |
+
|
| 69 |
+
<carrier_tablerate>OMS_Shippingimport_Model_Carrier_Tablerate</carrier_tablerate>
|
| 70 |
+
</rewrite>
|
| 71 |
+
<rewrite>
|
| 72 |
+
<shipping>OMS_Shippingimport_Model_Shipping</shipping>
|
| 73 |
+
</rewrite>
|
| 74 |
+
</shipping>
|
| 75 |
<shippingimport_mysql4>
|
| 76 |
<class>OMS_Shippingimport_Model_Mysql4</class>
|
| 77 |
<entities>
|
app/code/local/OMS/Shippingimport/etc/system.xml
CHANGED
|
@@ -18,7 +18,7 @@
|
|
| 18 |
|
| 19 |
<groups>
|
| 20 |
<webservice_group translate="label" module="shipping">
|
| 21 |
-
<label>OMS Global Freight Estimator
|
| 22 |
<frontend_type>text</frontend_type>
|
| 23 |
<sort_order>1000</sort_order>
|
| 24 |
<show_in_default>1</show_in_default>
|
|
@@ -147,18 +147,103 @@
|
|
| 147 |
<show_in_website>1</show_in_website>
|
| 148 |
<show_in_store>1</show_in_store>
|
| 149 |
</webservice_handlingfeepercent>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
<webservice_debug translate="label">
|
| 151 |
<label>Debug: </label>
|
| 152 |
<comment>Will add Webservice call info to a log.</comment>
|
| 153 |
<frontend_type>select</frontend_type>
|
| 154 |
<source_model>OMS_Shippingimport_Model_Handlingfees</source_model>
|
| 155 |
-
<sort_order>
|
| 156 |
<show_in_default>1</show_in_default>
|
| 157 |
<show_in_website>1</show_in_website>
|
| 158 |
<show_in_store>1</show_in_store>
|
| 159 |
</webservice_debug>
|
| 160 |
</fields>
|
| 161 |
</webservice_group>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
</groups>
|
| 163 |
</webservice>
|
| 164 |
<carriers>
|
|
@@ -180,6 +265,14 @@
|
|
| 180 |
<show_in_website>1</show_in_website>
|
| 181 |
<show_in_store>1</show_in_store>
|
| 182 |
</active>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
<!-- <sort_order translate="label">
|
| 184 |
<label>Sort order</label>
|
| 185 |
<frontend_type>text</frontend_type>
|
|
@@ -222,7 +315,22 @@
|
|
| 222 |
<show_in_store>0</show_in_store>
|
| 223 |
</handling_type>-->
|
| 224 |
|
| 225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
<allowedmethods translate="label">
|
| 227 |
<label>Allowed Methods</label>
|
| 228 |
<frontend_type>multiselect</frontend_type>
|
|
@@ -232,10 +340,29 @@
|
|
| 232 |
<show_in_website>1</show_in_website>
|
| 233 |
<show_in_store>1</show_in_store>
|
| 234 |
</allowedmethods>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
<specificerrmsg translate="label">
|
| 236 |
<label>Displayed Error Message</label>
|
| 237 |
<frontend_type>textarea</frontend_type>
|
| 238 |
-
<sort_order>
|
| 239 |
<show_in_default>1</show_in_default>
|
| 240 |
<show_in_website>1</show_in_website>
|
| 241 |
<show_in_store>1</show_in_store>
|
| 18 |
|
| 19 |
<groups>
|
| 20 |
<webservice_group translate="label" module="shipping">
|
| 21 |
+
<label>OMS Global Freight Estimator configuration</label>
|
| 22 |
<frontend_type>text</frontend_type>
|
| 23 |
<sort_order>1000</sort_order>
|
| 24 |
<show_in_default>1</show_in_default>
|
| 147 |
<show_in_website>1</show_in_website>
|
| 148 |
<show_in_store>1</show_in_store>
|
| 149 |
</webservice_handlingfeepercent>
|
| 150 |
+
<webservice_alternate translate="label">
|
| 151 |
+
<label>Alternate methods: </label>
|
| 152 |
+
<comment>Will be use in case when webservice returns no rates.</comment>
|
| 153 |
+
<frontend_type>select</frontend_type>
|
| 154 |
+
<source_model>OMS_Shippingimport_Model_Alternatemethods</source_model>
|
| 155 |
+
<sort_order>48</sort_order>
|
| 156 |
+
<show_in_default>1</show_in_default>
|
| 157 |
+
<show_in_website>1</show_in_website>
|
| 158 |
+
<show_in_store>1</show_in_store>
|
| 159 |
+
</webservice_alternate>
|
| 160 |
+
|
| 161 |
<webservice_debug translate="label">
|
| 162 |
<label>Debug: </label>
|
| 163 |
<comment>Will add Webservice call info to a log.</comment>
|
| 164 |
<frontend_type>select</frontend_type>
|
| 165 |
<source_model>OMS_Shippingimport_Model_Handlingfees</source_model>
|
| 166 |
+
<sort_order>49</sort_order>
|
| 167 |
<show_in_default>1</show_in_default>
|
| 168 |
<show_in_website>1</show_in_website>
|
| 169 |
<show_in_store>1</show_in_store>
|
| 170 |
</webservice_debug>
|
| 171 |
</fields>
|
| 172 |
</webservice_group>
|
| 173 |
+
<email_settings translate="label" module="shipping">
|
| 174 |
+
<label>OMS Shipping SMTP Settings</label>
|
| 175 |
+
<frontend_type>text</frontend_type>
|
| 176 |
+
<sort_order>1001</sort_order>
|
| 177 |
+
<show_in_default>1</show_in_default>
|
| 178 |
+
<show_in_website>1</show_in_website>
|
| 179 |
+
<show_in_store>1</show_in_store>
|
| 180 |
+
<fields>
|
| 181 |
+
<hostname translate="label">
|
| 182 |
+
<label>Host Name:</label>
|
| 183 |
+
<comment></comment>
|
| 184 |
+
<frontend_type>text</frontend_type>
|
| 185 |
+
<sort_order>1</sort_order>
|
| 186 |
+
<show_in_default>1</show_in_default>
|
| 187 |
+
<show_in_website>1</show_in_website>
|
| 188 |
+
<show_in_store>1</show_in_store>
|
| 189 |
+
</hostname>
|
| 190 |
+
<username translate="label">
|
| 191 |
+
<label>Username:</label>
|
| 192 |
+
<comment></comment>
|
| 193 |
+
<frontend_type>text</frontend_type>
|
| 194 |
+
<sort_order>2</sort_order>
|
| 195 |
+
<show_in_default>1</show_in_default>
|
| 196 |
+
<show_in_website>1</show_in_website>
|
| 197 |
+
<show_in_store>1</show_in_store>
|
| 198 |
+
</username>
|
| 199 |
+
<password translate="label">
|
| 200 |
+
<label>Password:</label>
|
| 201 |
+
<comment></comment>
|
| 202 |
+
<frontend_type>password</frontend_type>
|
| 203 |
+
<sort_order>3</sort_order>
|
| 204 |
+
<show_in_default>1</show_in_default>
|
| 205 |
+
<show_in_website>1</show_in_website>
|
| 206 |
+
<show_in_store>1</show_in_store>
|
| 207 |
+
</password>
|
| 208 |
+
<port translate="label">
|
| 209 |
+
<label>Port:</label>
|
| 210 |
+
<comment></comment>
|
| 211 |
+
<frontend_type>text</frontend_type>
|
| 212 |
+
<sort_order>4</sort_order>
|
| 213 |
+
<show_in_default>1</show_in_default>
|
| 214 |
+
<show_in_website>1</show_in_website>
|
| 215 |
+
<show_in_store>1</show_in_store>
|
| 216 |
+
</port>
|
| 217 |
+
<send_to translate="label">
|
| 218 |
+
<label>Send to:</label>
|
| 219 |
+
<comment></comment>
|
| 220 |
+
<frontend_type>text</frontend_type>
|
| 221 |
+
<sort_order>5</sort_order>
|
| 222 |
+
<show_in_default>1</show_in_default>
|
| 223 |
+
<show_in_website>1</show_in_website>
|
| 224 |
+
<show_in_store>1</show_in_store>
|
| 225 |
+
</send_to>
|
| 226 |
+
<from_name translate="label">
|
| 227 |
+
<label>Store Name:</label>
|
| 228 |
+
<comment></comment>
|
| 229 |
+
<frontend_type>text</frontend_type>
|
| 230 |
+
<sort_order>6</sort_order>
|
| 231 |
+
<show_in_default>1</show_in_default>
|
| 232 |
+
<show_in_website>1</show_in_website>
|
| 233 |
+
<show_in_store>1</show_in_store>
|
| 234 |
+
</from_name>
|
| 235 |
+
<from_email translate="label">
|
| 236 |
+
<label>Store Email:</label>
|
| 237 |
+
<comment></comment>
|
| 238 |
+
<frontend_type>text</frontend_type>
|
| 239 |
+
<sort_order>6</sort_order>
|
| 240 |
+
<show_in_default>1</show_in_default>
|
| 241 |
+
<show_in_website>1</show_in_website>
|
| 242 |
+
<show_in_store>1</show_in_store>
|
| 243 |
+
</from_email>
|
| 244 |
+
</fields>
|
| 245 |
+
|
| 246 |
+
</email_settings>
|
| 247 |
</groups>
|
| 248 |
</webservice>
|
| 249 |
<carriers>
|
| 265 |
<show_in_website>1</show_in_website>
|
| 266 |
<show_in_store>1</show_in_store>
|
| 267 |
</active>
|
| 268 |
+
<title translate="label">
|
| 269 |
+
<label>Title</label>
|
| 270 |
+
<frontend_type>text</frontend_type>
|
| 271 |
+
<sort_order>2</sort_order>
|
| 272 |
+
<show_in_default>1</show_in_default>
|
| 273 |
+
<show_in_website>1</show_in_website>
|
| 274 |
+
<show_in_store>1</show_in_store>
|
| 275 |
+
</title>
|
| 276 |
<!-- <sort_order translate="label">
|
| 277 |
<label>Sort order</label>
|
| 278 |
<frontend_type>text</frontend_type>
|
| 315 |
<show_in_store>0</show_in_store>
|
| 316 |
</handling_type>-->
|
| 317 |
|
| 318 |
+
<domestic_fail_safe_rate>
|
| 319 |
+
<label>Domestic failsafe Rate</label>
|
| 320 |
+
<frontend_type>text</frontend_type>
|
| 321 |
+
<sort_order>78</sort_order>
|
| 322 |
+
<show_in_default>1</show_in_default>
|
| 323 |
+
<show_in_website>1</show_in_website>
|
| 324 |
+
<show_in_store>1</show_in_store>
|
| 325 |
+
</domestic_fail_safe_rate>
|
| 326 |
+
<international_fail_safe_rate>
|
| 327 |
+
<label>International failsafe Rate</label>
|
| 328 |
+
<frontend_type>text</frontend_type>
|
| 329 |
+
<sort_order>79</sort_order>
|
| 330 |
+
<show_in_default>1</show_in_default>
|
| 331 |
+
<show_in_website>1</show_in_website>
|
| 332 |
+
<show_in_store>1</show_in_store>
|
| 333 |
+
</international_fail_safe_rate>
|
| 334 |
<allowedmethods translate="label">
|
| 335 |
<label>Allowed Methods</label>
|
| 336 |
<frontend_type>multiselect</frontend_type>
|
| 340 |
<show_in_website>1</show_in_website>
|
| 341 |
<show_in_store>1</show_in_store>
|
| 342 |
</allowedmethods>
|
| 343 |
+
<sallowspecific translate="label">
|
| 344 |
+
<label>Ship to applicable countries</label>
|
| 345 |
+
<frontend_type>select</frontend_type>
|
| 346 |
+
<sort_order>90</sort_order>
|
| 347 |
+
<frontend_class>shipping-applicable-country</frontend_class>
|
| 348 |
+
<source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
|
| 349 |
+
<show_in_default>1</show_in_default>
|
| 350 |
+
<show_in_website>1</show_in_website>
|
| 351 |
+
<show_in_store>1</show_in_store>
|
| 352 |
+
</sallowspecific>
|
| 353 |
+
<specificcountry translate="label">
|
| 354 |
+
<label>Ship to Specific countries</label>
|
| 355 |
+
<frontend_type>multiselect</frontend_type>
|
| 356 |
+
<sort_order>91</sort_order>
|
| 357 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
| 358 |
+
<show_in_default>1</show_in_default>
|
| 359 |
+
<show_in_website>1</show_in_website>
|
| 360 |
+
<show_in_store>1</show_in_store>
|
| 361 |
+
</specificcountry>
|
| 362 |
<specificerrmsg translate="label">
|
| 363 |
<label>Displayed Error Message</label>
|
| 364 |
<frontend_type>textarea</frontend_type>
|
| 365 |
+
<sort_order>92</sort_order>
|
| 366 |
<show_in_default>1</show_in_default>
|
| 367 |
<show_in_website>1</show_in_website>
|
| 368 |
<show_in_store>1</show_in_store>
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>OMS_Global_Freight_Estimator</name>
|
| 4 |
-
<version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>AFL 3.0</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -10,9 +10,9 @@
|
|
| 10 |
<description>Displays shipping rates.</description>
|
| 11 |
<notes>Completed</notes>
|
| 12 |
<authors><author><name>OMS</name><user>OMS</user><email>david.morris@oms.us.com</email></author></authors>
|
| 13 |
-
<date>2012-
|
| 14 |
-
<time>
|
| 15 |
-
<contents><target name="magelocal"><dir name="OMS"><dir name="Shippingimport"><dir name="Helper"><file name="Data.php" hash="
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.2.0</min><max>5.4.0</max></php></required></dependencies>
|
| 18 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>OMS_Global_Freight_Estimator</name>
|
| 4 |
+
<version>2.0.0</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>AFL 3.0</license>
|
| 7 |
<channel>community</channel>
|
| 10 |
<description>Displays shipping rates.</description>
|
| 11 |
<notes>Completed</notes>
|
| 12 |
<authors><author><name>OMS</name><user>OMS</user><email>david.morris@oms.us.com</email></author></authors>
|
| 13 |
+
<date>2012-12-11</date>
|
| 14 |
+
<time>06:46:17</time>
|
| 15 |
+
<contents><target name="magelocal"><dir name="OMS"><dir name="Shippingimport"><dir name="Helper"><file name="Data.php" hash="6180a2ca23bbc0b52b188febb028b39b"/></dir><dir name="Model"><file name="Alternatemethods.php" hash="d317ce8917756cf0666f64495e660b4e"/><dir name="Carrier"><file name="Localdelivery.php" hash="4a4481961f3c5f3fcd0946c0918a60d1"/><file name="Tablerate.php" hash="21f9a9d7e531f9d971210590eedbc4a9"/><file name="_Localdelivery.php" hash="b6d9006d6450ac61db74c5f30bb56aeb"/><file name="__Localdelivery.php" hash="62407aa8d2ae22dcc232077dfdd5299f"/></dir><file name="Enable.php" hash="27503f2345449d8ad476b7ed705a4196"/><file name="Handlingfees.php" hash="3f3fdf8557190cec4f786d63697c1d66"/><file name="Import.php" hash="9bf8bd095f3880d80263fa77e9841b49"/><file name="Methodslist.php" hash="d2a684ca77d6752e4e38c04033094749"/><dir name="Mysql4"><dir name="Import"><file name="Collection.php" hash="3fdb97c52fc30e58fec1829b6f93f477"/></dir><file name="Import.php" hash="adb97b24eb8f757a0111c87f4d6a323f"/></dir><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="65035aef1bb79a13a49b596187139b85"/></dir></dir></dir><file name="Shipping.php" hash="51a267e460cd17366149b80944483d57"/><file name="Unit.php" hash="51defb0b2281c0add597c57e67e47a10"/></dir><dir name="controllers"><file name="IndexController.php" hash="e2c98fd728c7c0e71f3b9df90934d3b7"/></dir><dir name="etc"><file name="adminhtml.xml" hash="ea5b26de474c6e4ee445013789e383a8"/><file name="config.xml" hash="14bb48f2d233159c6b302131ef80c447"/><file name="system.xml" hash="c2dbc15ef65bbbf4d3a21f8ae2dc3c8d"/></dir><dir name="sql"><dir name="shippingimport_setup"><file name="mysql4-install-0.0.1.php" hash="d6d1d20afa936be5ef35207545df4a15"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="OMS_Shippingimport.xml" hash="24e6c1788c336a0653079edd518c2a3f"/></dir></target></contents>
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.2.0</min><max>5.4.0</max></php></required></dependencies>
|
| 18 |
</package>
|
