diff --git a/src/app/code/community/Brander/PaymentFee/Helper/Data.php b/src/app/code/community/Brander/PaymentFee/Helper/Data.php index 66e93a1..254ffe7 100644 --- a/src/app/code/community/Brander/PaymentFee/Helper/Data.php +++ b/src/app/code/community/Brander/PaymentFee/Helper/Data.php @@ -31,12 +31,17 @@ public function isEnabled() { /** * Retrieve Store Config + * * @param string $field + * @param null|int $storeId * @return mixed|null */ - public function getConfig($field = '') { + public function getConfig($field = '', $storeId=null) { if ($field) { - return Mage::getStoreConfig(self::XML_PATH_SYSTEM_CONFIG . $field, $this->getCurrentStoreId()); + if ($storeId ==null) { + $storeId = $this->getCurrentStoreId(); + } + return Mage::getStoreConfig(self::XML_PATH_SYSTEM_CONFIG . $field, $storeId); } return NULL; @@ -52,12 +57,14 @@ public function getFeeType() { /** * Retrieve and unserialize Payment Method and their Fees array from Store Config + * + * @param null|int $storeId * @return array */ - public function getFee() { + public function getFee($storeId = null) { if (is_null($this->fee)) { - $fees = (array)unserialize($this->getConfig('fee')); - foreach ($fees as $fee) { + $fees = (array)unserialize($this->getConfig('fee', $storeId)); + foreach ((array)$fees as $fee) { $this->fee[$fee['payment_method']] = array( 'fee' => $fee['fee'], 'description' => $fee['description'] diff --git a/src/app/code/community/Brander/PaymentFee/Model/Fee.php b/src/app/code/community/Brander/PaymentFee/Model/Fee.php index df108e7..060577c 100644 --- a/src/app/code/community/Brander/PaymentFee/Model/Fee.php +++ b/src/app/code/community/Brander/PaymentFee/Model/Fee.php @@ -21,20 +21,15 @@ class Brander_PaymentFee_Model_Fee extends Mage_Core_Model_Abstract { */ public $methodFee = NULL; - /** - * Constructor - */ - public function __construct() { - $this->_getMethodFee(); - } - /** * Retrieve Payment Method Fees from Store Config + * + * @param null|int $storeId * @return array */ - protected function _getMethodFee() { + protected function _getMethodFee($storeId = null) { if (is_null($this->methodFee)) { - $this->methodFee = Mage::helper('payment_fee')->getFee(); + $this->methodFee = Mage::helper('payment_fee')->getFee($storeId); } return $this->methodFee; @@ -73,6 +68,8 @@ public function getFee(Mage_Sales_Model_Quote_Address $address) { /* @var $quote Mage_Sales_Model_Quote */ $quote = $address->getQuote(); $method = $quote->getPayment()->getMethod(); + + $this->_getMethodFee($quote->getStoreId()); $fee = $this->methodFee[$method]['fee']; $feeType = $helper->getFeeType(); if ($feeType == Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_FIXED) { @@ -101,6 +98,9 @@ public function getTotalTitle($method = '', Mage_Sales_Model_Quote $quote = null if (!$method) { $method = $quote->getPayment()->getMethod(); } + + $this->_getMethodFee($quote->getStoreId()); + if ($method) { if (isset($this->methodFee[$method]) && $this->methodFee[$method]['description']) { $title = $this->methodFee[$method]['description']; @@ -114,4 +114,4 @@ public function getTotalTitle($method = '', Mage_Sales_Model_Quote $quote = null return $title; } -} \ No newline at end of file +}