CashOnDelivery - Version 1.0.8

Version Notes

- Refactored the totals handling and added CoD totals to creditmemos and guest orders
- Fixed compatibility issues

Download this release

Release Info

Developer Magento Core Team
Extension CashOnDelivery
Version 1.0.8
Comparing to
See all releases


Code changes from version 1.0.6 to 1.0.8

Files changed (48) hide show
  1. app/code/community/Phoenix/CashOnDelivery/Block/Adminhtml/Sales/Creditmemo/Create/Totals.php +50 -0
  2. app/code/community/Phoenix/CashOnDelivery/Block/Adminhtml/Sales/Order/Create/Totals/Cod.php +39 -17
  3. app/code/community/Phoenix/CashOnDelivery/Block/Adminhtml/Sales/Order/Creditmemo/Totals/Cod.php +0 -36
  4. app/code/community/Phoenix/CashOnDelivery/Block/Checkout/Cod.php +6 -7
  5. app/code/community/Phoenix/CashOnDelivery/Block/Form.php +12 -8
  6. app/code/community/Phoenix/CashOnDelivery/Block/Info.php +29 -14
  7. app/code/community/Phoenix/CashOnDelivery/Block/Invoice/Totals/Cod.php +0 -55
  8. app/code/community/Phoenix/CashOnDelivery/Block/Order/Totals/Cod.php +0 -54
  9. app/code/community/Phoenix/CashOnDelivery/Block/Totals/Abstract.php +127 -0
  10. app/code/community/Phoenix/CashOnDelivery/Block/Totals/Creditmemo.php +38 -0
  11. app/code/community/Phoenix/CashOnDelivery/Block/Totals/Invoice.php +37 -0
  12. app/code/community/Phoenix/CashOnDelivery/Block/Totals/Order.php +37 -0
  13. app/code/community/Phoenix/CashOnDelivery/Helper/Data.php +77 -17
  14. app/code/community/Phoenix/CashOnDelivery/Model/CashOnDelivery.php +88 -46
  15. app/code/community/Phoenix/CashOnDelivery/Model/Creditmemo/Total.php +0 -68
  16. app/code/community/Phoenix/CashOnDelivery/Model/Observer.php +70 -18
  17. app/code/community/Phoenix/CashOnDelivery/Model/Sales/Creditmemo/Tax.php +62 -0
  18. app/code/community/Phoenix/CashOnDelivery/Model/Sales/Creditmemo/Total.php +58 -0
  19. app/code/community/Phoenix/CashOnDelivery/Model/{Invoice → Sales/Invoice}/Tax.php +26 -18
  20. app/code/community/Phoenix/CashOnDelivery/Model/{Invoice → Sales/Invoice}/Total.php +14 -18
  21. app/code/community/Phoenix/CashOnDelivery/Model/Sales/Pdf/Cod.php +26 -29
  22. app/code/community/Phoenix/CashOnDelivery/Model/{Quote → Sales/Quote}/TaxTotal.php +6 -10
  23. app/code/community/Phoenix/CashOnDelivery/Model/{Quote → Sales/Quote}/Total.php +4 -4
  24. app/code/community/Phoenix/CashOnDelivery/Model/Source/AvailableShipmentMethods.php +3 -2
  25. app/code/community/Phoenix/CashOnDelivery/Model/Source/CostType.php +32 -0
  26. app/code/community/Phoenix/CashOnDelivery/etc/config.xml +69 -47
  27. app/code/community/Phoenix/CashOnDelivery/etc/system.xml +48 -21
  28. app/code/community/Phoenix/CashOnDelivery/sql/cashondelivery_setup/mysql4-install-0.2.0.php +1 -10
  29. app/code/community/Phoenix/CashOnDelivery/sql/cashondelivery_setup/mysql4-upgrade-0.2.0-0.2.1.php +1 -10
  30. app/code/community/Phoenix/CashOnDelivery/sql/cashondelivery_setup/mysql4-upgrade-0.3.2-0.3.3.php +1 -1
  31. app/code/community/Phoenix/CashOnDelivery/sql/cashondelivery_setup/mysql4-upgrade-0.4.6-0.4.7.php +1 -1
  32. app/code/community/Phoenix/CashOnDelivery/sql/cashondelivery_setup/mysql4-upgrade-1.0.7-1.0.8.php +39 -0
  33. app/design/adminhtml/default/default/layout/cashondelivery.xml +0 -102
  34. app/design/adminhtml/default/default/layout/phoenix/cashondelivery.xml +72 -0
  35. app/design/adminhtml/default/default/template/{cashondelivery → phoenix/cashondelivery}/form.phtml +5 -1
  36. app/design/adminhtml/default/default/template/{cashondelivery → phoenix/cashondelivery}/info.phtml +8 -4
  37. app/design/adminhtml/default/default/template/{cashondelivery → phoenix/cashondelivery}/pdf/info.phtml +5 -5
  38. app/design/adminhtml/default/default/template/{cashondelivery → phoenix/cashondelivery}/sales/order/create/totals/cod.phtml +1 -1
  39. app/design/frontend/base/default/layout/cashondelivery.xml +0 -65
  40. app/design/frontend/base/default/layout/phoenix/cashondelivery.xml +113 -0
  41. app/design/frontend/base/default/template/{cashondelivery → phoenix/cashondelivery}/checkout/cod.phtml +2 -1
  42. app/design/frontend/base/default/template/{cashondelivery → phoenix/cashondelivery}/form.phtml +6 -6
  43. app/design/frontend/base/default/template/{cashondelivery → phoenix/cashondelivery}/info.phtml +4 -4
  44. app/etc/modules/Phoenix_CashOnDelivery.xml +1 -1
  45. app/locale/de_DE/Phoenix_CashOnDelivery.csv +8 -2
  46. app/locale/en_US/Phoenix_CashOnDelivery.csv +6 -0
  47. js/phoenix/cashondelivery/sales.js +20 -1
  48. package.xml +6 -5
app/code/community/Phoenix/CashOnDelivery/Block/Adminhtml/Sales/Creditmemo/Create/Totals.php ADDED
@@ -0,0 +1,50 @@
1
+ <?php
2
+ class Phoenix_CashOnDelivery_Block_Adminhtml_Sales_Creditmemo_Create_Totals extends Mage_Adminhtml_Block_Template
3
+ {
4
+ /**
5
+ * Holds the creditmemo object.
6
+ * @var Mage_Sales_Model_Order_Creditmemo
7
+ */
8
+ protected $_source;
9
+
10
+ /**
11
+ * Initialize creditmemo CoD totals
12
+ *
13
+ * @return Phoenix_CashOnDelivery_Block_Adminhtml_Sales_Creditmemo_Create_Totals
14
+ */
15
+ public function initTotals()
16
+ {
17
+ $parent = $this->getParentBlock();
18
+ $this->_source = $parent->getSource();
19
+ $total = new Varien_Object(array(
20
+ 'code' => 'phoenix_cashondelivery_fee',
21
+ 'value' => $this->getCodAmount(),
22
+ 'base_value'=> $this->getCodAmount(),
23
+ 'label' => $this->helper('phoenix_cashondelivery')->__('Refund Cash on Delivery fee')
24
+ ));
25
+
26
+ $parent->addTotalBefore($total, 'shipping');
27
+ return $this;
28
+ }
29
+
30
+ /**
31
+ * Getter for the creditmemo object.
32
+ *
33
+ * @return Mage_Sales_Model_Order_Creditmemo
34
+ */
35
+ public function getSource()
36
+ {
37
+ return $this->_source;
38
+ }
39
+
40
+ /**
41
+ * Get CoD fee amount for actual invoice.
42
+ * @return float
43
+ */
44
+ public function getCodAmount()
45
+ {
46
+ $codFee = $this->_source->getCodFee() + $this->_source->getCodTaxAmount();
47
+
48
+ return Mage::app()->getStore()->roundPrice($codFee);
49
+ }
50
+ }
app/code/community/Phoenix/CashOnDelivery/Block/Adminhtml/Sales/Order/Create/Totals/Cod.php CHANGED
@@ -14,7 +14,7 @@
14
*
15
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
- * @copyright Copyright (c) 2010 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
18
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
@@ -22,45 +22,67 @@
22
* COD fee Total Row Renderer
23
*
24
*/
25
-
26
- class Phoenix_CashOnDelivery_Block_Adminhtml_Sales_Order_Create_Totals_Cod
27
- extends Mage_Adminhtml_Block_Sales_Order_Create_Totals_Default
28
{
29
- protected $_template = 'cashondelivery/sales/order/create/totals/cod.phtml';
30
31
/**
32
- * Check if we need display COD fee include and exlude tax
33
*
34
* @return bool
35
*/
36
public function displayBoth()
37
{
38
- return Mage::helper('cashondelivery')->displayCodBothPrices();
39
}
40
41
/**
42
- * Check if we need display COD fee include tax
43
*
44
* @return bool
45
*/
46
public function displayIncludeTax()
47
{
48
- return Mage::helper('cashondelivery')->displayCodFeeIncludingTax();
49
}
50
51
/**
52
- * Get COD fee include tax
53
*
54
* @return float
55
*/
56
public function getCodFeeIncludeTax()
57
{
58
- return $this->getTotal()->getAddress()->getCodFee() +
59
- $this->getTotal()->getAddress()->getCodTaxAmount();
60
}
61
62
/**
63
- * Get COD fee exclude tax
64
*
65
* @return float
66
*/
@@ -70,22 +92,22 @@ class Phoenix_CashOnDelivery_Block_Adminhtml_Sales_Order_Create_Totals_Cod
70
}
71
72
/**
73
- * Get label for COD fee include tax
74
*
75
* @return float
76
*/
77
public function getIncludeTaxLabel()
78
{
79
- return $this->helper('cashondelivery')->__('Cash on Delivery fee Incl. Tax');
80
}
81
82
/**
83
- * Get label for COD fee exclude tax
84
*
85
* @return float
86
*/
87
public function getExcludeTaxLabel()
88
{
89
- return $this->helper('cashondelivery')->__('Cash on Delivery fee Excl. Tax');
90
}
91
}
14
*
15
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
18
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
22
* COD fee Total Row Renderer
23
*
24
*/
25
+ class Phoenix_CashOnDelivery_Block_Adminhtml_Sales_Order_Create_Totals_Cod extends Mage_Adminhtml_Block_Sales_Order_Create_Totals_Default
26
{
27
+ /**
28
+ * Path to template file in theme.
29
+ *
30
+ * @var string
31
+ */
32
+ protected $_template = 'phoenix/cashondelivery/sales/order/create/totals/cod.phtml';
33
+
34
+ /**
35
+ * Variable to lazy load the helper.
36
+ *
37
+ * @var Phoenix_CashOnDelivery_Helper_Data
38
+ */
39
+ protected $_helper;
40
+
41
+ /**
42
+ * Get the helper object.
43
+ *
44
+ * @return Phoenix_CashOnDelivery_Helper_Data
45
+ */
46
+ protected function _getHelper()
47
+ {
48
+ if (!$this->_helper) {
49
+ $this->_helper = Mage::helper('phoenix_cashondelivery');
50
+ }
51
+ return $this->_helper;
52
+ }
53
54
/**
55
+ * Check if we need to display the CoD fee including and excluding the tax.
56
*
57
* @return bool
58
*/
59
public function displayBoth()
60
{
61
+ return $this->_getHelper()->displayCodBothPrices();
62
}
63
64
/**
65
+ * Check if we need to display the CoD fee including the tax.
66
*
67
* @return bool
68
*/
69
public function displayIncludeTax()
70
{
71
+ return $this->_getHelper()->displayCodFeeIncludingTax();
72
}
73
74
/**
75
+ * Get the CoD fee including the tax.
76
*
77
* @return float
78
*/
79
public function getCodFeeIncludeTax()
80
{
81
+ return $this->getTotal()->getAddress()->getCodFee() + $this->getTotal()->getAddress()->getCodTaxAmount();
82
}
83
84
/**
85
+ * Get the CoD fee excluding the tax.
86
*
87
* @return float
88
*/
92
}
93
94
/**
95
+ * Get the label for the CoD fee including the tax.
96
*
97
* @return float
98
*/
99
public function getIncludeTaxLabel()
100
{
101
+ return $this->_getHelper()->__('Cash on Delivery fee Incl. Tax');
102
}
103
104
/**
105
+ * Get the label for the CoD fee excluding the tax.
106
*
107
* @return float
108
*/
109
public function getExcludeTaxLabel()
110
{
111
+ return $this->_getHelper()->__('Cash on Delivery fee Excl. Tax');
112
}
113
}
app/code/community/Phoenix/CashOnDelivery/Block/Adminhtml/Sales/Order/Creditmemo/Totals/Cod.php DELETED
@@ -1,36 +0,0 @@
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 available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category Phoenix
12
- * @package Phoenix_CashOnDelivery
13
- * @copyright Copyright (c) 2008-2009 Andrej Sinicyn, Mik3e
14
- * @copyright Copyright (c) 2010 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- class Phoenix_CashOnDelivery_Block_Adminhtml_Sales_Order_Creditmemo_Totals_Cod extends Mage_Core_Block_Abstract
19
- {
20
-
21
- public function initTotals()
22
- {
23
- $parent = $this->getParentBlock();
24
- if ($this->_invoice->getCodFee()) {
25
- $cod = new Varien_Object();
26
- $cod->setLabel($this->__('Refund Cash on Delivery fee'));
27
- $cod->setValue($parent->getSource()->getCodFee());
28
- $cod->setBaseValue($parent->getSource()->getBaseCodFee());
29
- $cod->setCode('cod_fee');
30
- $parent->addTotalBefore($cod, 'adjustment_positive');
31
- }
32
-
33
- return $this;
34
- }
35
-
36
- }
app/code/community/Phoenix/CashOnDelivery/Block/Checkout/Cod.php CHANGED
@@ -14,7 +14,7 @@
14
*
15
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
- * @copyright Copyright (c) 2010 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
18
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
@@ -22,10 +22,9 @@
22
* COD fee Total Row Renderer
23
*
24
*/
25
-
26
class Phoenix_CashOnDelivery_Block_Checkout_Cod extends Mage_Checkout_Block_Total_Default
27
{
28
- protected $_template = 'cashondelivery/checkout/cod.phtml';
29
30
/**
31
* Check if we need display COD fee include and exlude tax
@@ -34,7 +33,7 @@ class Phoenix_CashOnDelivery_Block_Checkout_Cod extends Mage_Checkout_Block_Tota
34
*/
35
public function displayBoth()
36
{
37
- return Mage::helper('cashondelivery')->displayCodBothPrices();
38
}
39
40
/**
@@ -44,7 +43,7 @@ class Phoenix_CashOnDelivery_Block_Checkout_Cod extends Mage_Checkout_Block_Tota
44
*/
45
public function displayIncludeTax()
46
{
47
- return Mage::helper('cashondelivery')->displayCodFeeIncludingTax();
48
}
49
50
/**
@@ -82,7 +81,7 @@ class Phoenix_CashOnDelivery_Block_Checkout_Cod extends Mage_Checkout_Block_Tota
82
*/
83
public function getIncludeTaxLabel()
84
{
85
- return $this->helper('cashondelivery')->__('Cash on Delivery fee (Incl.Tax)');
86
}
87
88
/**
@@ -92,6 +91,6 @@ class Phoenix_CashOnDelivery_Block_Checkout_Cod extends Mage_Checkout_Block_Tota
92
*/
93
public function getExcludeTaxLabel()
94
{
95
- return $this->helper('cashondelivery')->__('Cash on Delivery fee (Excl.Tax)');
96
}
97
}
14
*
15
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
18
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
22
* COD fee Total Row Renderer
23
*
24
*/
25
class Phoenix_CashOnDelivery_Block_Checkout_Cod extends Mage_Checkout_Block_Total_Default
26
{
27
+ protected $_template = 'phoenix/cashondelivery/checkout/cod.phtml';
28
29
/**
30
* Check if we need display COD fee include and exlude tax
33
*/
34
public function displayBoth()
35
{
36
+ return Mage::helper('phoenix_cashondelivery')->displayCodBothPrices();
37
}
38
39
/**
43
*/
44
public function displayIncludeTax()
45
{
46
+ return Mage::helper('phoenix_cashondelivery')->displayCodFeeIncludingTax();
47
}
48
49
/**
81
*/
82
public function getIncludeTaxLabel()
83
{
84
+ return $this->helper('phoenix_cashondelivery')->__('Cash on Delivery fee (Incl.Tax)');
85
}
86
87
/**
91
*/
92
public function getExcludeTaxLabel()
93
{
94
+ return $this->helper('phoenix_cashondelivery')->__('Cash on Delivery fee (Excl.Tax)');
95
}
96
}
app/code/community/Phoenix/CashOnDelivery/Block/Form.php CHANGED
@@ -5,24 +5,28 @@
5
* NOTICE OF LICENSE
6
*
7
* This source file is subject to the Open Software License (OSL 3.0)
8
- * that is available through the world-wide-web at this URL:
9
* http://opensource.org/licenses/osl-3.0.php
10
*
11
* @category Phoenix
12
* @package Phoenix_CashOnDelivery
13
* @copyright Copyright (c) 2008-2009 Andrej Sinicyn, Mik3e
14
- * @copyright Copyright (c) 2010 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
15
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
*/
17
18
class Phoenix_CashOnDelivery_Block_Form extends Mage_Payment_Block_Form
19
{
20
-
21
- protected function _construct()
22
- {
23
- parent::_construct();
24
- $this->setTemplate('cashondelivery/form.phtml');
25
- }
26
27
public function getQuote()
28
{
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
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
* @copyright Copyright (c) 2008-2009 Andrej Sinicyn, Mik3e
18
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
19
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
*/
21
22
class Phoenix_CashOnDelivery_Block_Form extends Mage_Payment_Block_Form
23
{
24
+ /**
25
+ * Path to template file in theme.
26
+ *
27
+ * @var string
28
+ */
29
+ protected $_template = 'phoenix/cashondelivery/form.phtml';
30
31
public function getQuote()
32
{
app/code/community/Phoenix/CashOnDelivery/Block/Info.php CHANGED
@@ -5,13 +5,17 @@
5
* NOTICE OF LICENSE
6
*
7
* This source file is subject to the Open Software License (OSL 3.0)
8
- * that is available through the world-wide-web at this URL:
9
* http://opensource.org/licenses/osl-3.0.php
10
*
11
* @category Phoenix
12
* @package Phoenix_CashOnDelivery
13
* @copyright Copyright (c) 2008-2009 Andrej Sinicyn, Mik3e
14
- * @copyright Copyright (c) 2010 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
15
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
*/
17
@@ -24,12 +28,12 @@ class Phoenix_CashOnDelivery_Block_Info extends Mage_Payment_Block_Info
24
protected function _construct()
25
{
26
parent::_construct();
27
- $this->setTemplate('cashondelivery/info.phtml');
28
}
29
30
public function toPdf()
31
{
32
- $this->setTemplate('cashondelivery/pdf/info.phtml');
33
return $this->toHtml();
34
}
35
@@ -44,8 +48,7 @@ class Phoenix_CashOnDelivery_Block_Info extends Mage_Payment_Block_Info
44
public function getCodFeeExclTax()
45
{
46
if ($_dataObject = $this->_getDataObject()) {
47
- $extraFeeExcl = $_dataObject->getCodFee() ?
48
- $this->_getPriceModel()->formatPrice($_dataObject->getCodFee()) : null;
49
return $extraFeeExcl;
50
}
51
return null;
@@ -54,8 +57,7 @@ class Phoenix_CashOnDelivery_Block_Info extends Mage_Payment_Block_Info
54
public function getCodFeeInclTax()
55
{
56
if ($_dataObject = $this->_getDataObject()) {
57
- $extraFeeIncl = $_dataObject->getCodFee() ?
58
- $this->_getPriceModel()->formatPrice($_dataObject->getCodFee()+$_dataObject->getCodTaxAmount()) : null;
59
return $extraFeeIncl;
60
}
61
return null;
@@ -64,9 +66,14 @@ class Phoenix_CashOnDelivery_Block_Info extends Mage_Payment_Block_Info
64
protected function _getDataObject()
65
{
66
if (!isset($this->_dataObject)) {
67
- if ($this->_dataObject = $this->getInfo()->getQuote()) {
68
- } elseif ($this->_dataObject = $this->getInfo()->getOrder()) {
69
}
70
}
71
return $this->_dataObject;
72
}
@@ -74,11 +81,19 @@ class Phoenix_CashOnDelivery_Block_Info extends Mage_Payment_Block_Info
74
protected function _getPriceModel()
75
{
76
if (!isset($this->_priceModel)) {
77
- if ($this->getInfo()->getQuote()) {
78
- $this->_priceModel = $this->getInfo()->getQuote()->getStore();
79
- } elseif ($this->getInfo()->getOrder()) {
80
- $this->_priceModel = $this->getInfo()->getOrder();
81
}
82
}
83
return $this->_priceModel;
84
}
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
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
* @copyright Copyright (c) 2008-2009 Andrej Sinicyn, Mik3e
18
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
19
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
*/
21
28
protected function _construct()
29
{
30
parent::_construct();
31
+ $this->setTemplate('phoenix/cashondelivery/info.phtml');
32
}
33
34
public function toPdf()
35
{
36
+ $this->setTemplate('phoenix/cashondelivery/pdf/info.phtml');
37
return $this->toHtml();
38
}
39
48
public function getCodFeeExclTax()
49
{
50
if ($_dataObject = $this->_getDataObject()) {
51
+ $extraFeeExcl = $_dataObject->getCodFee() ? $this->_getPriceModel()->formatPrice($_dataObject->getCodFee()) : null;
52
return $extraFeeExcl;
53
}
54
return null;
57
public function getCodFeeInclTax()
58
{
59
if ($_dataObject = $this->_getDataObject()) {
60
+ $extraFeeIncl = $_dataObject->getCodFee() ? $this->_getPriceModel()->formatPrice($_dataObject->getCodFee()+$_dataObject->getCodTaxAmount()) : null;
61
return $extraFeeIncl;
62
}
63
return null;
66
protected function _getDataObject()
67
{
68
if (!isset($this->_dataObject)) {
69
+
70
+ $dataObject = $this->getInfo()->getQuote();
71
+
72
+ if (!is_object($dataObject)) {
73
+ $dataObject = $this->getInfo()->getOrder();
74
}
75
+
76
+ $this->_dataObject = $dataObject;
77
}
78
return $this->_dataObject;
79
}
81
protected function _getPriceModel()
82
{
83
if (!isset($this->_priceModel)) {
84
+
85
+ $quote = $this->getInfo()->getQuote();
86
+ $priceModel = null;
87
+
88
+ if (is_object($quote)) {
89
+ $priceModel = $quote->getStore();
90
+ }
91
+
92
+ if (!$priceModel) {
93
+ $priceModel = $this->getInfo()->getOrder();
94
}
95
+
96
+ $this->_priceModel = $priceModel;
97
}
98
return $this->_priceModel;
99
}
app/code/community/Phoenix/CashOnDelivery/Block/Invoice/Totals/Cod.php DELETED
@@ -1,55 +0,0 @@
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 available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category Phoenix
12
- * @package Phoenix_CashOnDelivery
13
- * @copyright Copyright (c) 2008-2009 Andrej Sinicyn, Mik3e
14
- * @copyright Copyright (c) 2010 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- class Phoenix_CashOnDelivery_Block_Invoice_Totals_Cod extends Mage_Core_Block_Abstract
19
- {
20
-
21
- public function initTotals()
22
- {
23
- $parent = $this->getParentBlock();
24
- $this->_invoice = $parent->getInvoice();
25
- if ($this->_invoice->getCodFee()) {
26
- $cod = new Varien_Object();
27
- $cod->setLabel($this->__('Cash on Delivery fee'));
28
- $cod->setValue($this->_invoice->getCodFee());
29
- $cod->setBaseValue($this->_invoice->getBaseCodFee());
30
- $cod->setCode('cod_fee');
31
-
32
- if (Mage::helper('cashondelivery')->displayCodBothPrices()) {
33
- $cod->setLabel($this->__('Cash on Delivery fee (Excl.Tax)'));
34
-
35
- $codIncl = new Varien_Object();
36
- $codIncl->setLabel($this->__('Cash on Delivery fee (Incl.Tax)'));
37
- $codIncl->setValue($this->_invoice->getCodFee()+$this->_invoice->getCodTaxAmount());
38
- $codIncl->setBaseValue($this->_invoice->getBaseCodFee()+$this->_invoice->getBaseCodTaxAmount());
39
- $codIncl->setCode('cod_fee_incl');
40
-
41
- $parent->addTotalBefore($cod, 'tax');
42
- $parent->addTotalBefore($codIncl, 'tax');
43
- } elseif (Mage::helper('cashondelivery')->displayCodFeeIncludingTax()) {
44
- $cod->setValue($this->_invoice->getCodFee()+$this->_invoice->getCodTaxAmount());
45
- $cod->setBaseValue($this->_invoice->getBaseCodFee()+$this->_invoice->getBaseCodTaxAmount());
46
- $parent->addTotalBefore($cod, 'tax');
47
- } else {
48
- $parent->addTotalBefore($cod, 'tax');
49
- }
50
- }
51
-
52
- return $this;
53
- }
54
-
55
- }
app/code/community/Phoenix/CashOnDelivery/Block/Order/Totals/Cod.php DELETED
@@ -1,54 +0,0 @@
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 available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category Phoenix
12
- * @package Phoenix_CashOnDelivery
13
- * @copyright Copyright (c) 2008-2009 Andrej Sinicyn, Mik3e
14
- * @copyright Copyright (c) 2010 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- class Phoenix_CashOnDelivery_Block_Order_Totals_Cod extends Mage_Core_Block_Abstract
19
- {
20
-
21
- public function initTotals()
22
- {
23
- $parent = $this->getParentBlock();
24
- $this->_order = $parent->getOrder();
25
- if ($this->_order->getCodFee()) {
26
- $cod = new Varien_Object();
27
- $cod->setLabel($this->__('Cash on Delivery'));
28
- $cod->setValue($this->_order->getCodFee());
29
- $cod->setBaseValue($this->_order->getBaseCodFee());
30
- $cod->setCode('cod_fee');
31
-
32
- if (Mage::helper('cashondelivery')->displayCodBothPrices()) {
33
- $cod->setLabel($this->__('Cash on Delivery fee (Excl.Tax)'));
34
-
35
- $codIncl = new Varien_Object();
36
- $codIncl->setLabel($this->__('Cash on Delivery fee (Incl.Tax)'));
37
- $codIncl->setValue($this->_order->getCodFee()+$this->_order->getCodTaxAmount());
38
- $codIncl->setBaseValue($this->_order->getBaseCodFee()+$this->_order->getBaseCodTaxAmount());
39
- $codIncl->setCode('cod_fee_incl');
40
-
41
- $parent->addTotalBefore($cod, 'tax');
42
- $parent->addTotalBefore($codIncl, 'tax');
43
- } elseif (Mage::helper('cashondelivery')->displayCodFeeIncludingTax()) {
44
- $cod->setValue($this->_order->getCodFee()+$this->_order->getCodTaxAmount());
45
- $cod->setBaseValue($this->_order->getBaseCodFee()+$this->_order->getBaseCodTaxAmount());
46
- $parent->addTotalBefore($cod, 'tax');
47
- } else {
48
- $parent->addTotalBefore($cod, 'tax');
49
- }
50
- }
51
-
52
- return $this;
53
- }
54
- }
app/code/community/Phoenix/CashOnDelivery/Block/Totals/Abstract.php ADDED
@@ -0,0 +1,127 @@
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
+ * @category Phoenix
16
+ * @package Phoenix_CashOnDelivery
17
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_CashOnDelivery_Block_Totals_Abstract extends Mage_Core_Block_Abstract
22
+ {
23
+ /**
24
+ * Holds the correct object from where we get the CoD fees and taxes from.
25
+ * For example this could be the order or invoice object.
26
+ *
27
+ * @var Varien_Object
28
+ */
29
+ protected $_totalObject;
30
+
31
+ /**
32
+ * Holds the correct parent block from which we get the total object and set the totals.
33
+ *
34
+ * @var Mage_Core_Block_Abstract
35
+ */
36
+ protected $_parentBlock;
37
+
38
+ /**
39
+ * Generate and add the CoD totals to the parent block.
40
+ *
41
+ * @return Phoenix_CashOnDelivery_Block_Totals_Abstract
42
+ */
43
+ public function initTotals()
44
+ {
45
+ $this->_prepareTotals();
46
+
47
+ if ($this->_totalObject->getCodFee()) {
48
+
49
+ $label = $this->__('Cash on Delivery fee');
50
+ $value = $this->_totalObject->getCodFee();
51
+ $baseValue = $this->_totalObject->getBaseCodFee();
52
+ $code = 'phoenix_cashondelivery_fee';
53
+
54
+ if (Mage::helper('phoenix_cashondelivery')->displayCodBothPrices()) {
55
+
56
+ $label = $this->__('Cash on Delivery fee (Excl.Tax)');
57
+
58
+ $totalInclLabel = $this->__('Cash on Delivery fee (Incl.Tax)');
59
+ $totalInclValue = $this->_totalObject->getCodFee() + $this->_totalObject->getCodTaxAmount();
60
+ $totalInclBaseValue = $this->_totalObject->getBaseCodFee() + $this->_totalObject->getBaseCodTaxAmount();
61
+ $totalInclCode = 'phoenix_cashondelivery_fee_incl';
62
+
63
+ } elseif (Mage::helper('phoenix_cashondelivery')->displayCodFeeIncludingTax()) {
64
+
65
+ $value = $this->_totalObject->getCodFee() + $this->_totalObject->getCodTaxAmount();
66
+ $baseValue = $this->_totalObject->getBaseCodFee() + $this->_totalObject->getBaseCodTaxAmount();
67
+ }
68
+
69
+ $totalObject = $this->_getTotalObject($label, $value, $baseValue, $code);
70
+ $this->_addTotalToParent($totalObject);
71
+
72
+ if (isset($totalInclLabel)) {
73
+ $totalInclObject = $this->_getTotalObject($totalInclLabel, $totalInclValue, $totalInclBaseValue, $totalInclCode);
74
+ $this->_addTotalToParent($totalInclObject, 'phoenix_cashondelivery_fee');
75
+ }
76
+ }
77
+ return $this;
78
+ }
79
+
80
+ /**
81
+ * To be able to abstract the CoD totals we need an own method to set the right objects.
82
+ *
83
+ * @return Phoenix_CashOnDelivery_Block_Totals_Abstract
84
+ */
85
+ protected function _prepareTotals()
86
+ {
87
+ return $this;
88
+ }
89
+
90
+ /**
91
+ * Generate an Varien_Object which could be set as total to the parent block.
92
+ *
93
+ * @param $label string
94
+ * @param $value string
95
+ * @param $baseValue string
96
+ * @param $code string
97
+ * @return Varien_Object
98
+ */
99
+ protected function _getTotalObject($label, $value, $baseValue, $code)
100
+ {
101
+ $total = new Varien_Object();
102
+ $total->setLabel($label)
103
+ ->setValue($value)
104
+ ->setBaseValue($baseValue)
105
+ ->setCode($code);
106
+
107
+ return $total;
108
+ }
109
+
110
+ /**
111
+ * Add an Varien_Object, which holds the total values, to the parent block.
112
+ *
113
+ * @param $total Varien_Object
114
+ * @param $after null|string
115
+ * @return Phoenix_CashOnDelivery_Block_Totals_Abstract
116
+ */
117
+ protected function _addTotalToParent($total, $after = null)
118
+ {
119
+ if (!$after) {
120
+ $after = Mage::helper('phoenix_cashondelivery')->getTotalAfterPosition();
121
+ }
122
+
123
+ $this->_parentBlock->addTotal($total, $after);
124
+
125
+ return $this;
126
+ }
127
+ }
app/code/community/Phoenix/CashOnDelivery/Block/Totals/Creditmemo.php ADDED
@@ -0,0 +1,38 @@
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
+ * @category Phoenix
16
+ * @package Phoenix_CashOnDelivery
17
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_CashOnDelivery_Block_Totals_Creditmemo extends Phoenix_CashOnDelivery_Block_Totals_Abstract
22
+ {
23
+ /**
24
+ * Set the correct parent block and the object from which we get / set our total data.
25
+ *
26
+ * @return Phoenix_CashOnDelivery_Block_Invoice_Totals_Cod
27
+ */
28
+ protected function _prepareTotals()
29
+ {
30
+ parent::_prepareTotals();
31
+
32
+ $this->_parentBlock = $this->getParentBlock();
33
+ $this->_totalObject = $this->_parentBlock->getSource();
34
+
35
+ return $this;
36
+ }
37
+
38
+ }
app/code/community/Phoenix/CashOnDelivery/Block/Totals/Invoice.php ADDED
@@ -0,0 +1,37 @@
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
+ * @category Phoenix
16
+ * @package Phoenix_CashOnDelivery
17
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_CashOnDelivery_Block_Totals_Invoice extends Phoenix_CashOnDelivery_Block_Totals_Abstract
22
+ {
23
+ /**
24
+ * Set the correct parent block and the object from which we get / set our total data.
25
+ *
26
+ * @return Phoenix_CashOnDelivery_Block_Invoice_Totals_Cod
27
+ */
28
+ protected function _prepareTotals()
29
+ {
30
+ parent::_prepareTotals();
31
+
32
+ $this->_parentBlock = $this->getParentBlock();
33
+ $this->_totalObject = $this->_parentBlock->getInvoice();
34
+
35
+ return $this;
36
+ }
37
+ }
app/code/community/Phoenix/CashOnDelivery/Block/Totals/Order.php ADDED
@@ -0,0 +1,37 @@
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
+ * @category Phoenix
16
+ * @package Phoenix_CashOnDelivery
17
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_CashOnDelivery_Block_Totals_Order extends Phoenix_CashOnDelivery_Block_Totals_Abstract
22
+ {
23
+ /**
24
+ * Set the correct parent block and the object from which we get / set our total data.
25
+ *
26
+ * @return Phoenix_CashOnDelivery_Block_Order_Totals_Cod
27
+ */
28
+ protected function _prepareTotals()
29
+ {
30
+ parent::_prepareTotals();
31
+
32
+ $this->_parentBlock = $this->getParentBlock();
33
+ $this->_totalObject = $this->_parentBlock->getOrder();
34
+
35
+ return $this;
36
+ }
37
+ }
app/code/community/Phoenix/CashOnDelivery/Helper/Data.php CHANGED
@@ -1,5 +1,4 @@
1
<?php
2
-
3
/**
4
* Magento
5
*
@@ -15,33 +14,64 @@
15
*
16
* @category Phoenix
17
* @package Phoenix_CashOnDelivery
18
- * @copyright Copyright (c) 2010 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
19
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
*/
21
22
class Phoenix_CashOnDelivery_Helper_Data extends Mage_Core_Helper_Data
23
{
24
25
- protected $_codPriceIncludesTax;
26
27
public function codPriceIncludesTax($store = null)
28
{
29
- $storeId = Mage::app()->getStore($store)->getId();
30
if (!isset($this->_codPriceIncludesTax[$storeId])) {
31
- $this->_codPriceIncludesTax[$storeId] = (int)Mage::getStoreConfig(
32
- Phoenix_CashOnDelivery_Model_Quote_TaxTotal::CONFIG_XML_PATH_COD_INCLUDES_TAX,
33
- $store
34
- );
35
}
36
return $this->_codPriceIncludesTax[$storeId];
37
}
38
39
- public function getCodTaxClass($store)
40
{
41
- return (int)Mage::getStoreConfig(
42
- Phoenix_CashOnDelivery_Model_Quote_TaxTotal::CONFIG_XML_PATH_COD_TAX_CLASS,
43
- $store
44
- );
45
}
46
47
public function getCodPrice($price, $includingTax = null, $shippingAddress = null, $ctc = null, $store = null)
@@ -72,11 +102,10 @@ class Phoenix_CashOnDelivery_Helper_Data extends Mage_Core_Helper_Data
72
public function getCodFeeDisplayType($store = null)
73
{
74
$storeId = Mage::app()->getStore($store)->getId();
75
if (!isset($this->_shippingPriceDisplayType[$storeId])) {
76
- $this->_shippingPriceDisplayType[$storeId] = (int)Mage::getStoreConfig(
77
- Phoenix_CashOnDelivery_Model_Quote_TaxTotal::CONFIG_XML_PATH_DISPLAY_COD,
78
- $store
79
- );
80
}
81
return $this->_shippingPriceDisplayType[$storeId];
82
}
@@ -96,4 +125,35 @@ class Phoenix_CashOnDelivery_Helper_Data extends Mage_Core_Helper_Data
96
return $this->getCodFeeDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH;
97
}
98
99
}
1
<?php
2
/**
3
* Magento
4
*
14
*
15
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
18
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
21
class Phoenix_CashOnDelivery_Helper_Data extends Mage_Core_Helper_Data
22
{
23
+ /**
24
+ * Config path constants
25
+ */
26
+ const CONFIG_XML_PATH_COD_TAX_CLASS = 'tax/classes/phoenix_cashondelivery_tax_class';
27
+ const CONFIG_XML_PATH_COD_INCLUDES_TAX = 'tax/calculation/phoenix_cashondelivery_includes_tax';
28
+ const CONFIG_XML_PATH_DISPLAY_COD = 'tax/display/phoenix_cashondelivery_fee';
29
+
30
+
31
+ /**
32
+ * Instance variable for lazy load.
33
+ * @var array
34
+ */
35
+ protected $_codPriceIncludesTax = array();
36
37
+ /**
38
+ * Instance variable for lazy load.
39
+ * @var array
40
+ */
41
+ protected $_shippingPriceDisplayType = array();
42
43
+ /**
44
+ * Holds the total block which is before the CoD total block.
45
+ * @var string
46
+ */
47
+ protected $_getTotalAfterPosition;
48
+
49
+ /**
50
+ * Are the taxes included in the configured or calculated ( percentage ) Cash on Delivery fee?
51
+ *
52
+ * @param @param null|string|bool|int|Mage_Core_Model_Store $store
53
+ * @return int
54
+ */
55
public function codPriceIncludesTax($store = null)
56
{
57
+ $store = Mage::app()->getStore($store);
58
+ $storeId = $store->getId();
59
+
60
if (!isset($this->_codPriceIncludesTax[$storeId])) {
61
+ $this->_codPriceIncludesTax[$storeId] = (int)Mage::getStoreConfig(self::CONFIG_XML_PATH_COD_INCLUDES_TAX, $store);
62
}
63
return $this->_codPriceIncludesTax[$storeId];
64
}
65
66
+ /**
67
+ * Get the configured Tax class id.
68
+ *
69
+ * @param @param null|string|bool|int|Mage_Core_Model_Store $store
70
+ * @return int
71
+ */
72
+ public function getCodTaxClass($store = null)
73
{
74
+ return (int)Mage::getStoreConfig(self::CONFIG_XML_PATH_COD_TAX_CLASS, $store);
75
}
76
77
public function getCodPrice($price, $includingTax = null, $shippingAddress = null, $ctc = null, $store = null)
102
public function getCodFeeDisplayType($store = null)
103
{
104
$storeId = Mage::app()->getStore($store)->getId();
105
+
106
if (!isset($this->_shippingPriceDisplayType[$storeId])) {
107
+
108
+ $this->_shippingPriceDisplayType[$storeId] = (int)Mage::getStoreConfig(self::CONFIG_XML_PATH_DISPLAY_COD, $store);
109
}
110
return $this->_shippingPriceDisplayType[$storeId];
111
}
125
return $this->getCodFeeDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH;
126
}
127
128
+ /**
129
+ * Get the configured total position for the backend views.
130
+ * If nothing is set it will place it after the subtotal.
131
+ *
132
+ * @ return string
133
+ */
134
+ public function getTotalAfterPosition()
135
+ {
136
+ if (!$this->_getTotalAfterPosition) {
137
+
138
+ $config = Mage::app()->getConfig()->getXpath('//sales/totals_sort');
139
+ $positions = end($config);
140
+ $positions = $positions->asArray();
141
+ $codPos = $positions['phoenix_cashondelivery'];
142
+ $beforeTotal = 'subtotal';
143
+
144
+ asort($positions);
145
+
146
+ while($val = current($positions)) {
147
+ if ($val == $codPos) {
148
+ prev($positions);
149
+ $beforeTotal = key($positions);
150
+ break;
151
+ }
152
+ next($positions);
153
+ }
154
+ $this->_getTotalAfterPosition = $beforeTotal;
155
+ }
156
+
157
+ return $this->_getTotalAfterPosition;
158
+ }
159
}
app/code/community/Phoenix/CashOnDelivery/Model/CashOnDelivery.php CHANGED
@@ -1,49 +1,82 @@
1
<?php
2
-
3
/**
4
* Magento
5
*
6
* NOTICE OF LICENSE
7
*
8
* This source file is subject to the Open Software License (OSL 3.0)
9
- * that is available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
* @category Phoenix
13
* @package Phoenix_CashOnDelivery
14
* @copyright Copyright (c) 2008-2009 Andrej Sinicyn, Mik3e
15
- * @copyright Copyright (c) 2010 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
19
class Phoenix_CashOnDelivery_Model_CashOnDelivery extends Mage_Payment_Model_Method_Abstract
20
{
21
/**
22
* unique internal payment method identifier
23
*
24
* @var string [a-z0-9_]
25
*/
26
- protected $_code = 'cashondelivery';
27
protected $_canUseForMultishipping = false;
28
29
- protected $_formBlockType = 'cashondelivery/form';
30
- protected $_infoBlockType = 'cashondelivery/info';
31
32
- public function getCODTitle()
33
{
34
- return $this->getConfigData('title');
35
- }
36
37
- public function getInlandCosts()
38
- {
39
- return floatval($this->getConfigData('inlandcosts'));
40
}
41
42
- public function getForeignCountryCosts()
43
{
44
- return floatval($this->getConfigData('foreigncountrycosts'));
45
}
46
47
public function getCustomText()
48
{
49
return $this->getConfigData('customtext');
@@ -52,56 +85,63 @@ class Phoenix_CashOnDelivery_Model_CashOnDelivery extends Mage_Payment_Model_Met
52
/**
53
* Returns COD fee for certain address
54
*
55
- * @param Mage_Sales_Model_Quote_Address $address
56
- * @return decimal
57
- *
58
*/
59
public function getAddressCosts(Mage_Customer_Model_Address_Abstract $address)
60
{
61
if ($address->getCountry() == Mage::getStoreConfig('shipping/origin/country_id')) {
62
- return $this->getInlandCosts();
63
} else {
64
- return $this->getForeignCountryCosts();
65
}
66
}
67
68
- public function getAddressCodFee(Mage_Customer_Model_Address_Abstract $address, $value = null,
69
- $alreadyExclTax = false)
70
{
71
if (is_null($value)) {
72
$value = $this->getAddressCosts($address);
73
}
74
- if (Mage::helper('cashondelivery')->codPriceIncludesTax()) {
75
if (!$alreadyExclTax) {
76
- $value = Mage::helper('cashondelivery')->getCodPrice(
77
- $value,
78
- false,
79
- $address,
80
- $address->getQuote()->getCustomerTaxClassId()
81
- );
82
}
83
}
84
return $value;
85
}
86
87
- public function getAddressCodTaxAmount(Mage_Customer_Model_Address_Abstract $address, $value = null,
88
- $alreadyExclTax = false)
89
{
90
if (is_null($value)) {
91
$value = $this->getAddressCosts($address);
92
}
93
- if (Mage::helper('cashondelivery')->codPriceIncludesTax()) {
94
- $includingTax = Mage::helper('cashondelivery')->getCodPrice(
95
- $value,
96
- true,
97
- $address, $address->getQuote()->getCustomerTaxClassId()
98
- );
99
if (!$alreadyExclTax) {
100
- $value = Mage::helper('cashondelivery')->getCodPrice(
101
- $value,
102
- false,
103
- $address, $address->getQuote()->getCustomerTaxClassId()
104
- );
105
}
106
return $includingTax - $value;
107
}
@@ -111,26 +151,28 @@ class Phoenix_CashOnDelivery_Model_CashOnDelivery extends Mage_Payment_Model_Met
111
/**
112
* Return true if the method can be used at this time
113
*
114
* @return bool
115
*/
116
- public function isAvailable($quote=null)
117
{
118
if (!parent::isAvailable($quote)) {
119
return false;
120
}
121
if (!is_null($quote)) {
122
if ($this->getConfigData('shippingallowspecific', $quote->getStoreId()) == 1) {
123
- $country = $quote->getShippingAddress()->getCountry();
124
$availableCountries = $this->getConfigData('shippingspecificcountry', $quote->getStoreId());
125
if (!in_array($country, explode(',', $availableCountries))) {
126
return false;
127
}
128
-
129
}
130
if ($this->getConfigData('disallowspecificshippingmethods', $quote->getStoreId()) == 1) {
131
- $shippingMethodCode = explode('_', $quote->getShippingAddress()->getShippingMethod());
132
- $shippingMethodCode = $shippingMethodCode[0];
133
$disallowedShippingMethods = $this->getConfigData('disallowedshippingmethods', $quote->getStoreId());
134
if (in_array($shippingMethodCode, explode(',', $disallowedShippingMethods))) {
135
return false;
136
}
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
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
* @copyright Copyright (c) 2008-2009 Andrej Sinicyn, Mik3e
18
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
19
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
*/
21
22
class Phoenix_CashOnDelivery_Model_CashOnDelivery extends Mage_Payment_Model_Method_Abstract
23
{
24
+ const XML_CONFIG_PATH_CASHONDELIVERY_COST_TYPE = 'payment/phoenix_cashondelivery/cost_type';
25
+
26
/**
27
* unique internal payment method identifier
28
*
29
* @var string [a-z0-9_]
30
*/
31
+ protected $_code = 'phoenix_cashondelivery';
32
protected $_canUseForMultishipping = false;
33
34
+ protected $_formBlockType = 'phoenix_cashondelivery/form';
35
+ protected $_infoBlockType = 'phoenix_cashondelivery/info';
36
37
+ /**
38
+ * Get the configured inland fee.
39
+ * If percentage is configured we calculate it from the configured address attribute.
40
+ *
41
+ * @param Mage_Customer_Model_Address_Abstract|null $address
42
+ * @return float
43
+ */
44
+ public function getInlandCosts($address = null)
45
{
46
+ $inlandCost = $this->getConfigData('inlandcosts');
47
48
+ if (is_object($address) && Mage::getStoreConfigFlag(self::XML_CONFIG_PATH_CASHONDELIVERY_COST_TYPE)) {
49
+ $calcBase = $this->getConfigData('cost_calc_base');
50
+ $inlandCost = ($address->getData($calcBase) / 100) * $inlandCost;
51
+ }
52
+
53
+ return floatval($inlandCost);
54
}
55
56
+ /**
57
+ * Get the configured foreign country fee.
58
+ * If percentage is configured we calculate it from the configured address attribute.
59
+ *
60
+ * @param Mage_Customer_Model_Address_Abstract|null $address
61
+ * @return float
62
+ */
63
+ public function getForeignCountryCosts($address = null)
64
{
65
+ $foreignCost = $this->getConfigData('foreigncountrycosts');
66
+
67
+ if (is_object($address) && Mage::getStoreConfigFlag(self::XML_CONFIG_PATH_CASHONDELIVERY_COST_TYPE)) {
68
+ $calcBase = $this->getConfigData('cost_calc_base');
69
+ $foreignCost = ($address->getData($calcBase) / 100) * $foreignCost;
70
+ }
71
+
72
+ return floatval($foreignCost);
73
}
74
75
+ /**
76
+ * Returns an configured custom text which is used to show additional information to the customer.
77
+ *
78
+ * @return string
79
+ */
80
public function getCustomText()
81
{
82
return $this->getConfigData('customtext');
85
/**
86
* Returns COD fee for certain address
87
*
88
+ * @param Mage_Customer_Model_Address_Abstract $address
89
+ * @return float
90
*/
91
public function getAddressCosts(Mage_Customer_Model_Address_Abstract $address)
92
{
93
if ($address->getCountry() == Mage::getStoreConfig('shipping/origin/country_id')) {
94
+ return $this->getInlandCosts($address);
95
+
96
} else {
97
+ return $this->getForeignCountryCosts($address);
98
}
99
}
100
101
+ /**
102
+ * Returns the payment fee excluding the tax.
103
+ *
104
+ * @param Mage_Customer_Model_Address_Abstract $address
105
+ * @param null|float $value
106
+ * @param bool $alreadyExclTax
107
+ * @return float|null
108
+ */
109
+ public function getAddressCodFee(Mage_Customer_Model_Address_Abstract $address, $value = null, $alreadyExclTax = false)
110
{
111
+ $helper = Mage::helper('phoenix_cashondelivery');
112
+
113
if (is_null($value)) {
114
$value = $this->getAddressCosts($address);
115
}
116
+
117
+ if ($helper->codPriceIncludesTax()) {
118
if (!$alreadyExclTax) {
119
+ $value = $helper->getCodPrice($value, false, $address, $address->getQuote()->getCustomerTaxClassId());
120
}
121
}
122
return $value;
123
}
124
125
+ /**
126
+ * Returns the tax for the payment fee.
127
+ *
128
+ * @param Mage_Customer_Model_Address_Abstract $address
129
+ * @param null|float $value
130
+ * @param bool $alreadyExclTax
131
+ * @return int|float
132
+ */
133
+ public function getAddressCodTaxAmount(Mage_Customer_Model_Address_Abstract $address, $value = null, $alreadyExclTax = false)
134
{
135
+ $helper = Mage::helper('phoenix_cashondelivery');
136
+
137
if (is_null($value)) {
138
$value = $this->getAddressCosts($address);
139
}
140
+
141
+ if ($helper->codPriceIncludesTax()) {
142
+ $includingTax = $helper->getCodPrice($value, true, $address, $address->getQuote()->getCustomerTaxClassId());
143
if (!$alreadyExclTax) {
144
+ $value = $helper->getCodPrice($value, false, $address, $address->getQuote()->getCustomerTaxClassId());
145
}
146
return $includingTax - $value;
147
}
151
/**
152
* Return true if the method can be used at this time
153
*
154
+ * @param Mage_Sales_Model_Quote|null $quote
155
* @return bool
156
*/
157
+ public function isAvailable($quote = null)
158
{
159
if (!parent::isAvailable($quote)) {
160
return false;
161
}
162
if (!is_null($quote)) {
163
if ($this->getConfigData('shippingallowspecific', $quote->getStoreId()) == 1) {
164
+ $country = $quote->getShippingAddress()->getCountry();
165
$availableCountries = $this->getConfigData('shippingspecificcountry', $quote->getStoreId());
166
+
167
if (!in_array($country, explode(',', $availableCountries))) {
168
return false;
169
}
170
}
171
if ($this->getConfigData('disallowspecificshippingmethods', $quote->getStoreId()) == 1) {
172
+ $shippingMethodCode = explode('_', $quote->getShippingAddress()->getShippingMethod());
173
+ $shippingMethodCode = $shippingMethodCode[0];
174
$disallowedShippingMethods = $this->getConfigData('disallowedshippingmethods', $quote->getStoreId());
175
+
176
if (in_array($shippingMethodCode, explode(',', $disallowedShippingMethods))) {
177
return false;
178
}
app/code/community/Phoenix/CashOnDelivery/Model/Creditmemo/Total.php DELETED
@@ -1,68 +0,0 @@
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
- * @category Phoenix
16
- * @package Phoenix_CashOnDelivery
17
- * @copyright Copyright (c) 2010 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
18
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
- */
20
-
21
- class Phoenix_CashOnDelivery_Model_Creditmemo_Total extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
22
- {
23
- public function collect(Mage_Sales_Model_Order_Creditmemo $cm)
24
- {
25
-
26
- $order = $cm->getOrder();
27
-
28
- if ($order->getPayment()->getMethodInstance()->getCode() != 'cashondelivery') {
29
- return $this;
30
- }
31
-
32
- $baseCmTotal = $cm->getBaseGrandTotal();
33
- $cmTotal = $cm->getGrandTotal();
34
-
35
- $baseCodFeeCredited = $order->getBaseCodFeeCredited();
36
- $codFeeCredited = $order->getCodFeeCredited();
37
-
38
- $baseCodFeeInvoiced = $order->getBaseCodFeeInvoiced();
39
- $codFeeInvoiced = $order->getCodFeeInvoiced();
40
-
41
- if ($cm->getInvoice()) {
42
- $invoice = $cm->getInvoice();
43
- $baseCodFeeToCredit = $invoice->getBaseCodFee();
44
- $codFeeToCredit = $invoice->getCodFee();
45
- } else {
46
- $baseCodFeeToCredit = $baseCodFeeInvoiced;
47
- $codFeeToCredit = $codFeeInvoiced;
48
- }
49
-
50
- if (!$baseCodFeeToCredit > 0) {
51
- return $this;
52
- }
53
-
54
-
55
- // Subtracting invoiced COD fee from Credit memo total
56
- //$cm->setBaseGrandTotal($baseCmTotal-$baseCodFeeToCredit);
57
- //$cm->setGrandTotal($cmTotal-$codFeeToCredit);
58
-
59
- //$cm->setBaseCodFee($baseCodFeeToCredit);
60
- //$cm->setCodFee($codFeeToCredit);
61
-
62
- //$order->setBaseCodFeeCredited($baseCodFeeCredited+$baseCodFeeToCredit);
63
- //$order->setCodFeeCredited($codFeeCredited+$baseCodFeeToCredit);
64
-
65
-
66
- return $this;
67
- }
68
- }
app/code/community/Phoenix/CashOnDelivery/Model/Observer.php CHANGED
@@ -14,77 +14,129 @@
14
*
15
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
- * @copyright Copyright (c) 2010 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
18
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
class Phoenix_CashOnDelivery_Model_Observer extends Mage_Core_Model_Abstract
21
{
22
/**
23
- * Collects codFee from qoute/addresses to quote
24
*
25
* @param Varien_Event_Observer $observer
26
- *
27
*/
28
public function sales_quote_collect_totals_after(Varien_Event_Observer $observer)
29
{
30
$quote = $observer->getEvent()->getQuote();
31
- $data = $observer->getInput();
32
$quote->setCodFee(0);
33
$quote->setBaseCodFee(0);
34
$quote->setCodTaxAmount(0);
35
$quote->setBaseCodTaxAmount(0);
36
- foreach ($quote->getAllAddresses() as $address) {
37
- $quote->setCodFee((float) $quote->getCodFee() + $address->getCodFee());
38
- $quote->setBaseCodFee((float) $quote->getBaseCodFee() + $address->getBaseCodFee());
39
40
- $quote->setCodTaxAmount((float) $quote->getCodTaxAmount() + $address->getCodTaxAmount());
41
- $quote->setBaseCodTaxAmount((float) $quote->getBaseCodTaxAmount() + $address->getBaseCodTaxAmount());
42
}
43
}
44
45
/**
46
* Adds codFee to order
47
*
48
* @param Varien_Event_Observer $observer
49
*/
50
public function sales_order_payment_place_end(Varien_Event_Observer $observer)
51
{
52
$payment = $observer->getPayment();
53
- if ($payment->getMethodInstance()->getCode() != 'cashondelivery') {
54
- return;
55
}
56
57
$order = $payment->getOrder();
58
$quote = Mage::getSingleton('checkout/session')->getQuote();
59
if (!$quote->getId()) {
60
$quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
61
}
62
$order->setCodFee($quote->getCodFee());
63
$order->setBaseCodFee($quote->getBaseCodFee());
64
-
65
$order->setCodTaxAmount($quote->getCodTaxAmount());
66
$order->setBaseCodTaxAmount($quote->getBaseCodTaxAmount());
67
-
68
$order->save();
69
}
70
71
/**
72
- * Performs order_creage_loadBlock response update
73
* adds totals block to each response
74
- * This function is depricated, the totals block update is implemented
75
* in phoenix/cashondelivery/sales.js (SalesOrder class extension)
76
*
77
* @param Varien_Event_Observer $observer
78
*/
79
public function controller_action_layout_load_before(Varien_Event_Observer $observer)
80
{
81
$action = $observer->getAction();
82
- if ($action->getFullActionName() != 'adminhtml_sales_order_create_loadBlock' ||
83
- !$action->getRequest()->getParam('json')) {
84
- return;
85
}
86
$layout = $observer->getLayout();
87
$layout->getUpdate()->addHandle('adminhtml_sales_order_create_load_block_totals');
88
}
89
90
}
14
*
15
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
18
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
+
21
class Phoenix_CashOnDelivery_Model_Observer extends Mage_Core_Model_Abstract
22
{
23
/**
24
+ * Collects codFee from quote/addresses to quote
25
*
26
* @param Varien_Event_Observer $observer
27
+ * @return Phoenix_CashOnDelivery_Model_Observer
28
*/
29
public function sales_quote_collect_totals_after(Varien_Event_Observer $observer)
30
{
31
$quote = $observer->getEvent()->getQuote();
32
+ $data = $observer->getInput();
33
+
34
$quote->setCodFee(0);
35
$quote->setBaseCodFee(0);
36
$quote->setCodTaxAmount(0);
37
$quote->setBaseCodTaxAmount(0);
38
39
+ foreach ($quote->getAllAddresses() as $address) {
40
+ $quote->setCodFee((float)($quote->getCodFee() + $address->getCodFee()));
41
+ $quote->setBaseCodFee((float)($quote->getBaseCodFee() + $address->getBaseCodFee()));
42
+ $quote->setCodTaxAmount((float)($quote->getCodTaxAmount() + $address->getCodTaxAmount()));
43
+ $quote->setBaseCodTaxAmount((float)($quote->getBaseCodTaxAmount() + $address->getBaseCodTaxAmount()));
44
}
45
+ return $this;
46
}
47
48
/**
49
* Adds codFee to order
50
*
51
* @param Varien_Event_Observer $observer
52
+ * @return Phoenix_CashOnDelivery_Model_Observer
53
*/
54
public function sales_order_payment_place_end(Varien_Event_Observer $observer)
55
{
56
$payment = $observer->getPayment();
57
+ if ($payment->getMethodInstance()->getCode() != 'phoenix_cashondelivery') {
58
+ return $this;;
59
}
60
61
$order = $payment->getOrder();
62
$quote = Mage::getSingleton('checkout/session')->getQuote();
63
+
64
if (!$quote->getId()) {
65
$quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
66
}
67
+
68
$order->setCodFee($quote->getCodFee());
69
$order->setBaseCodFee($quote->getBaseCodFee());
70
$order->setCodTaxAmount($quote->getCodTaxAmount());
71
$order->setBaseCodTaxAmount($quote->getBaseCodTaxAmount());
72
$order->save();
73
+
74
+ return $this;
75
}
76
77
/**
78
+ * Performs order_create_loadBlock response update
79
* adds totals block to each response
80
+ * This function is deprecated, the totals block update is implemented
81
* in phoenix/cashondelivery/sales.js (SalesOrder class extension)
82
*
83
* @param Varien_Event_Observer $observer
84
+ * @return Phoenix_CashOnDelivery_Model_Observer
85
*/
86
public function controller_action_layout_load_before(Varien_Event_Observer $observer)
87
{
88
$action = $observer->getAction();
89
+
90
+ if ($action->getFullActionName() != 'adminhtml_sales_order_create_loadBlock' || !$action->getRequest()->getParam('json')) {
91
+ return $this;
92
}
93
+
94
$layout = $observer->getLayout();
95
$layout->getUpdate()->addHandle('adminhtml_sales_order_create_load_block_totals');
96
+
97
+ return $this;
98
}
99
100
+ /**
101
+ * When the order gets canceled we put the Cash on Delivery fee and tax also in the canceled columns.
102
+ *
103
+ * @param Varien_Event_Observer $observer
104
+ * @return Phoenix_CashOnDelivery_Model_Observer
105
+ */
106
+ public function order_cancel_after(Varien_Event_Observer $observer)
107
+ {
108
+ $order = $observer->getEvent()->getOrder();
109
+
110
+ if ($order->getPayment()->getMethodInstance()->getCode() != 'phoenix_cashondelivery') {
111
+ return $this;
112
+ }
113
+
114
+ $codFee = $order->getCodFee();
115
+ $baseCodFee = $order->getBaseCodFee();
116
+ $codTax = $order->getCodTaxAmount();
117
+ $baseCodTax = $order->getBaseCodTaxAmount();
118
+
119
+ $codFeeInvoiced = $order->getCodFeeInvoiced();
120
+
121
+ if ($codFeeInvoiced) {
122
+ $baseCodFeeInvoiced = $order->getBaseCodFeeInvoiced();
123
+ $codTaxInvoiced = $order->getCodTaxAmountInvoiced();
124
+ $baseCodTaxInvoiced = $order->getBaseCodTaxAmountInvoiced();
125
+
126
+ $codFee = $codFee - $codFeeInvoiced;
127
+ $baseCodFee = $baseCodFee - $baseCodFeeInvoiced;
128
+ $codTax = $codTax - $codTaxInvoiced;
129
+ $baseCodTax = $baseCodTax - $baseCodTaxInvoiced;
130
+ }
131
+
132
+ if ($baseCodFee) {
133
+ $order->setCodFeeCanceled($codFee)
134
+ ->setBaseCodFeeCanceled($baseCodFee)
135
+ ->setCodTaxAmountCanceled($codTax)
136
+ ->setBaseCodTaxAmountCanceled($baseCodTax)
137
+ ->save();
138
+ }
139
+
140
+ return $this;
141
+ }
142
}
app/code/community/Phoenix/CashOnDelivery/Model/Sales/Creditmemo/Tax.php ADDED
@@ -0,0 +1,62 @@
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
+ * @category Phoenix
16
+ * @package Phoenix_CashOnDelivery
17
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_CashOnDelivery_Model_Sales_Creditmemo_Tax extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
22
+ {
23
+ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
24
+ {
25
+ $order = $creditmemo->getOrder();
26
+
27
+ if ($order->getPayment()->getMethodInstance()->getCode() != 'phoenix_cashondelivery') {
28
+ return $this;
29
+ }
30
+
31
+ $creditmemoBaseGrandTotal = $creditmemo->getBaseGrandTotal();
32
+ $creditmemoGrandTotal = $creditmemo->getGrandTotal();
33
+ $creditmemoBaseTaxAmount = $creditmemo->getBaseTaxAmount();
34
+ $creditmemoTaxAmount = $creditmemo->getTaxAmount();
35
+
36
+ $baseCodTaxAmountRefunded = $order->getBaseCodTaxAmountRefunded();
37
+ $codTaxAmountRefunded = $order->getCodTaxAmountRefunded();
38
+
39
+ $baseCodTaxAmountInvoiced = $order->getBaseCodTaxAmountInvoiced();
40
+ $codTaxAmountInvoiced = $order->getCodTaxAmountInvoiced();
41
+
42
+ $baseCodTaxAmountToRefund = abs($baseCodTaxAmountInvoiced - $baseCodTaxAmountRefunded);
43
+ $codTaxAmountToRefund = abs($codTaxAmountInvoiced - $codTaxAmountRefunded);
44
+
45
+ if ($baseCodTaxAmountToRefund <= 0) {
46
+ return $this;
47
+ }
48
+
49
+ $creditmemo->setBaseGrandTotal($creditmemoBaseGrandTotal + $baseCodTaxAmountToRefund)
50
+ ->setGrandTotal($creditmemoGrandTotal + $codTaxAmountToRefund)
51
+ ->setBaseTaxAmount($creditmemoBaseTaxAmount + $baseCodTaxAmountToRefund)
52
+ ->setTaxAmount($creditmemoTaxAmount + $codTaxAmountToRefund)
53
+ ->setBaseCodTaxAmount($codTaxAmountToRefund)
54
+ ->setCodTaxAmount($codTaxAmountToRefund);
55
+
56
+ $order->setBaseCodTaxAmountRefunded($baseCodTaxAmountRefunded + $baseCodTaxAmountToRefund)
57
+ ->setCodTaxAmountRefunded($codTaxAmountRefunded + $codTaxAmountToRefund);
58
+
59
+
60
+ return $this;
61
+ }
62
+ }
app/code/community/Phoenix/CashOnDelivery/Model/Sales/Creditmemo/Total.php ADDED
@@ -0,0 +1,58 @@
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
+ * @category Phoenix
16
+ * @package Phoenix_CashOnDelivery
17
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_CashOnDelivery_Model_Sales_Creditmemo_Total extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
22
+ {
23
+ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
24
+ {
25
+ $order = $creditmemo->getOrder();
26
+
27
+ if ($order->getPayment()->getMethodInstance()->getCode() != 'phoenix_cashondelivery') {
28
+ return $this;
29
+ }
30
+
31
+ $creditmemoBaseGrandTotal = $creditmemo->getBaseGrandTotal();
32
+ $creditmemoGrandTotal = $creditmemo->getGrandTotal();
33
+
34
+ $baseCodFeeRefunded = $order->getBaseCodFeeRefunded();
35
+ $codFeeRefunded = $order->getCodFeeRefunded();
36
+
37
+ $baseCodFeeInvoiced = $order->getBaseCodFeeInvoiced();
38
+ $codFeeInvoiced = $order->getCodFeeInvoiced();
39
+
40
+ $baseCodFeeToRefund = abs($baseCodFeeInvoiced - $baseCodFeeRefunded);
41
+ $codFeeToRefund = abs($codFeeInvoiced - $codFeeRefunded);
42
+
43
+ if ($baseCodFeeToRefund <= 0) {
44
+ return $this;
45
+ }
46
+
47
+ $creditmemo->setBaseGrandTotal($creditmemoBaseGrandTotal + $baseCodFeeToRefund)
48
+ ->setGrandTotal($creditmemoGrandTotal + $codFeeToRefund)
49
+ ->setBaseCodFee($baseCodFeeToRefund)
50
+ ->setCodFee($codFeeToRefund);
51
+
52
+ $order->setBaseCodFeeRefunded($baseCodFeeRefunded + $baseCodFeeToRefund)
53
+ ->setCodFeeRefunded($codFeeRefunded + $codFeeToRefund);
54
+
55
+
56
+ return $this;
57
+ }
58
+ }
app/code/community/Phoenix/CashOnDelivery/Model/{Invoice → Sales/Invoice}/Tax.php RENAMED
@@ -14,35 +14,42 @@
14
*
15
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
- * @copyright Copyright (c) 2010 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
18
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
21
- class Phoenix_CashOnDelivery_Model_Invoice_Tax extends Mage_Sales_Model_Order_Invoice_Total_Abstract
22
{
23
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
24
{
25
- $codTax = 0;
26
- $baseCodTax = 0;
27
- $order = $invoice->getOrder();
28
-
29
$includeCodTax = true;
30
/**
31
* Check Cod amount in previus invoices
32
*/
33
- foreach ($invoice->getOrder()->getInvoiceCollection() as $previusInvoice) {
34
- if ($previusInvoice->getCodFee() && !$previusInvoice->isCanceled()) {
35
$includeCodTax = false;
36
}
37
}
38
39
if ($includeCodTax) {
40
- $codTax += $invoice->getOrder()->getCodTaxAmount();
41
- $baseCodTax += $invoice->getOrder()->getBaseCodTaxAmount();
42
- $invoice->setCodTaxAmount($invoice->getOrder()->getCodTaxAmount());
43
- $invoice->setBaseCodTaxAmount($invoice->getOrder()->getBaseCodTaxAmount());
44
$invoice->getOrder()->setCodTaxAmountInvoiced($codTax);
45
- $invoice->getOrder()->setBaseCodTaxAmountInvoice($baseCodTax);
46
}
47
48
/**
@@ -50,12 +57,13 @@ class Phoenix_CashOnDelivery_Model_Invoice_Tax extends Mage_Sales_Model_Order_In
50
* totalTax adjustment
51
* check Mage_Sales_Model_Order_Invoice_Total_Tax::collect()
52
*/
53
- $allowedTax = $order->getTaxAmount() - $order->getTaxInvoiced();
54
$allowedBaseTax = $order->getBaseTaxAmount() - $order->getBaseTaxInvoiced();
55
- $totalTax = $invoice->getTaxAmount();
56
- $baseTotalTax = $invoice->getBaseTaxAmount();
57
- if (!$invoice->isLast()
58
- && $allowedTax > $totalTax) {
59
$newTotalTax = min($allowedTax, $totalTax + $codTax);
60
$newBaseTotalTax = min($allowedBaseTax, $baseTotalTax + $baseCodTax);
61
14
*
15
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
18
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
21
+ class Phoenix_CashOnDelivery_Model_Sales_Invoice_Tax extends Mage_Sales_Model_Order_Invoice_Total_Abstract
22
{
23
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
24
{
25
+ $codTax = 0;
26
+ $baseCodTax = 0;
27
+ $order = $invoice->getOrder();
28
$includeCodTax = true;
29
+
30
+ if ($order->getPayment()->getMethodInstance()->getCode() != 'phoenix_cashondelivery') {
31
+ return $this;
32
+ }
33
+
34
/**
35
* Check Cod amount in previus invoices
36
*/
37
+ foreach ($order->getInvoiceCollection() as $previousInvoice) {
38
+
39
+ if ($previousInvoice->getCodFee() && !$previousInvoice->isCanceled()) {
40
$includeCodTax = false;
41
}
42
}
43
44
if ($includeCodTax) {
45
+ $codTax = $order->getCodTaxAmount();
46
+ $baseCodTax = $order->getBaseCodTaxAmount();
47
+
48
+ $invoice->setCodTaxAmount($order->getCodTaxAmount());
49
+ $invoice->setBaseCodTaxAmount($order->getBaseCodTaxAmount());
50
+
51
$invoice->getOrder()->setCodTaxAmountInvoiced($codTax);
52
+ $invoice->getOrder()->setBaseCodTaxAmountInvoiced($baseCodTax);
53
}
54
55
/**
57
* totalTax adjustment
58
* check Mage_Sales_Model_Order_Invoice_Total_Tax::collect()
59
*/
60
+ $allowedTax = $order->getTaxAmount() - $order->getTaxInvoiced();
61
$allowedBaseTax = $order->getBaseTaxAmount() - $order->getBaseTaxInvoiced();
62
+
63
+ $totalTax = $invoice->getTaxAmount();
64
+ $baseTotalTax = $invoice->getBaseTaxAmount();
65
+
66
+ if (!$invoice->isLast() && $allowedTax > $totalTax) {
67
$newTotalTax = min($allowedTax, $totalTax + $codTax);
68
$newBaseTotalTax = min($allowedBaseTax, $baseTotalTax + $baseCodTax);
69
app/code/community/Phoenix/CashOnDelivery/Model/{Invoice → Sales/Invoice}/Total.php RENAMED
@@ -14,46 +14,42 @@
14
*
15
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
- * @copyright Copyright (c) 2010 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
18
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
21
- class Phoenix_CashOnDelivery_Model_Invoice_Total extends Mage_Sales_Model_Order_Invoice_Total_Abstract
22
{
23
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
24
{
25
$order = $invoice->getOrder();
26
27
- if ($order->getPayment()->getMethodInstance()->getCode() != 'cashondelivery') {
28
return $this;
29
}
30
31
- if (!$order->getCodFee()) {
32
- return $this;
33
- }
34
-
35
- foreach ($invoice->getOrder()->getInvoiceCollection() as $previusInvoice) {
36
- if ($previusInvoice->getCodAmount() && !$previusInvoice->isCanceled()) {
37
$includeCodTax = false;
38
}
39
}
40
41
- $baseCodFee = $order->getBaseCodFee();
42
$baseCodFeeInvoiced = $order->getBaseCodFeeInvoiced();
43
- $baseInvoiceTotal = $invoice->getBaseGrandTotal();
44
- $codFee = $order->getCodFee();
45
- $codFeeInvoiced = $order->getCodFeeInvoiced();
46
- $invoiceTotal = $invoice->getGrandTotal();
47
48
if (!$baseCodFee || $baseCodFeeInvoiced==$baseCodFee) {
49
return $this;
50
}
51
52
$baseCodFeeToInvoice = $baseCodFee - $baseCodFeeInvoiced;
53
- $codFeeToInvoice = $codFee - $codFeeInvoiced;
54
55
$baseInvoiceTotal = $baseInvoiceTotal + $baseCodFeeToInvoice;
56
- $invoiceTotal = $invoiceTotal + $codFeeToInvoice;
57
58
$invoice->setBaseGrandTotal($baseInvoiceTotal);
59
$invoice->setGrandTotal($invoiceTotal);
@@ -61,8 +57,8 @@ class Phoenix_CashOnDelivery_Model_Invoice_Total extends Mage_Sales_Model_Order_
61
$invoice->setBaseCodFee($baseCodFeeToInvoice);
62
$invoice->setCodFee($codFeeToInvoice);
63
64
- $order->setBaseCodFeeInvoiced($baseCodFeeInvoiced+$baseCodFeeToInvoice);
65
- $order->setCodFeeInvoiced($codFeeInvoiced+$codFeeToInvoice);
66
67
return $this;
68
}
14
*
15
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
18
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
21
+ class Phoenix_CashOnDelivery_Model_Sales_Invoice_Total extends Mage_Sales_Model_Order_Invoice_Total_Abstract
22
{
23
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
24
{
25
$order = $invoice->getOrder();
26
27
+ if ($order->getPayment()->getMethodInstance()->getCode() != 'phoenix_cashondelivery' || !$order->getCodFee()) {
28
return $this;
29
}
30
31
+ foreach ($invoice->getOrder()->getInvoiceCollection() as $previousInvoice) {
32
+ if ($previousInvoice->getCodAmount() && !$previousInvoice->isCanceled()) {
33
$includeCodTax = false;
34
}
35
}
36
37
+ $baseCodFee = $order->getBaseCodFee();
38
$baseCodFeeInvoiced = $order->getBaseCodFeeInvoiced();
39
+ $baseInvoiceTotal = $invoice->getBaseGrandTotal();
40
+ $codFee = $order->getCodFee();
41
+ $codFeeInvoiced = $order->getCodFeeInvoiced();
42
+ $invoiceTotal = $invoice->getGrandTotal();
43
44
if (!$baseCodFee || $baseCodFeeInvoiced==$baseCodFee) {
45
return $this;
46
}
47
48
$baseCodFeeToInvoice = $baseCodFee - $baseCodFeeInvoiced;
49
+ $codFeeToInvoice = $codFee - $codFeeInvoiced;
50
51
$baseInvoiceTotal = $baseInvoiceTotal + $baseCodFeeToInvoice;
52
+ $invoiceTotal = $invoiceTotal + $codFeeToInvoice;
53
54
$invoice->setBaseGrandTotal($baseInvoiceTotal);
55
$invoice->setGrandTotal($invoiceTotal);
57
$invoice->setBaseCodFee($baseCodFeeToInvoice);
58
$invoice->setCodFee($codFeeToInvoice);
59
60
+ $order->setBaseCodFeeInvoiced($baseCodFeeInvoiced + $baseCodFeeToInvoice);
61
+ $order->setCodFeeInvoiced($codFeeInvoiced + $codFeeToInvoice);
62
63
return $this;
64
}
app/code/community/Phoenix/CashOnDelivery/Model/Sales/Pdf/Cod.php CHANGED
@@ -12,16 +12,10 @@
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_Tax
23
- * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
27
class Phoenix_CashOnDelivery_Model_Sales_Pdf_Cod extends Mage_Sales_Model_Order_Pdf_Total_Default
@@ -39,39 +33,42 @@ class Phoenix_CashOnDelivery_Model_Sales_Pdf_Cod extends Mage_Sales_Model_Order_
39
*/
40
public function getTotalsForDisplay()
41
{
42
- $store = $this->getOrder()->getStore();
43
- $amount = $this->getOrder()->formatPriceTxt($this->getAmount());
44
- $amountInclTax = $this->getAmount()+$this->getSource()->getCodTaxAmount();
45
$amountInclTax = $this->getOrder()->formatPriceTxt($amountInclTax);
46
- $fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
47
48
- if (Mage::helper('cashondelivery')->displayCodBothPrices()){
49
$totals = array(
50
array(
51
'amount' => $this->getAmountPrefix().$amount,
52
- 'label' => Mage::helper('cashondelivery')->__('Cash on Delivery fee (Excl.Tax)') . ':',
53
'font_size' => $fontSize
54
),
55
array(
56
'amount' => $this->getAmountPrefix().$amountInclTax,
57
- 'label' => Mage::helper('cashondelivery')->__('Cash on Delivery fee (Incl.Tax)') . ':',
58
'font_size' => $fontSize
59
),
60
);
61
- } elseif (Mage::helper('cashondelivery')->displayCodFeeIncludingTax()) {
62
- $totals = array(array(
63
- 'amount' => $this->getAmountPrefix().$amountInclTax,
64
- 'label' => Mage::helper('cashondelivery')->__($this->getTitle()) . ':',
65
- 'font_size' => $fontSize
66
- ));
67
} else {
68
- $totals = array(array(
69
- 'amount' => $this->getAmountPrefix().$amount,
70
- 'label' => Mage::helper('cashondelivery')->__($this->getTitle()) . ':',
71
- 'font_size' => $fontSize
72
- ));
73
}
74
-
75
return $totals;
76
}
77
}
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
+ * @category Phoenix
16
+ * @package Phoenix_CashOnDelivery
17
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
21
class Phoenix_CashOnDelivery_Model_Sales_Pdf_Cod extends Mage_Sales_Model_Order_Pdf_Total_Default
33
*/
34
public function getTotalsForDisplay()
35
{
36
+ $amount = $this->getOrder()->formatPriceTxt($this->getAmount());
37
+ $amountInclTax = $this->getAmount() + $this->getSource()->getCodTaxAmount();
38
$amountInclTax = $this->getOrder()->formatPriceTxt($amountInclTax);
39
+ $fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
40
+ $helper = Mage::helper('phoenix_cashondelivery');
41
42
+ if ($helper->displayCodBothPrices()){
43
$totals = array(
44
array(
45
'amount' => $this->getAmountPrefix().$amount,
46
+ 'label' => $helper->__('Cash on Delivery fee (Excl.Tax)') . ':',
47
'font_size' => $fontSize
48
),
49
array(
50
'amount' => $this->getAmountPrefix().$amountInclTax,
51
+ 'label' => $helper->__('Cash on Delivery fee (Incl.Tax)') . ':',
52
'font_size' => $fontSize
53
),
54
);
55
+ } elseif ($helper->displayCodFeeIncludingTax()) {
56
+ $totals = array(
57
+ array(
58
+ 'amount' => $this->getAmountPrefix().$amountInclTax,
59
+ 'label' => $helper->__($this->getTitle()) . ':',
60
+ 'font_size' => $fontSize
61
+ )
62
+ );
63
} else {
64
+ $totals = array(
65
+ array(
66
+ 'amount' => $this->getAmountPrefix().$amount,
67
+ 'label' => $helper->__($this->getTitle()) . ':',
68
+ 'font_size' => $fontSize
69
+ )
70
+ );
71
}
72
return $totals;
73
}
74
}
app/code/community/Phoenix/CashOnDelivery/Model/{Quote → Sales/Quote}/TaxTotal.php RENAMED
@@ -14,16 +14,12 @@
14
*
15
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
- * @copyright Copyright (c) 2010 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
18
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
21
- class Phoenix_CashOnDelivery_Model_Quote_TaxTotal extends Mage_Sales_Model_Quote_Address_Total_Tax
22
{
23
- const CONFIG_XML_PATH_COD_TAX_CLASS = 'tax/classes/cod_tax_class';
24
- const CONFIG_XML_PATH_COD_INCLUDES_TAX = 'tax/calculation/cod_includes_tax';
25
- const CONFIG_XML_PATH_DISPLAY_COD = 'tax/display/cod_fee';
26
-
27
public function collect(Mage_Sales_Model_Quote_Address $address)
28
{
29
$collection = $address->getQuote()->getPaymentsCollection();
@@ -33,7 +29,7 @@ class Phoenix_CashOnDelivery_Model_Quote_TaxTotal extends Mage_Sales_Model_Quote
33
34
$paymentMethod = $address->getQuote()->getPayment()->getMethodInstance();
35
36
- if ($paymentMethod->getCode() != 'cashondelivery') {
37
return $this;
38
}
39
@@ -54,14 +50,14 @@ class Phoenix_CashOnDelivery_Model_Quote_TaxTotal extends Mage_Sales_Model_Quote
54
$custTaxClassId,
55
$store
56
);
57
- $codTaxClass = Mage::helper('cashondelivery')->getCodTaxClass($store);
58
59
$codTax = 0;
60
$codBaseTax = 0;
61
62
if ($codTaxClass) {
63
if ($rate = $taxCalculationModel->getRate($request->setProductClassId($codTaxClass))) {
64
- if (!Mage::helper('cashondelivery')->codPriceIncludesTax()) {
65
$codTax = $address->getCodFee() * $rate/100;
66
$codBaseTax= $address->getBaseCodFee() * $rate/100;
67
} else {
@@ -85,7 +81,7 @@ class Phoenix_CashOnDelivery_Model_Quote_TaxTotal extends Mage_Sales_Model_Quote
85
}
86
}
87
88
- if (!Mage::helper('cashondelivery')->codPriceIncludesTax()) {
89
$address->setCodTaxAmount($codTax);
90
$address->setBaseCodTaxAmount($codBaseTax);
91
}
14
*
15
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
18
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
21
+ class Phoenix_CashOnDelivery_Model_Sales_Quote_TaxTotal extends Mage_Sales_Model_Quote_Address_Total_Tax
22
{
23
public function collect(Mage_Sales_Model_Quote_Address $address)
24
{
25
$collection = $address->getQuote()->getPaymentsCollection();
29
30
$paymentMethod = $address->getQuote()->getPayment()->getMethodInstance();
31
32
+ if ($paymentMethod->getCode() != 'phoenix_cashondelivery') {
33
return $this;
34
}
35
50
$custTaxClassId,
51
$store
52
);
53
+ $codTaxClass = Mage::helper('phoenix_cashondelivery')->getCodTaxClass($store);
54
55
$codTax = 0;
56
$codBaseTax = 0;
57
58
if ($codTaxClass) {
59
if ($rate = $taxCalculationModel->getRate($request->setProductClassId($codTaxClass))) {
60
+ if (!Mage::helper('phoenix_cashondelivery')->codPriceIncludesTax()) {
61
$codTax = $address->getCodFee() * $rate/100;
62
$codBaseTax= $address->getBaseCodFee() * $rate/100;
63
} else {
81
}
82
}
83
84
+ if (!Mage::helper('phoenix_cashondelivery')->codPriceIncludesTax()) {
85
$address->setCodTaxAmount($codTax);
86
$address->setBaseCodTaxAmount($codBaseTax);
87
}
app/code/community/Phoenix/CashOnDelivery/Model/{Quote → Sales/Quote}/Total.php RENAMED
@@ -14,11 +14,11 @@
14
*
15
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
- * @copyright Copyright (c) 2010 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
18
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
21
- class Phoenix_CashOnDelivery_Model_Quote_Total extends Mage_Sales_Model_Quote_Address_Total_Abstract
22
{
23
public function collect(Mage_Sales_Model_Quote_Address $address)
24
{
@@ -34,7 +34,7 @@ class Phoenix_CashOnDelivery_Model_Quote_Total extends Mage_Sales_Model_Quote_Ad
34
35
$paymentMethod = $address->getQuote()->getPayment()->getMethodInstance();
36
37
- if ($paymentMethod->getCode() != 'cashondelivery') {
38
return $this;
39
}
40
@@ -81,7 +81,7 @@ class Phoenix_CashOnDelivery_Model_Quote_Total extends Mage_Sales_Model_Quote_Ad
81
$address->addTotal(
82
array(
83
'code' => $this->getCode(),
84
- 'title' => Mage::helper('cashondelivery')->__('Cash on Delivery fee'),
85
'value' => $amount
86
)
87
);
14
*
15
* @category Phoenix
16
* @package Phoenix_CashOnDelivery
17
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
18
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
21
+ class Phoenix_CashOnDelivery_Model_Sales_Quote_Total extends Mage_Sales_Model_Quote_Address_Total_Abstract
22
{
23
public function collect(Mage_Sales_Model_Quote_Address $address)
24
{
34
35
$paymentMethod = $address->getQuote()->getPayment()->getMethodInstance();
36
37
+ if ($paymentMethod->getCode() != 'phoenix_cashondelivery') {
38
return $this;
39
}
40
81
$address->addTotal(
82
array(
83
'code' => $this->getCode(),
84
+ 'title' => Mage::helper('phoenix_cashondelivery')->__('Cash on Delivery fee'),
85
'value' => $amount
86
)
87
);
app/code/community/Phoenix/CashOnDelivery/Model/Source/AvailableShipmentMethods.php CHANGED
@@ -13,8 +13,9 @@
13
* to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
* @category Phoenix
16
- * @package Phoenix_Ipayment
17
- * @copyright Copyright (c) 2008 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
18
*/
19
20
class Phoenix_CashOnDelivery_Model_Source_AvailableShipmentMethods
13
* to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
* @category Phoenix
16
+ * @package Phoenix_CashOnDelivery
17
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
21
class Phoenix_CashOnDelivery_Model_Source_AvailableShipmentMethods
app/code/community/Phoenix/CashOnDelivery/Model/Source/CostType.php ADDED
@@ -0,0 +1,32 @@
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
+ * @category Phoenix
16
+ * @package Phoenix_CashOnDelivery
17
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_CashOnDelivery_Model_Source_CostType
22
+ {
23
+ public function toOptionArray()
24
+ {
25
+ $helper = Mage::helper('phoenix_cashondelivery');
26
+
27
+ return array(
28
+ '0' => $helper->__('Fixed'),
29
+ '1' => $helper->__('Percentage'),
30
+ );
31
+ }
32
+ }
app/code/community/Phoenix/CashOnDelivery/etc/config.xml CHANGED
@@ -23,15 +23,15 @@
23
<config>
24
<modules>
25
<Phoenix_CashOnDelivery>
26
- <version>1.0.6</version>
27
</Phoenix_CashOnDelivery>
28
</modules>
29
30
<global>
31
<models>
32
- <cashondelivery>
33
<class>Phoenix_CashOnDelivery_Model</class>
34
- </cashondelivery>
35
</models>
36
<resources>
37
<cashondelivery_setup>
@@ -50,78 +50,100 @@
50
</cashondelivery_read>
51
</resources>
52
<helpers>
53
- <cashondelivery>
54
<class>Phoenix_CashOnDelivery_Helper</class>
55
- </cashondelivery>
56
</helpers>
57
<blocks>
58
- <cashondelivery><class>Phoenix_CashOnDelivery_Block</class></cashondelivery>
59
</blocks>
60
<sales>
61
<quote>
62
<totals>
63
- <cashondelivery>
64
- <class>cashondelivery/quote_total</class>
65
<after>subtotal,discount,shipping</after>
66
<before>tax,grand_total</before>
67
- <renderer>cashondelivery/checkout_cod</renderer>
68
- <admin_renderer>cashondelivery/adminhtml_sales_order_create_totals_cod</admin_renderer>
69
- </cashondelivery>
70
- <cashondelivery_tax>
71
- <class>cashondelivery/quote_taxTotal</class>
72
<after>subtotal,discount,shipping,tax</after>
73
<before>grand_total</before>
74
- </cashondelivery_tax>
75
</totals>
76
</quote>
77
<order_invoice>
78
<totals>
79
- <cashondelivery>
80
- <class>cashondelivery/invoice_total</class>
81
- </cashondelivery>
82
- <cashondelivery_tax>
83
- <class>cashondelivery/invoice_tax</class>
84
- </cashondelivery_tax>
85
</totals>
86
</order_invoice>
87
<order_creditmemo>
88
<totals>
89
- <cashondelivery>
90
- <class>cashondelivery/creditmemo_total</class>
91
- </cashondelivery>
92
</totals>
93
</order_creditmemo>
94
</sales>
95
<events>
96
<sales_quote_collect_totals_after>
97
<observers>
98
- <cashondelivery>
99
<type>singleton</type>
100
- <class>cashondelivery/observer</class>
101
<method>sales_quote_collect_totals_after</method>
102
- </cashondelivery>
103
</observers>
104
</sales_quote_collect_totals_after>
105
<sales_order_payment_place_end>
106
<observers>
107
- <cashondelivery>
108
<type>singleton</type>
109
- <class>cashondelivery/observer</class>
110
<method>sales_order_payment_place_end</method>
111
- </cashondelivery>
112
</observers>
113
</sales_order_payment_place_end>
114
</events>
115
<pdf>
116
<totals>
117
- <cashondelivery translate="title">
118
<title>Cash on Delivery fee</title>
119
<source_field>cod_fee</source_field>
120
<font_size>7</font_size>
121
<display_zero>0</display_zero>
122