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.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash Smith committed Dec 17, 2014
2 parents 088428b + 73f8da2 commit cf447fc
Show file tree
Hide file tree
Showing 21 changed files with 322 additions and 111 deletions.
25 changes: 15 additions & 10 deletions app/code/community/Meanbee/Royalmail/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

class Meanbee_Royalmail_Helper_Data extends Mage_Core_Helper_Abstract {

const WORLD_ZONE_GB = 'gb';
const WORLD_ZONE_EU = 'eu';
const WORLD_ZONE_NONEU = 'noneu';
const WORLD_ZONE_ONE = 'wz1';
Expand All @@ -27,6 +28,9 @@ class Meanbee_Royalmail_Helper_Data extends Mage_Core_Helper_Abstract {
const INTERNATIONAL_TRACKED_AND_SIGNED = 'international_trackedsigned';
const INTERNATIONAL_TRACKED = 'international_tracked';

protected $_worldZoneGb = array(
'GB', 'IM', 'JE', 'GG');

protected $_worldZoneEu = array(
'DK', 'EE', 'LV', 'AT', 'FI',
'LT', 'SK', 'FR', 'LU', 'SI',
Expand Down Expand Up @@ -185,6 +189,7 @@ class Meanbee_Royalmail_Helper_Data extends Mage_Core_Helper_Abstract {
'ME' => array(self::INTERNATIONAL_SIGNED),
'MS' => array(self::INTERNATIONAL_SIGNED),
'MA' => array(self::INTERNATIONAL_SIGNED),
'MC' => array(self::INTERNATIONAL_TRACKED_AND_SIGNED, self::INTERNATIONAL_TRACKED),
'MZ' => array(self::INTERNATIONAL_SIGNED),
'MM' => array(self::INTERNATIONAL_SIGNED),
'NA' => array(self::INTERNATIONAL_SIGNED),
Expand Down Expand Up @@ -343,16 +348,16 @@ public function addInsuranceCharges($rates, $charge, $cartTotal, $valueOver = 50
*/
public function getWorldZone($countryCode) {
$country = strtoupper($countryCode);
if ($country != 'GB') {
if (in_array($country, $this->_worldZoneEu)) {
return self::WORLD_ZONE_EU;
} else if (in_array($country, $this->_worldZoneNonEu)) {
return self::WORLD_ZONE_NONEU;
} else if (in_array($country, $this->_worldZone2)) {
return self::WORLD_ZONE_TWO;
} else {
return self::WORLD_ZONE_ONE;
}
if (in_array($country, $this->_worldZoneGb)) {
return self::WORLD_ZONE_GB;
} else if (in_array($country, $this->_worldZoneEu)) {
return self::WORLD_ZONE_EU;
} else if (in_array($country, $this->_worldZoneNonEu)) {
return self::WORLD_ZONE_NONEU;
} else if (in_array($country, $this->_worldZone2)) {
return self::WORLD_ZONE_TWO;
} else {
return self::WORLD_ZONE_ONE;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,11 @@ public function getAllowedMethods() {

public function getMethods($name=null) {
$codes = array(
'letter' => 'Letter',
'largeletter' => 'Large Letter',
// To maintain backwards comparability we need to keep letter and largeletter indices the same
'letter' => 'First Class Letter',
'largeletter' => 'First Class Large Letter',
'secondclassletter' => 'Second Class Letter',
'secondclasslargeletter' => 'Second Class Large Letter',

'secondclass' => 'Second Class Parcel',
'secondclassrecordedsignedfor' => 'Second Class Parcel (Signed for)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ class Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Firstclass
extends Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Abstract {

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

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

Expand All @@ -34,7 +35,8 @@ protected function _getRateFile() {
$weight = $this->_getWeight();

if ($weight <= 2000) {
if (Mage::getStoreConfig('carriers/royalmail/parcel_size') == Meanbee_Royalmail_Model_Parcelsize::SMALL) {
if (Mage::getStoreConfig('carriers/royalmail/parcel_size') == Meanbee_Royalmail_Model_Parcelsize::SMALL ||
Mage::getStoreConfig('carriers/royalmail/parcel_size') == "") {
return 'firstclass_small';
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ class Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Internationaleconomy
extends Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Abstract {

public function getRates() {
if($this->_getCountry() !== 'GB') {
$helper = Mage::helper('royalmail');
if ($helper->getWorldZone($this->_getCountry()) !== Meanbee_Royalmail_Helper_Data::WORLD_ZONE_GB) {
return $this->_loadCsv('internationaleconomy');
}
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,34 @@ public function getRates() {
if($weight > $this->maxWeight) {
return null;
}
if($country != 'GB') {
switch($worldZone) {
case 'eu':
case 'noneu':
$rates = $_helper->addAdditionalWeightCharges(
$this->_getEuropeRates(),
$this->additionalChargeEurope,
$weight
);
break;
case 'wz1':
$rates = $_helper->addAdditionalWeightCharges(
$this->_getWz1Rates(),
$this->additionalChargeWz1,
$weight
);
break;
case 'wz2':
$rates = $_helper->addAdditionalWeightCharges(
$this->_getWz2Rates(),
$this->additionalChargeWz2,
$weight
);
break;
}
return $rates;
}

return null;
switch($worldZone) {
case 'gb':
return null;
case 'eu':
case 'noneu':
$rates = $_helper->addAdditionalWeightCharges(
$this->_getEuropeRates(),
$this->additionalChargeEurope,
$weight
);
break;
case 'wz1':
$rates = $_helper->addAdditionalWeightCharges(
$this->_getWz1Rates(),
$this->additionalChargeWz1,
$weight
);
break;
case 'wz2':
$rates = $_helper->addAdditionalWeightCharges(
$this->_getWz2Rates(),
$this->additionalChargeWz2,
$weight
);
break;
}
return $rates;
}

public function calculateRate($weight) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,60 +45,59 @@ public function getRates() {
return null;
}

if($country != 'GB') {
switch($worldZone) {
case 'eu':
$rates = $_helper->addAdditionalWeightCharges(
$_helper->addInsuranceCharges(
$this->_getEuRates(),
$this->additionalInsuranceChargeEu,
$this->getCartTotal(),
$this->insureOver
),
$this->additionalChargeEu,
$weight
);
break;
case 'noneu':
$rates = $_helper->addAdditionalWeightCharges(
$_helper->addInsuranceCharges(
$this->_getNonEuRates(),
$this->additionalInsuranceChargeNonEu,
$this->getCartTotal(),
$this->insureOver
),
$this->additionalChargeNonEu,
$weight
);
break;
case 'wz1':
$rates = $_helper->addAdditionalWeightCharges(
$_helper->addInsuranceCharges(
$this->_getWz1Rates(),
$this->additionalInsuranceChargeWz1,
$this->getCartTotal(),
$this->insureOver
),
$this->additionalChargeWz1,
$weight
);
break;
case 'wz2':
$rates = $_helper->addAdditionalWeightCharges(
$_helper->addInsuranceCharges(
$this->_getWz2Rates(),
$this->additionalInsuranceChargeWz2,
$this->getCartTotal(),
$this->insureOver
),
$this->additionalChargeWz2,
$weight
);
break;
}
return $rates;
switch($worldZone) {
case 'gb':
return null;
case 'eu':
$rates = $_helper->addAdditionalWeightCharges(
$_helper->addInsuranceCharges(
$this->_getEuRates(),
$this->additionalInsuranceChargeEu,
$this->getCartTotal(),
$this->insureOver
),
$this->additionalChargeEu,
$weight
);
break;
case 'noneu':
$rates = $_helper->addAdditionalWeightCharges(
$_helper->addInsuranceCharges(
$this->_getNonEuRates(),
$this->additionalInsuranceChargeNonEu,
$this->getCartTotal(),
$this->insureOver
),
$this->additionalChargeNonEu,
$weight
);
break;
case 'wz1':
$rates = $_helper->addAdditionalWeightCharges(
$_helper->addInsuranceCharges(
$this->_getWz1Rates(),
$this->additionalInsuranceChargeWz1,
$this->getCartTotal(),
$this->insureOver
),
$this->additionalChargeWz1,
$weight
);
break;
case 'wz2':
$rates = $_helper->addAdditionalWeightCharges(
$_helper->addInsuranceCharges(
$this->_getWz2Rates(),
$this->additionalInsuranceChargeWz2,
$this->getCartTotal(),
$this->insureOver
),
$this->additionalChargeWz2,
$weight
);
break;
}
return null;
return $rates;
}

public function calculateRate($weight) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ class Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Largeletter
extends Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Abstract {

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ class Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Letter
extends Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Abstract {

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ class Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Secondclass
extends Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Abstract {

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

if ($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,33 @@
<?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 Limited (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_Secondclasslargeletter
extends Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Abstract {

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

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,33 @@
<?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 Limited (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_Secondclassletter
extends Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Abstract {

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

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 @@ -21,9 +21,10 @@ class Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Specialdelivery9am
extends Meanbee_Royalmail_Model_Shipping_Carrier_Royalmail_Abstract {

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

if ($this->_getCountry() == 'GB') {
if ($helper->getWorldZone($this->_getCountry()) == 'gb' && $this->_getCountry() != "GG") {
return $rates;
}

Expand Down
Loading

0 comments on commit cf447fc

Please sign in to comment.