Skip to content
This repository has been archived by the owner on Feb 3, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/2.6.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan McBride committed May 13, 2015
2 parents cf447fc + 9d770e5 commit 965fe3f
Show file tree
Hide file tree
Showing 95 changed files with 1,287 additions and 1,340 deletions.
19 changes: 0 additions & 19 deletions app/code/community/Meanbee/Royalmail/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,25 +300,6 @@ public function isCountryAvailableForInternationalSigned($countryCode) {
return $this->_isCountryAvailableForMethod($countryCode, self::INTERNATIONAL_SIGNED);
}

/**
* RoyalMail allow weights over their upper limit, and usually charge per additional 250g.
* This is a helper to add those charges onto the rates supplied.
*
* @param $rates
* @param $charge
* @param $weight
* @param int $chargePer
* @return mixed
*/
public function addAdditionalWeightCharges($rates, $charge, $weight, $chargePer = 250) {
for($i = 0; $i < count($rates); $i++) {
if($weight > $rates[$i]['upper']) {
$additional = ceil(((($weight - $rates[$i]['upper']) / $chargePer) * $charge * 100)) / 100;
$rates[$i]['cost'] += $additional;
}
}
return $rates;
}

/**
* A simple helper to add the insurance charges on top of the rates supplied.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,39 @@ public function getAllowedMethods() {
public function getMethods($name=null) {
$codes = array(
// To maintain backwards comparability we need to keep letter and largeletter indices the same

'letter' => 'First Class Letter',
'largeletter' => 'First Class Large Letter',
'firstclasslettersignedfor' => 'First Class Letter (Signed for)',
'firstclasslargelettersignedfor' => 'First Class Large Letter (Signed for)',

'secondclassletter' => 'Second Class Letter',
'secondclasslargeletter' => 'Second Class Large Letter',
'secondclasslettersignedfor' => 'Second Class Letter (Signed For)',
'secondclasslargelettersignedfor' => 'Second Class Large Letter (Signed For)',

'secondclass' => 'Second Class Parcel',
'secondclassrecordedsignedfor' => 'Second Class Parcel (Signed for)',

'firstclass' => 'First Class Parcel',
'firstclassrecordedsignedfor' => 'First Class Parcel (Signed for)',

'specialdeliverynextday' => 'Special Delivery Guaranteed by 1pm (Up to 500GBP Insurance)',

'specialdeliverynextday' => 'Special Delivery Guaranteed by 1pm (Up to 2,500GBP Insurance)',
'specialdelivery9am' => 'Special Delivery Guaranteed by 9am (Up to 2,500GBP Insurance)',
'specialdelivery9amsaturday' => 'Special Delivery Saturday Guaranteed by 9am (Up to 2,500GBP Insurance)',
'specialdeliverynextdaysaturday' => 'Special Delivery Saturday Guaranteed by 1pm (Up to 2,500GBP Insurance)',

'internationalstandard' => 'International Standard (up to 5kg)',
'internationalstandard' => 'International Standard (up to 2kg)',
'internationaltrackedsigned' => 'International Tracked & Signed (Up to 250GBP Compensation)',
'internationaltracked' => 'International Tracked (Up to 250GBP Compensation)',
'internationalsigned' => 'International Signed (Up to 250GBP Compensation)',
'internationaleconomy' => 'International Economy'
'internationaleconomy' => 'International Economy',

'internationallettertracked' => 'International Letter Tracked',
'internationallettersigned' => 'International Letter Signed',
'internationallettereconomy' => 'International Letter Economy',
'internationalletterstandard' => 'International Letter Standard',
'internationallettertrackedsigned' => 'International Letter Tracked (Signed)',
);

if ($name !== null) {
Expand All @@ -167,4 +180,4 @@ public function getMethods($name=null) {
return $codes;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function getRates() {
$helper = Mage::helper('royalmail');
$rates = $this->_loadCsv($this->_getRateFile());

if ($helper->getWorldZone($this->_getCountry()) == 'gb') {
if ($helper->getWorldZone($this->_getCountry()) == Meanbee_Royalmail_Helper_Data::WORLD_ZONE_GB) {
return $rates;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category Meanbee
* @package Meanbee_Royalmail
* @copyright Copyright (c) 2008 Meanbee Internet Solutions (http://www.meanbee.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Firstclasslargelettersignedfor
extends Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Abstract {

protected function getRates() {
$helper = Mage::helper('royalmail');
$rates = $this->_loadCsv('firstclass_largeletter_signedfor');

if ($helper->getWorldZone($this->_getCountry()) == Meanbee_Royalmail_Helper_Data::WORLD_ZONE_GB) {
return $rates;
}

return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category Meanbee
* @package Meanbee_Royalmail
* @copyright Copyright (c) 2008 Meanbee Internet Solutions (http://www.meanbee.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Firstclasslettersignedfor
extends Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Abstract {

protected function getRates() {
$helper = Mage::helper('royalmail');
$rates = $this->_loadCsv('firstclass_letter_signedfor');

if ($helper->getWorldZone($this->_getCountry()) == Meanbee_Royalmail_Helper_Data::WORLD_ZONE_GB) {
return $rates;
}

return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,23 @@
class Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Firstclassrecordedsignedfor
extends Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Firstclass {

private $_extraCharge = 1.10;

public function getRates() {
$rates = parent::getRates();
$helper = Mage::helper('royalmail');
$rates = $this->_loadCsv($this->_getRateFile());

if ($helper->getWorldZone($this->_getCountry()) == Meanbee_Royalmail_Helper_Data::WORLD_ZONE_GB) {
return $rates;
}

return null;
}

protected function _getRateFile() {

for ($i = 0; $i < count($rates); $i++) {
$rates[$i]['cost'] += $this->_extraCharge;
if (Mage::getStoreConfig('carriers/royalmail/parcel_size') == Meanbee_Royalmail_Model_Parcelsize::SMALL) {
return 'firstclass_small_signedfor';
}

return $rates;
return 'firstclass_medium_signedfor';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category Meanbee
* @package Meanbee_Royalmail
* @copyright Copyright (c) 2014 Meanbee Internet Solutions (http://www.meanbee.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Internationallettereconomy
extends Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Abstract {

public function getRates() {
$helper = Mage::helper('royalmail');
if ($helper->getWorldZone($this->_getCountry()) !== Meanbee_Royalmail_Helper_Data::WORLD_ZONE_GB) {
return $this->_loadCsv('internationalltettereconomy');
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category Meanbee
* @package Meanbee_Royalmail
* @copyright Copyright (c) 2014 Meanbee Internet Solutions (http://www.meanbee.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Internationallettersigned
extends Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Abstract {

protected $insureOver = 50;
protected $additionalInsuranceChargeEu = 2.50;
protected $additionalInsuranceChargeNonEu = 2.50;
protected $additionalInsuranceChargeWz1 = 2.50;
protected $additionalInsuranceChargeWz2 = 2.50;

public function getRates() {
$_helper = Mage::helper('royalmail');
$country = $this->_getCountry();
$worldZone = $_helper->getWorldZone($country);


if (!$_helper->isCountryAvailableForInternationalSigned($country)) {
return null;
}


switch($worldZone) {
case Meanbee_Royalmail_Helper_Data::WORLD_ZONE_GB:
return null;
case Meanbee_Royalmail_Helper_Data::WORLD_ZONE_EU:
$rates = $_helper->addInsuranceCharges(
$this->_getEuRates(),
$this->additionalInsuranceChargeEu,
$this->getCartTotal(),
$this->insureOver
);
break;
case Meanbee_Royalmail_Helper_Data::WORLD_ZONE_ONE:
$rates = $_helper->addInsuranceCharges(
$this->_getWzRates(),
$this->additionalInsuranceChargeWz1,
$this->getCartTotal(),
$this->insureOver
);
break;
case Meanbee_Royalmail_Helper_Data::WORLD_ZONE_TWO:
$rates = $_helper->addInsuranceCharges(
$this->_getWzRates(),
$this->additionalInsuranceChargeWz2,
$this->getCartTotal(),
$this->insureOver
);
break;
default:
return null;
}
return $rates;
}

protected function _getEuRates() {
return $this->_loadCsv('internationallettersigned_eu');
}

protected function _getWzRates() {
return $this->_loadCsv('internationallettersigned_wz');
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category Meanbee
* @package Meanbee_Royalmail
* @copyright Copyright (c) 2014 Meanbee Internet Solutions (http://www.meanbee.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Internationalletterstandard
extends Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Abstract {


public function getRates() {
$_helper = Mage::helper('royalmail');
$country = $this->_getCountry();
$worldZone = $_helper->getWorldZone($country);


switch($worldZone) {
case Meanbee_Royalmail_Helper_Data::WORLD_ZONE_GB:
return null;
case Meanbee_Royalmail_Helper_Data::WORLD_ZONE_EU:
$rates = $this->_getEuropeRates();
break;
case Meanbee_Royalmail_Helper_Data::WORLD_ZONE_ONE:
case Meanbee_Royalmail_Helper_Data::WORLD_ZONE_TWO:
$rates = $this->_getWzRates();
break;
default:
return null;
}
return $rates;
}

protected function _getEuropeRates() {
return $this->_loadCsv('internationalletterstandard_eu');
}

protected function _getWzRates() {
return $this->_loadCsv('internationalletterstandard_wz');
}

}
Loading

0 comments on commit 965fe3f

Please sign in to comment.