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
  <sort_order>450</sort_order>
123
- <model>cashondelivery/sales_pdf_cod</model>
124
- </cashondelivery>
125
  </totals>
126
  </pdf>
127
  </global>
@@ -129,36 +151,36 @@
129
  <default>
130
  <sales>
131
  <totals_sort>
132
- <cashondelivery>35</cashondelivery>
133
  </totals_sort>
134
  </sales>
135
  <payment>
136
- <cashondelivery>
137
  <active>0</active>
138
- <model>cashondelivery/cashOnDelivery</model>
139
  <order_status>1</order_status>
140
  <title>Cash on Delivery</title>
141
  <allowspecific>0</allowspecific>
142
  <shippingallowspecific>0</shippingallowspecific>
143
  <disallowspecificshippingmethods>0</disallowspecificshippingmethods>
144
  <display_zero_fee>0</display_zero_fee>
145
- </cashondelivery>
146
  </payment>
147
  <sales>
148
  <totals_sort>
149
- <cashondelivery>39</cashondelivery>
150
- <cashondelivery_tax>97</cashondelivery_tax>
151
  </totals_sort>
152
  </sales>
153
  <tax>
154
  <classes>
155
- <cod_tax_class></cod_tax_class>
156
  </classes>
157
  <calculation>
158
- <cod_includes_tax>0</cod_includes_tax>
159
  </calculation>
160
  <display>
161
- <cod_fee>1</cod_fee>
162
  </display>
163
  </tax>
164
  </default>
@@ -175,9 +197,9 @@
175
  </translate>
176
  <layout>
177
  <updates>
178
- <cashondelivery>
179
- <file>cashondelivery.xml</file>
180
- </cashondelivery>
181
  </updates>
182
  </layout>
183
  </adminhtml>
@@ -185,9 +207,9 @@
185
  <frontend>
186
  <layout>
187
  <updates>
188
- <cashondelivery>
189
- <file>cashondelivery.xml</file>
190
- </cashondelivery>
191
  </updates>
192
  </layout>
193
  <translate>
23
  <config>
24
  <modules>
25
  <Phoenix_CashOnDelivery>
26
+ <version>1.0.8</version>
27
  </Phoenix_CashOnDelivery>
28
  </modules>
29
 
30
  <global>
31
  <models>
32
+ <phoenix_cashondelivery>
33
  <class>Phoenix_CashOnDelivery_Model</class>
34
+ </phoenix_cashondelivery>
35
  </models>
36
  <resources>
37
  <cashondelivery_setup>
50
  </cashondelivery_read>
51
  </resources>
52
  <helpers>
53
+ <phoenix_cashondelivery>
54
  <class>Phoenix_CashOnDelivery_Helper</class>
55
+ </phoenix_cashondelivery>
56
  </helpers>
57
  <blocks>
58
+ <phoenix_cashondelivery>
59
+ <class>Phoenix_CashOnDelivery_Block</class>
60
+ </phoenix_cashondelivery>
61
  </blocks>
62
  <sales>
63
  <quote>
64
  <totals>
65
+ <phoenix_cashondelivery>
66
+ <class>phoenix_cashondelivery/sales_quote_total</class>
67
  <after>subtotal,discount,shipping</after>
68
  <before>tax,grand_total</before>
69
+ <renderer>phoenix_cashondelivery/checkout_cod</renderer>
70
+ <admin_renderer>phoenix_cashondelivery/adminhtml_sales_order_create_totals_cod</admin_renderer>
71
+ </phoenix_cashondelivery>
72
+ <phoenix_cashondelivery_tax>
73
+ <class>phoenix_cashondelivery/sales_quote_taxTotal</class>
74
  <after>subtotal,discount,shipping,tax</after>
75
  <before>grand_total</before>
76
+ </phoenix_cashondelivery_tax>
77
  </totals>
78
  </quote>
79
  <order_invoice>
80
  <totals>
81
+ <phoenix_cashondelivery>
82
+ <class>phoenix_cashondelivery/sales_invoice_total</class>
83
+ <after>subtotal,discount,shipping</after>
84
+ <before>tax,grand_total</before>
85
+ </phoenix_cashondelivery>
86
+ <phoenix_cashondelivery_tax>
87
+ <class>phoenix_cashondelivery/sales_invoice_tax</class>
88
+ <after>subtotal,discount,shipping,tax</after>
89
+ <before>grand_total</before>
90
+ </phoenix_cashondelivery_tax>
91
  </totals>
92
  </order_invoice>
93
  <order_creditmemo>
94
  <totals>
95
+ <phoenix_cashondelivery>
96
+ <class>phoenix_cashondelivery/sales_creditmemo_total</class>
97
+ <after>subtotal,discount,shipping</after>
98
+ <before>tax,grand_total</before>
99
+ </phoenix_cashondelivery>
100
+ <phoenix_cashondelivery_tax>
101
+ <class>phoenix_cashondelivery/sales_creditmemo_tax</class>
102
+ <after>subtotal,discount,shipping,tax</after>
103
+ <before>grand_total</before>
104
+ </phoenix_cashondelivery_tax>
105
  </totals>
106
  </order_creditmemo>
107
  </sales>
108
  <events>
109
  <sales_quote_collect_totals_after>
110
  <observers>
111
+ <phoenix_cashondelivery>
112
  <type>singleton</type>
113
+ <class>phoenix_cashondelivery/observer</class>
114
  <method>sales_quote_collect_totals_after</method>
115
+ </phoenix_cashondelivery>
116
  </observers>
117
  </sales_quote_collect_totals_after>
118
  <sales_order_payment_place_end>
119
  <observers>
120
+ <phoenix_cashondelivery>
121
  <type>singleton</type>
122
+ <class>phoenix_cashondelivery/observer</class>
123
  <method>sales_order_payment_place_end</method>
124
+ </phoenix_cashondelivery>
125
  </observers>
126
  </sales_order_payment_place_end>
127
+ <order_cancel_after>
128
+ <observers>
129
+ <phoenix_cashondelivery>
130
+ <type>singleton</type>
131
+ <class>phoenix_cashondelivery/observer</class>
132
+ <method>order_cancel_after</method>
133
+ </phoenix_cashondelivery>
134
+ </observers>
135
+ </order_cancel_after>
136
  </events>
137
  <pdf>
138
  <totals>
139
+ <phoenix_cashondelivery translate="title">
140
  <title>Cash on Delivery fee</title>
141
  <source_field>cod_fee</source_field>
142
  <font_size>7</font_size>
143
  <display_zero>0</display_zero>
144
  <sort_order>450</sort_order>
145
+ <model>phoenix_cashondelivery/sales_pdf_cod</model>
146
+ </phoenix_cashondelivery>
147
  </totals>
148
  </pdf>
149
  </global>
151
  <default>
152
  <sales>
153
  <totals_sort>
154
+ <phoenix_cashondelivery>35</phoenix_cashondelivery>
155
  </totals_sort>
156
  </sales>
157
  <payment>
158
+ <phoenix_cashondelivery>
159
  <active>0</active>
160
+ <model>phoenix_cashondelivery/cashOnDelivery</model>
161
  <order_status>1</order_status>
162
  <title>Cash on Delivery</title>
163
  <allowspecific>0</allowspecific>
164
  <shippingallowspecific>0</shippingallowspecific>
165
  <disallowspecificshippingmethods>0</disallowspecificshippingmethods>
166
  <display_zero_fee>0</display_zero_fee>
167
+ </phoenix_cashondelivery>
168
  </payment>
169
  <sales>
170
  <totals_sort>
171
+ <phoenix_cashondelivery>15</phoenix_cashondelivery>
172
+ <phoenix_cashondelivery_tax>97</phoenix_cashondelivery_tax>
173
  </totals_sort>
174
  </sales>
175
  <tax>
176
  <classes>
177
+ <phoenix_cashondelivery_tax_class></phoenix_cashondelivery_tax_class>
178
  </classes>
179
  <calculation>
180
+ <phoenix_cashondelivery_includes_tax>0</phoenix_cashondelivery_includes_tax>
181
  </calculation>
182
  <display>
183
+ <phoenix_cashondelivery_fee>1</phoenix_cashondelivery_fee>
184
  </display>
185
  </tax>
186
  </default>
197
  </translate>
198
  <layout>
199
  <updates>
200
+ <phoenix_cashondelivery>
201
+ <file>phoenix/cashondelivery.xml</file>
202
+ </phoenix_cashondelivery>
203
  </updates>
204
  </layout>
205
  </adminhtml>
207
  <frontend>
208
  <layout>
209
  <updates>
210
+ <phoenix_cashondelivery>
211
+ <file>phoenix/cashondelivery.xml</file>
212
+ </phoenix_cashondelivery>
213
  </updates>
214
  </layout>
215
  <translate>
app/code/community/Phoenix/CashOnDelivery/etc/system.xml CHANGED
@@ -26,21 +26,21 @@
26
  <groups>
27
  <totals_sort>
28
  <fields>
29
- <cashondelivery translate="label" module="cashondelivery">
30
  <label>Cash on Delivery fee</label>
31
  <frontend_type>text</frontend_type>
32
  <sort_order>100</sort_order>
33
  <show_in_default>1</show_in_default>
34
  <show_in_website>1</show_in_website>
35
  <show_in_store>0</show_in_store>
36
- </cashondelivery>
37
  </fields>
38
  </totals_sort>
39
  </groups>
40
  </sales>
41
  <payment>
42
  <groups>
43
- <cashondelivery translate="label" module="payment">
44
  <label>Cash on Delivery</label>
45
  <frontend_type>text</frontend_type>
46
  <sort_order>1</sort_order>
@@ -61,7 +61,7 @@
61
  <label>Display Zero Fee</label>
62
  <frontend_type>select</frontend_type>
63
  <source_model>adminhtml/system_config_source_yesno</source_model>
64
- <sort_order>11</sort_order>
65
  <show_in_default>1</show_in_default>
66
  <show_in_website>1</show_in_website>
67
  <show_in_store>1</show_in_store>
@@ -69,7 +69,7 @@
69
  <title translate="label">
70
  <label>Title</label>
71
  <frontend_type>text</frontend_type>
72
- <sort_order>20</sort_order>
73
  <show_in_default>1</show_in_default>
74
  <show_in_website>1</show_in_website>
75
  <show_in_store>1</show_in_store>
@@ -108,11 +108,14 @@
108
  <show_in_default>1</show_in_default>
109
  <show_in_website>1</show_in_website>
110
  <show_in_store>1</show_in_store>
 
 
 
111
  </shippingspecificcountry>
112
  <min_order_total translate="label">
113
  <label>Minimum Order Total</label>
114
  <frontend_type>text</frontend_type>
115
- <sort_order>74</sort_order>
116
  <show_in_default>1</show_in_default>
117
  <show_in_website>1</show_in_website>
118
  <show_in_store>0</show_in_store>
@@ -120,15 +123,36 @@
120
  <max_order_total translate="label">
121
  <label>Maximum Order Total</label>
122
  <frontend_type>text</frontend_type>
123
- <sort_order>78</sort_order>
124
  <show_in_default>1</show_in_default>
125
  <show_in_website>1</show_in_website>
126
  <show_in_store>0</show_in_store>
127
  </max_order_total>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  <inlandcosts translate="label">
129
  <label>Costs for inland shipping</label>
130
  <frontend_type>text</frontend_type>
131
- <sort_order>80</sort_order>
132
  <show_in_default>1</show_in_default>
133
  <show_in_website>1</show_in_website>
134
  <show_in_store>1</show_in_store>
@@ -136,15 +160,15 @@
136
  <foreigncountrycosts translate="label">
137
  <label>Costs for shipping to foreign countries</label>
138
  <frontend_type>text</frontend_type>
139
- <sort_order>90</sort_order>
140
  <show_in_default>1</show_in_default>
141
  <show_in_website>1</show_in_website>
142
  <show_in_store>1</show_in_store>
143
  </foreigncountrycosts>
144
  <customtext translate="label">
145
  <label>Custom text for checkout page</label>
146
- <frontend_type>text</frontend_type>
147
- <sort_order>100</sort_order>
148
  <show_in_default>1</show_in_default>
149
  <show_in_website>1</show_in_website>
150
  <show_in_store>1</show_in_store>
@@ -152,7 +176,7 @@
152
  <disallowspecificshippingmethods translate="label">
153
  <label>Disallow specific shipping methods</label>
154
  <frontend_type>select</frontend_type>
155
- <sort_order>110</sort_order>
156
  <source_model>adminhtml/system_config_source_yesno</source_model>
157
  <show_in_default>1</show_in_default>
158
  <show_in_website>1</show_in_website>
@@ -161,21 +185,24 @@
161
  <disallowedshippingmethods translate="label">
162
  <label>Disallowed shipping methods</label>
163
  <frontend_type>multiselect</frontend_type>
164
- <sort_order>120</sort_order>
165
- <source_model>cashondelivery/source_availableShipmentMethods</source_model>
166
  <show_in_default>1</show_in_default>
167
  <show_in_website>1</show_in_website>
168
  <show_in_store>1</show_in_store>
 
 
 
169
  </disallowedshippingmethods>
170
  </fields>
171
- </cashondelivery>
172
  </groups>
173
  </payment>
174
  <tax translate="label" module="tax">
175
  <groups>
176
  <classes translate="label">
177
  <fields>
178
- <cod_tax_class translate="label">
179
  <label>Tax Class for Cash on Delivery Fee</label>
180
  <frontend_type>select</frontend_type>
181
  <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
@@ -183,12 +210,12 @@
183
  <show_in_default>1</show_in_default>
184
  <show_in_website>1</show_in_website>
185
  <show_in_store>1</show_in_store>
186
- </cod_tax_class>
187
  </fields>
188
  </classes>
189
  <calculation translate="label">
190
  <fields>
191
- <cod_includes_tax translate="label comment">
192
  <label>Cash on Delivery fee include tax</label>
193
  <frontend_type>select</frontend_type>
194
  <!--<backend_model>tax/config_price_include</backend_model>-->
@@ -197,12 +224,12 @@
197
  <show_in_default>1</show_in_default>
198
  <show_in_website>1</show_in_website>
199
  <show_in_store>1</show_in_store>
200
- </cod_includes_tax>
201
  </fields>
202
  </calculation>
203
  <display>
204
  <fields>
205
- <cod_fee translate="label">
206
  <label>Display Cod Fee</label>
207
  <frontend_type>select</frontend_type>
208
  <source_model>tax/system_config_source_tax_display_type</source_model>
@@ -210,7 +237,7 @@
210
  <show_in_default>1</show_in_default>
211
  <show_in_website>1</show_in_website>
212
  <show_in_store>1</show_in_store>
213
- </cod_fee>
214
  </fields>
215
  </display>
216
  </groups>
26
  <groups>
27
  <totals_sort>
28
  <fields>
29
+ <phoenix_cashondelivery translate="label" module="phoenix_cashondelivery">
30
  <label>Cash on Delivery fee</label>
31
  <frontend_type>text</frontend_type>
32
  <sort_order>100</sort_order>
33
  <show_in_default>1</show_in_default>
34
  <show_in_website>1</show_in_website>
35
  <show_in_store>0</show_in_store>
36
+ </phoenix_cashondelivery>
37
  </fields>
38
  </totals_sort>
39
  </groups>
40
  </sales>
41
  <payment>
42
  <groups>
43
+ <phoenix_cashondelivery translate="label" module="phoenix_cashondelivery">
44
  <label>Cash on Delivery</label>
45
  <frontend_type>text</frontend_type>
46
  <sort_order>1</sort_order>
61
  <label>Display Zero Fee</label>
62
  <frontend_type>select</frontend_type>
63
  <source_model>adminhtml/system_config_source_yesno</source_model>
64
+ <sort_order>20</sort_order>
65
  <show_in_default>1</show_in_default>
66
  <show_in_website>1</show_in_website>
67
  <show_in_store>1</show_in_store>
69
  <title translate="label">
70
  <label>Title</label>
71
  <frontend_type>text</frontend_type>
72
+ <sort_order>30</sort_order>
73
  <show_in_default>1</show_in_default>
74
  <show_in_website>1</show_in_website>
75
  <show_in_store>1</show_in_store>
108
  <show_in_default>1</show_in_default>
109
  <show_in_website>1</show_in_website>
110
  <show_in_store>1</show_in_store>
111
+ <depends>
112
+ <shippingallowspecific>1</shippingallowspecific>
113
+ </depends>
114
  </shippingspecificcountry>
115
  <min_order_total translate="label">
116
  <label>Minimum Order Total</label>
117
  <frontend_type>text</frontend_type>
118
+ <sort_order>80</sort_order>
119
  <show_in_default>1</show_in_default>
120
  <show_in_website>1</show_in_website>
121
  <show_in_store>0</show_in_store>
123
  <max_order_total translate="label">
124
  <label>Maximum Order Total</label>
125
  <frontend_type>text</frontend_type>
126
+ <sort_order>90</sort_order>
127
  <show_in_default>1</show_in_default>
128
  <show_in_website>1</show_in_website>
129
  <show_in_store>0</show_in_store>
130
  </max_order_total>
131
+ <cost_type translate="label">
132
+ <label>Cost calculation</label>
133
+ <frontend_type>select</frontend_type>
134
+ <source_model>phoenix_cashondelivery/source_costType</source_model>
135
+ <sort_order>100</sort_order>
136
+ <show_in_default>1</show_in_default>
137
+ <show_in_website>1</show_in_website>
138
+ <show_in_store>1</show_in_store>
139
+ </cost_type>
140
+ <cost_calc_base>
141
+ <label>Cost calculation base</label>
142
+ <frontend_type>text</frontend_type>
143
+ <sort_order>110</sort_order>
144
+ <show_in_default>1</show_in_default>
145
+ <show_in_website>1</show_in_website>
146
+ <show_in_store>1</show_in_store>
147
+ <comment>Please enter an sales_flat_quote_address attribute code which will be taken as base for the cost calculation.</comment>
148
+ <depends>
149
+ <cost_type>1</cost_type>
150
+ </depends>
151
+ </cost_calc_base>
152
  <inlandcosts translate="label">
153
  <label>Costs for inland shipping</label>
154
  <frontend_type>text</frontend_type>
155
+ <sort_order>120</sort_order>
156
  <show_in_default>1</show_in_default>
157
  <show_in_website>1</show_in_website>
158
  <show_in_store>1</show_in_store>
160
  <foreigncountrycosts translate="label">
161
  <label>Costs for shipping to foreign countries</label>
162
  <frontend_type>text</frontend_type>
163
+ <sort_order>130</sort_order>
164
  <show_in_default>1</show_in_default>
165
  <show_in_website>1</show_in_website>
166
  <show_in_store>1</show_in_store>
167
  </foreigncountrycosts>
168
  <customtext translate="label">
169
  <label>Custom text for checkout page</label>
170
+ <frontend_type>textarea</frontend_type>
171
+ <sort_order>140</sort_order>
172
  <show_in_default>1</show_in_default>
173
  <show_in_website>1</show_in_website>
174
  <show_in_store>1</show_in_store>
176
  <disallowspecificshippingmethods translate="label">
177
  <label>Disallow specific shipping methods</label>
178
  <frontend_type>select</frontend_type>
179
+ <sort_order>150</sort_order>
180
  <source_model>adminhtml/system_config_source_yesno</source_model>
181
  <show_in_default>1</show_in_default>
182
  <show_in_website>1</show_in_website>
185
  <disallowedshippingmethods translate="label">
186
  <label>Disallowed shipping methods</label>
187
  <frontend_type>multiselect</frontend_type>
188
+ <sort_order>160</sort_order>
189
+ <source_model>phoenix_cashondelivery/source_availableShipmentMethods</source_model>
190
  <show_in_default>1</show_in_default>
191
  <show_in_website>1</show_in_website>
192
  <show_in_store>1</show_in_store>
193
+ <depends>
194
+ <disallowspecificshippingmethods>1</disallowspecificshippingmethods>
195
+ </depends>
196
  </disallowedshippingmethods>
197
  </fields>
198
+ </phoenix_cashondelivery>
199
  </groups>
200
  </payment>
201
  <tax translate="label" module="tax">
202
  <groups>
203
  <classes translate="label">
204
  <fields>
205
+ <phoenix_cashondelivery_tax_class translate="label" module="phoenix_cashondelivery">
206
  <label>Tax Class for Cash on Delivery Fee</label>
207
  <frontend_type>select</frontend_type>
208
  <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
210
  <show_in_default>1</show_in_default>
211
  <show_in_website>1</show_in_website>
212
  <show_in_store>1</show_in_store>
213
+ </phoenix_cashondelivery_tax_class>
214
  </fields>
215
  </classes>
216
  <calculation translate="label">
217
  <fields>
218
+ <phoenix_cashondelivery_includes_tax translate="label" module="phoenix_cashondelivery">
219
  <label>Cash on Delivery fee include tax</label>
220
  <frontend_type>select</frontend_type>
221
  <!--<backend_model>tax/config_price_include</backend_model>-->
224
  <show_in_default>1</show_in_default>
225
  <show_in_website>1</show_in_website>
226
  <show_in_store>1</show_in_store>
227
+ </phoenix_cashondelivery_includes_tax>
228
  </fields>
229
  </calculation>
230
  <display>
231
  <fields>
232
+ <phoenix_cashondelivery_fee translate="label" module="phoenix_cashondelivery">
233
  <label>Display Cod Fee</label>
234
  <frontend_type>select</frontend_type>
235
  <source_model>tax/system_config_source_tax_display_type</source_model>
237
  <show_in_default>1</show_in_default>
238
  <show_in_website>1</show_in_website>
239
  <show_in_store>1</show_in_store>
240
+ </phoenix_cashondelivery_fee>
241
  </fields>
242
  </display>
243
  </groups>
app/code/community/Phoenix/CashOnDelivery/sql/cashondelivery_setup/mysql4-install-0.2.0.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
 
@@ -33,18 +33,9 @@ $eav->addAttribute('order', 'base_cod_fee', array('type' => 'decimal'));
33
  $eav->addAttribute('order', 'cod_fee_invoiced', array('type' => 'decimal',));
34
  $eav->addAttribute('order', 'base_cod_fee_invoiced', array('type' => 'decimal'));
35
 
36
- //$eav->addAttribute('order', 'cod_fee_refunded', array('type' => 'decimal',));
37
- //$eav->addAttribute('order', 'base_cod_fee_refunded', array('type' => 'decimal'));
38
-
39
- //$eav->addAttribute('order', 'cod_fee_canceled', array('type' => 'decimal',));
40
- //$eav->addAttribute('order', 'base_cod_fee_canceled', array('type' => 'decimal'));
41
-
42
  $eav->addAttribute('invoice', 'cod_fee', array('type' => 'decimal',));
43
  $eav->addAttribute('invoice', 'base_cod_fee', array('type' => 'decimal'));
44
 
45
- //$eav->addAttribute('creditmemo', 'cod_fee', array('type' => 'decimal',));
46
- //$eav->addAttribute('creditmemo', 'base_cod_fee', array('type' => 'decimal'));
47
-
48
  $this->endSetup();
49
 
50
  ?>
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
 
33
  $eav->addAttribute('order', 'cod_fee_invoiced', array('type' => 'decimal',));
34
  $eav->addAttribute('order', 'base_cod_fee_invoiced', array('type' => 'decimal'));
35
 
 
 
 
 
 
 
36
  $eav->addAttribute('invoice', 'cod_fee', array('type' => 'decimal',));
37
  $eav->addAttribute('invoice', 'base_cod_fee', array('type' => 'decimal'));
38
 
 
 
 
39
  $this->endSetup();
40
 
41
  ?>
app/code/community/Phoenix/CashOnDelivery/sql/cashondelivery_setup/mysql4-upgrade-0.2.0-0.2.1.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
 
@@ -33,18 +33,9 @@ $eav->addAttribute('order', 'base_cod_tax_amount', array('type' => 'decimal'));
33
  $eav->addAttribute('order', 'cod_tax_amount_invoiced', array('type' => 'decimal',));
34
  $eav->addAttribute('order', 'base_cod_tax_amount_invoiced', array('type' => 'decimal'));
35
 
36
- //$eav->addAttribute('order', 'cod_tax_amount_refunded', array('type' => 'decimal',));
37
- //$eav->addAttribute('order', 'base_cod_tax_amount_refunded', array('type' => 'decimal'));
38
-
39
- //$eav->addAttribute('order', 'cod_tax_amount_canceled', array('type' => 'decimal',));
40
- //$eav->addAttribute('order', 'base_cod_tax_amount_canceled', array('type' => 'decimal'));
41
-
42
  $eav->addAttribute('invoice', 'cod_tax_amount', array('type' => 'decimal',));
43
  $eav->addAttribute('invoice', 'base_cod_tax_amount', array('type' => 'decimal'));
44
 
45
- //$eav->addAttribute('creditmemo', 'cod_tax_amount', array('type' => 'decimal',));
46
- //$eav->addAttribute('creditmemo', 'base_cod_tax_amount', array('type' => 'decimal'));
47
-
48
  $this->endSetup();
49
 
50
  ?>
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
 
33
  $eav->addAttribute('order', 'cod_tax_amount_invoiced', array('type' => 'decimal',));
34
  $eav->addAttribute('order', 'base_cod_tax_amount_invoiced', array('type' => 'decimal'));
35
 
 
 
 
 
 
 
36
  $eav->addAttribute('invoice', 'cod_tax_amount', array('type' => 'decimal',));
37
  $eav->addAttribute('invoice', 'base_cod_tax_amount', array('type' => 'decimal'));
38
 
 
 
 
39
  $this->endSetup();
40
 
41
  ?>
app/code/community/Phoenix/CashOnDelivery/sql/cashondelivery_setup/mysql4-upgrade-0.3.2-0.3.3.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
 
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
 
app/code/community/Phoenix/CashOnDelivery/sql/cashondelivery_setup/mysql4-upgrade-0.4.6-0.4.7.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
 
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
 
app/code/community/Phoenix/CashOnDelivery/sql/cashondelivery_setup/mysql4-upgrade-1.0.7-1.0.8.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $this->startSetup();
22
+
23
+ $setup = new Mage_Sales_Model_Mysql4_Setup('sales_setup');
24
+
25
+ $setup->addAttribute('order', 'cod_fee_refunded', array('type' => 'decimal'));
26
+ $setup->addAttribute('order', 'base_cod_fee_refunded', array('type' => 'decimal'));
27
+ $setup->addAttribute('order', 'cod_tax_amount_refunded', array('type' => 'decimal'));
28
+ $setup->addAttribute('order', 'base_cod_tax_amount_refunded', array('type' => 'decimal'));
29
+ $setup->addAttribute('order', 'cod_fee_canceled', array('type' => 'decimal'));
30
+ $setup->addAttribute('order', 'base_cod_fee_canceled', array('type' => 'decimal'));
31
+ $setup->addAttribute('order', 'cod_tax_amount_canceled', array('type' => 'decimal'));
32
+ $setup->addAttribute('order', 'base_cod_tax_amount_canceled', array('type' => 'decimal'));
33
+
34
+ $setup->addAttribute('creditmemo', 'cod_fee', array('type' => 'decimal'));
35
+ $setup->addAttribute('creditmemo', 'base_cod_fee', array('type' => 'decimal'));
36
+ $setup->addAttribute('creditmemo', 'cod_tax_amount', array('type' => 'decimal'));
37
+ $setup->addAttribute('creditmemo', 'base_cod_tax_amount', array('type' => 'decimal'));
38
+
39
+ $this->endSetup();
app/design/adminhtml/default/default/layout/cashondelivery.xml DELETED
@@ -1,102 +0,0 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Academic Free License (AFL 3.0)
9
- * that is bundled with this package in the file LICENSE_AFL.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/afl-3.0.php
12
- * If you did not receive a copy of the license and are unable to
13
- * obtain it through the world-wide-web, please send an email
14
- * to license@magentocommerce.com so we can send you a copy immediately.
15
- *
16
- * DISCLAIMER
17
- *
18
- * Do not edit or add to this file if you wish to upgrade Magento to newer
19
- * versions in the future. If you wish to customize Magento for your
20
- * needs please refer to http://www.magentocommerce.com for more information.
21
- *
22
- * @category design_default
23
- * @package Phoenix_CashOnDelivery
24
- * @copyright Copyright (c) 2010 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
25
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
- */
27
- -->
28
-
29
- <layout>
30
- <adminhtml_sales_order_view>
31
- <!--
32
- <reference name="sales.order.view.totals.main">
33
- <block type="adminhtml/sales_order_totals_item" name="cod_fee" template="sales/order/totals/item.phtml" before="tax">
34
- <action method="setSourceField"><value>cod_fee</value></action>
35
- <action method="setLabel"><value>Cash on Delivery Fee</value></action>
36
- </block>
37
- </reference>
38
- -->
39
- <reference name="order_totals">
40
- <block name="cod_fee" type="cashondelivery/order_totals_cod" before="tax"/>
41
- </reference>
42
- </adminhtml_sales_order_view>
43
-
44
- <adminhtml_sales_order_invoice_view>
45
- <!--
46
- <reference name="sales.order.view.totals.main">
47
- <block type="adminhtml/sales_order_totals_item" name="cod_fee" template="sales/order/totals/item.phtml" before="tax">
48
- <action method="setSourceField"><value>cod_fee</value></action>
49
- <action method="setLabel"><value>Cash on Delivery Fee</value></action>
50
- </block>
51
- </reference>
52
- -->
53
- <reference name="invoice_totals">
54
- <block name="cod_fee" type="cashondelivery/invoice_totals_cod" before="tax"/>
55
- </reference>
56
- </adminhtml_sales_order_invoice_view>
57
-
58
- <adminhtml_sales_order_invoice_new>
59
- <!--
60
- <reference name="sales.order.view.totals.main">
61
- <block type="adminhtml/sales_order_totals_item" name="cod_fee" template="sales/order/totals/item.phtml" before="tax">
62
- <action method="setSourceField"><value>cod_fee</value></action>
63
- <action method="setLabel"><value>Cash on Delivery Fee</value></action>
64
- </block>
65
- </reference>
66
- -->
67
- <reference name="invoice_totals">
68
- <block name="cod_fee" type="cashondelivery/invoice_totals_cod" before="tax"/>
69
- </reference>
70
- </adminhtml_sales_order_invoice_new>
71
-
72
- <adminhtml_sales_order_invoice_updateqty>
73
- <reference name="invoice_totals">
74
- <block name="cod_fee" type="cashondelivery/invoice_totals_cod" before="tax"/>
75
- </reference>
76
- </adminhtml_sales_order_invoice_updateqty>
77
-
78
- <adminhtml_sales_order_creditmemo_new>
79
- <reference name="sales.order.view.totals.main">
80
- <block type="adminhtml/sales_order_totals_item" name="cod_fee" template="sales/order/totals/item.phtml" before="tax">
81
- <action method="setSourceField"><value>cod_fee</value></action>
82
- <action method="setLabel"><value>Cash on Delivery Fee</value></action>
83
- </block>
84
- </reference>
85
- </adminhtml_sales_order_creditmemo_new>
86
-
87
- <adminhtml_sales_order_creditmemo_view>
88
- <reference name="sales.order.view.totals.main">
89
- <block type="adminhtml/sales_order_totals_item" name="cod_fee" template="sales/order/totals/item.phtml" before="tax">
90
- <action method="setSourceField"><value>cod_fee</value></action>
91
- <action method="setLabel"><value>Cash on Delivery Fee</value></action>
92
- </block>
93
- </reference>
94
- </adminhtml_sales_order_creditmemo_view>
95
-
96
- <adminhtml_sales_order_create_index>
97
- <reference name="head">
98
- <action method="addJs"><file>phoenix/cashondelivery/sales.js</file></action>
99
- </reference>
100
- </adminhtml_sales_order_create_index>
101
-
102
- </layout>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/layout/phoenix/cashondelivery.xml ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
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 bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Phoenix
17
+ * @package Phoenix_CashOnDelivery
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
+
23
+ <layout>
24
+ <adminhtml_sales_order_view>
25
+ <reference name="order_totals">
26
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_order"/>
27
+ </reference>
28
+ </adminhtml_sales_order_view>
29
+
30
+ <adminhtml_sales_order_invoice_view>
31
+ <reference name="invoice_totals">
32
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_invoice"/>
33
+ </reference>
34
+ </adminhtml_sales_order_invoice_view>
35
+
36
+ <adminhtml_sales_order_invoice_new>
37
+ <reference name="invoice_totals">
38
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_invoice"/>
39
+ </reference>
40
+ </adminhtml_sales_order_invoice_new>
41
+
42
+ <adminhtml_sales_order_invoice_updateqty>
43
+ <reference name="invoice_totals">
44
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_invoice"/>
45
+ </reference>
46
+ </adminhtml_sales_order_invoice_updateqty>
47
+
48
+ <adminhtml_sales_order_creditmemo_new>
49
+ <reference name="creditmemo_totals">
50
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/adminhtml_sales_creditmemo_create_totals"/>
51
+ </reference>
52
+ </adminhtml_sales_order_creditmemo_new>
53
+
54
+ <adminhtml_sales_order_creditmemo_view>
55
+ <reference name="creditmemo_totals">
56
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_creditmemo"/>
57
+ </reference>
58
+ </adminhtml_sales_order_creditmemo_view>
59
+
60
+ <adminhtml_sales_order_creditmemo_updateqty>
61
+ <reference name="creditmemo_totals">
62
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_creditmemo"/>
63
+ </reference>
64
+ </adminhtml_sales_order_creditmemo_updateqty>
65
+
66
+ <adminhtml_sales_order_create_index>
67
+ <reference name="head">
68
+ <action method="addJs"><file>phoenix/cashondelivery/sales.js</file></action>
69
+ </reference>
70
+ </adminhtml_sales_order_create_index>
71
+
72
+ </layout>
app/design/adminhtml/default/default/template/{cashondelivery → phoenix/cashondelivery}/form.phtml RENAMED
@@ -5,8 +5,12 @@
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
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
app/design/adminhtml/default/default/template/{cashondelivery → phoenix/cashondelivery}/info.phtml RENAMED
@@ -5,8 +5,12 @@
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
@@ -24,16 +28,16 @@
24
  $_extra_fee_excl = $this->getCodFeeExclTax();
25
  $_extra_fee_incl = $this->getCodFeeInclTax();
26
  if (!is_null($_extra_fee_excl)):
27
- if ($this->helper('cashondelivery')->displayCodFeeIncludingTax()){
28
  $_codFeeStr = $_extra_fee_incl;
29
  }else{
30
  $_codFeeStr = $_extra_fee_excl;
31
- if ($this->helper('cashondelivery')->displayCodBothPrices() && ($_extra_fee_incl != $_extra_fee_excl)) {
32
  $_codFeeStr .= ' ('.$this->__('Incl. Tax').' '.$_extra_fee_incl.')';
33
  }
34
  }
35
  ?>
36
- <?php if((float)$this->getRawCodFee() || Mage::getStoreConfig('payment/cashondelivery/display_zero_fee')): ?>
37
  <div>
38
  <?php echo $this->__('Cash on Delivery fee %s', $_codFeeStr) ?>
39
  </div>
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
28
  $_extra_fee_excl = $this->getCodFeeExclTax();
29
  $_extra_fee_incl = $this->getCodFeeInclTax();
30
  if (!is_null($_extra_fee_excl)):
31
+ if ($this->helper('phoenix_cashondelivery')->displayCodFeeIncludingTax()){
32
  $_codFeeStr = $_extra_fee_incl;
33
  }else{
34
  $_codFeeStr = $_extra_fee_excl;
35
+ if ($this->helper('phoenix_cashondelivery')->displayCodBothPrices() && ($_extra_fee_incl != $_extra_fee_excl)) {
36
  $_codFeeStr .= ' ('.$this->__('Incl. Tax').' '.$_extra_fee_incl.')';
37
  }
38
  }
39
  ?>
40
+ <?php if((float)$this->getRawCodFee() || Mage::getStoreConfig('payment/phoenix_cashondelivery/display_zero_fee')): ?>
41
  <div>
42
  <?php echo $this->__('Cash on Delivery fee %s', $_codFeeStr) ?>
43
  </div>
app/design/adminhtml/default/default/template/{cashondelivery → phoenix/cashondelivery}/pdf/info.phtml RENAMED
@@ -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
  ?>
@@ -29,12 +29,12 @@
29
  $_extra_fee_incl = $this->getCodFeeInclTax();
30
  if (!is_null($_extra_fee_excl)):
31
  $_codFeeStr = $_extra_fee_excl;
32
- if ($this->helper('cashondelivery')->displayCodBothPrices() && ($_extra_fee_incl != $_extra_fee_excl)) {
33
- $_codFeeStr .= ' ('.$this->__('Incl. Tax').' '.$_extra_fee_incl.')';
34
  }
35
  ?>
36
 
37
- <?php if((float)$this->getRawCodFee() || Mage::getStoreConfig('payment/cashondelivery/display_zero_fee')): ?>
38
- <?php echo $this->__('Cash on Delivery fee %s', $_codFeeStr) ?>
39
  <?php endif; ?>
40
  <?php endif; ?>
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
  ?>
29
  $_extra_fee_incl = $this->getCodFeeInclTax();
30
  if (!is_null($_extra_fee_excl)):
31
  $_codFeeStr = $_extra_fee_excl;
32
+ if ($this->helper('phoenix_cashondelivery')->displayCodBothPrices() && ($_extra_fee_incl != $_extra_fee_excl)) {
33
+ $_codFeeStr .= '{{pdf_row_separator}}('.$this->__('Incl. Tax').' '.$_extra_fee_incl.')';
34
  }
35
  ?>
36
 
37
+ <?php if((float)$this->getRawCodFee() || Mage::getStoreConfig('payment/phoenix_cashondelivery/display_zero_fee')): ?>
38
+ <?php echo $this->__('Cash on Delivery fee %s', strip_tags($_codFeeStr)) ?>
39
  <?php endif; ?>
40
  <?php endif; ?>
app/design/adminhtml/default/default/template/{cashondelivery → phoenix/cashondelivery}/sales/order/create/totals/cod.phtml RENAMED
@@ -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
 
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
 
app/design/frontend/base/default/layout/cashondelivery.xml DELETED
@@ -1,65 +0,0 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Academic Free License (AFL 3.0)
9
- * that is bundled with this package in the file LICENSE_AFL.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/afl-3.0.php
12
- * If you did not receive a copy of the license and are unable to
13
- * obtain it through the world-wide-web, please send an email
14
- * to license@magentocommerce.com so we can send you a copy immediately.
15
- *
16
- * DISCLAIMER
17
- *
18
- * Do not edit or add to this file if you wish to upgrade Magento to newer
19
- * versions in the future. If you wish to customize Magento for your
20
- * needs please refer to http://www.magentocommerce.com for more information.
21
- *
22
- * @category design_default
23
- * @package Phoenix_CashOnDelivery
24
- * @copyright Copyright (c) 2010 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
25
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
- */
27
- -->
28
-
29
- <layout>
30
- <sales_order_print>
31
- <reference name="order_totals">
32
- <block name="cod_fee" type="cashondelivery/order_totals_cod" before="tax"/>
33
- </reference>
34
- </sales_order_print>
35
-
36
- <sales_order_view>
37
- <reference name="order_totals">
38
- <block name="cod_fee" type="cashondelivery/order_totals_cod" before="tax"/>
39
- </reference>
40
- </sales_order_view>
41
-
42
- <sales_order_invoice>
43
- <reference name="invoice_totals">
44
- <block name="cod_fee" type="cashondelivery/invoice_totals_cod" before="tax"/>
45
- </reference>
46
- </sales_order_invoice>
47
-
48
- <sales_order_printinvoice>
49
- <reference name="invoice_totals">
50
- <block name="cod_fee" type="cashondelivery/invoice_totals_cod" before="tax"/>
51
- </reference>
52
- </sales_order_printinvoice>
53
-
54
- <sales_email_order_items>
55
- <reference name="order_totals">
56
- <block name="cod_fee" type="cashondelivery/order_totals_cod" before="tax"/>
57
- </reference>
58
- </sales_email_order_items>
59
-
60
- <sales_email_order_invoice_items>
61
- <reference name="invoice_totals">
62
- <block name="cod_fee" type="cashondelivery/invoice_totals_cod" before="tax"/>
63
- </reference>
64
- </sales_email_order_invoice_items>
65
- </layout>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/layout/phoenix/cashondelivery.xml ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
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 bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Phoenix
17
+ * @package Phoenix_CashOnDelivery
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
+
23
+ <layout>
24
+ <sales_order_print>
25
+ <reference name="order_totals">
26
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_order"/>
27
+ </reference>
28
+ </sales_order_print>
29
+
30
+ <sales_order_view>
31
+ <reference name="order_totals">
32
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_order"/>
33
+ </reference>
34
+ </sales_order_view>
35
+
36
+ <sales_order_invoice>
37
+ <reference name="invoice_totals">
38
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_invoice"/>
39
+ </reference>
40
+ </sales_order_invoice>
41
+
42
+ <sales_order_printinvoice>
43
+ <reference name="invoice_totals">
44
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_invoice"/>
45
+ </reference>
46
+ </sales_order_printinvoice>
47
+
48
+ <sales_email_order_items>
49
+ <reference name="order_totals">
50
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_order"/>
51
+ </reference>
52
+ </sales_email_order_items>
53
+
54
+ <sales_email_order_invoice_items>
55
+ <reference name="invoice_totals">
56
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_invoice"/>
57
+ </reference>
58
+ </sales_email_order_invoice_items>
59
+
60
+ <sales_order_creditmemo>
61
+ <reference name="creditmemo_totals">
62
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_creditmemo"/>
63
+ </reference>
64
+ </sales_order_creditmemo>
65
+
66
+ <sales_order_printcreditmemo>
67
+ <reference name="creditmemo_totals">
68
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_creditmemo"/>
69
+ </reference>
70
+ </sales_order_printcreditmemo>
71
+
72
+ <sales_email_order_creditmemo_items>
73
+ <reference name="creditmemo_totals">
74
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_creditmemo"/>
75
+ </reference>
76
+ </sales_email_order_creditmemo_items>
77
+
78
+ <sales_guest_view>
79
+ <reference name="order_totals">
80
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_order"/>
81
+ </reference>
82
+ </sales_guest_view>
83
+
84
+ <sales_guest_print>
85
+ <reference name="order_totals">
86
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_order"/>
87
+ </reference>
88
+ </sales_guest_print>
89
+
90
+ <sales_guest_invoice>
91
+ <reference name="invoice_totals">
92
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_invoice"/>
93
+ </reference>
94
+ </sales_guest_invoice>
95
+
96
+ <sales_guest_printinvoice>
97
+ <reference name="invoice_totals">
98
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_invoice"/>
99
+ </reference>
100
+ </sales_guest_printinvoice>
101
+
102
+ <sales_guest_creditmemo>
103
+ <reference name="creditmemo_totals">
104
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_creditmemo"/>
105
+ </reference>
106
+ </sales_guest_creditmemo>
107
+
108
+ <sales_guest_printcreditmemo>
109
+ <reference name="creditmemo_totals">
110
+ <block name="phoenix_cashondelivery_fee" type="phoenix_cashondelivery/totals_creditmemo"/>
111
+ </reference>
112
+ </sales_guest_printcreditmemo>
113
+ </layout>
app/design/frontend/base/default/template/{cashondelivery → phoenix/cashondelivery}/checkout/cod.phtml RENAMED
@@ -14,9 +14,10 @@
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
  * @var $this Phoenix_CashOnDelivery_Block_Checkout_Cod
22
  * @see Phoenix_CashOnDelivery_Block_Checkout_Cod
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
  /**
22
  * @var $this Phoenix_CashOnDelivery_Block_Checkout_Cod
23
  * @see Phoenix_CashOnDelivery_Block_Checkout_Cod
app/design/frontend/base/default/template/{cashondelivery → phoenix/cashondelivery}/form.phtml RENAMED
@@ -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,18 +22,18 @@
22
  $_code = $this->getMethodCode();
23
  $_extra_fee = $this->getMethod()->getAddressCosts($this->getShippingAddress());
24
 
25
- $_extra_fee_excl = $this->convertPrice(Mage::helper('cashondelivery')->getCodPrice($_extra_fee, $this->helper('cashondelivery')->displayCodFeeIncludingTax(), $this->getShippingAddress()), true);
26
- $_extra_fee_incl = $this->convertPrice(Mage::helper('cashondelivery')->getCodPrice($_extra_fee, true, $this->getShippingAddress()), true);
27
 
28
  $_codFeeStr = $_extra_fee_excl;
29
- if ($this->helper('cashondelivery')->displayCodBothPrices() && ($_extra_fee_incl != $_extra_fee_excl)) {
30
  $_codFeeStr .= ' ('.$this->__('Incl. Tax').' '.$_extra_fee_incl.')';
31
  }
32
  ?>
33
- <?php if($this->getMethod()->getCustomText() || $_extra_fee || Mage::getStoreConfig('payment/cashondelivery/display_zero_fee')): ?>
34
  <fieldset class="form-list">
35
  <ul id="payment_form_<?php echo $_code ?>" style="display:none;">
36
- <?php if($_extra_fee || Mage::getStoreConfig('payment/cashondelivery/display_zero_fee')): ?>
37
  <li><?php echo $this->__('You will be charged an extra fee of %s.', $_codFeeStr) ?></li>
38
  <?php endif; ?>
39
  <?php if ($this->getMethod()->getCustomText()): ?>
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
  $_code = $this->getMethodCode();
23
  $_extra_fee = $this->getMethod()->getAddressCosts($this->getShippingAddress());
24
 
25
+ $_extra_fee_excl = $this->convertPrice(Mage::helper('phoenix_cashondelivery')->getCodPrice($_extra_fee, $this->helper('phoenix_cashondelivery')->displayCodFeeIncludingTax(), $this->getShippingAddress()), true);
26
+ $_extra_fee_incl = $this->convertPrice(Mage::helper('phoenix_cashondelivery')->getCodPrice($_extra_fee, true, $this->getShippingAddress()), true);
27
 
28
  $_codFeeStr = $_extra_fee_excl;
29
+ if ($this->helper('phoenix_cashondelivery')->displayCodBothPrices() && ($_extra_fee_incl != $_extra_fee_excl)) {
30
  $_codFeeStr .= ' ('.$this->__('Incl. Tax').' '.$_extra_fee_incl.')';
31
  }
32
  ?>
33
+ <?php if($this->getMethod()->getCustomText() || $_extra_fee || Mage::getStoreConfig('payment/phoenix_cashondelivery/display_zero_fee')): ?>
34
  <fieldset class="form-list">
35
  <ul id="payment_form_<?php echo $_code ?>" style="display:none;">
36
+ <?php if($_extra_fee || Mage::getStoreConfig('payment/phoenix_cashondelivery/display_zero_fee')): ?>
37
  <li><?php echo $this->__('You will be charged an extra fee of %s.', $_codFeeStr) ?></li>
38
  <?php endif; ?>
39
  <?php if ($this->getMethod()->getCustomText()): ?>
app/design/frontend/base/default/template/{cashondelivery → phoenix/cashondelivery}/info.phtml RENAMED
@@ -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
  ?>
@@ -27,16 +27,16 @@
27
  $_extra_fee_excl = $this->getCodFeeExclTax();
28
  $_extra_fee_incl = $this->getCodFeeInclTax();
29
  if (!is_null($_extra_fee_excl)):
30
- if ($this->helper('cashondelivery')->displayCodFeeIncludingTax()){
31
  $_codFeeStr = $_extra_fee_incl;
32
  }else{
33
  $_codFeeStr = $_extra_fee_excl;
34
- if ($this->helper('cashondelivery')->displayCodBothPrices() && ($_extra_fee_incl != $_extra_fee_excl)) {
35
  $_codFeeStr .= ' ('.$this->__('Incl. Tax').' '.$_extra_fee_incl.')';
36
  }
37
  }
38
  ?>
39
- <?php if((float)$this->getRawCodFee() || Mage::getStoreConfig('payment/cashondelivery/display_zero_fee')): ?>
40
  <div>
41
  <?php echo $this->__('Cash on Delivery fee %s', $_codFeeStr) ?>
42
  </div>
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
  ?>
27
  $_extra_fee_excl = $this->getCodFeeExclTax();
28
  $_extra_fee_incl = $this->getCodFeeInclTax();
29
  if (!is_null($_extra_fee_excl)):
30
+ if ($this->helper('phoenix_cashondelivery')->displayCodFeeIncludingTax()){
31
  $_codFeeStr = $_extra_fee_incl;
32
  }else{
33
  $_codFeeStr = $_extra_fee_excl;
34
+ if ($this->helper('phoenix_cashondelivery')->displayCodBothPrices() && ($_extra_fee_incl != $_extra_fee_excl)) {
35
  $_codFeeStr .= ' ('.$this->__('Incl. Tax').' '.$_extra_fee_incl.')';
36
  }
37
  }
38
  ?>
39
+ <?php if((float)$this->getRawCodFee() || Mage::getStoreConfig('payment/phoenix_cashondelivery/display_zero_fee')): ?>
40
  <div>
41
  <?php echo $this->__('Cash on Delivery fee %s', $_codFeeStr) ?>
42
  </div>
app/etc/modules/Phoenix_CashOnDelivery.xml CHANGED
@@ -15,7 +15,7 @@
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
  -->
15
  *
16
  * @category Phoenix
17
  * @package Phoenix_CashOnDelivery
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
  -->
app/locale/de_DE/Phoenix_CashOnDelivery.csv CHANGED
@@ -6,6 +6,12 @@
6
  "You will be charged an extra fee of %s.","Eine Nachnahmegebühr von %s wird erhoben."
7
  "Incl. Tax","inkl. Steuern"
8
  "Cash on Delivery fee (Excl.Tax)","Nachnahme Gebühr (exkl. Steuern)"
9
- "Cash on Delivery fee (Incl.Tax)","Nachnahme Gebühr fee (inkl. Steuern)"
10
  "Cash on Delivery fee %s","Nachnahme Gebühr %s"
11
- "Refund Cash on Delivery fee","Refund Cash on Delivery fee"
 
 
 
 
 
 
6
  "You will be charged an extra fee of %s.","Eine Nachnahmegebühr von %s wird erhoben."
7
  "Incl. Tax","inkl. Steuern"
8
  "Cash on Delivery fee (Excl.Tax)","Nachnahme Gebühr (exkl. Steuern)"
9
+ "Cash on Delivery fee (Incl.Tax)","Nachnahme Gebühr (inkl. Steuern)"
10
  "Cash on Delivery fee %s","Nachnahme Gebühr %s"
11
+ "Refund Cash on Delivery fee","Refund Cash on Delivery fee"
12
+ "Cost calculation","Berechnungsart der Gebühr"
13
+ "Fixed","Fix"
14
+ "Percentage","Prozentual"
15
+ "Cost calculation base","Berechnungsbasis der Gebühr"
16
+ "Please enter an sales_flat_quote_address attribute code which will be taken as base for the cost calculation.","bitte geben Sie hier ein sales_flat_quote_address Attribut Code ein, dessen Wert als Basis für die prozentuale Berechnung benutzt wird."
17
+ "Refund Cash on Delivery fee","Nachname Gebühr erstatten"
app/locale/en_US/Phoenix_CashOnDelivery.csv CHANGED
@@ -8,4 +8,10 @@
8
  "Cash on Delivery fee (Excl.Tax)","Cash on Delivery fee (Excl.Tax)"
9
  "Cash on Delivery fee (Incl.Tax)","Cash on Delivery fee (Incl.Tax)"
10
  "Cash on Delivery fee %s","Cash on Delivery fee %s"
 
 
 
 
 
 
11
  "Refund Cash on Delivery fee","Refund Cash on Delivery fee"
8
  "Cash on Delivery fee (Excl.Tax)","Cash on Delivery fee (Excl.Tax)"
9
  "Cash on Delivery fee (Incl.Tax)","Cash on Delivery fee (Incl.Tax)"
10
  "Cash on Delivery fee %s","Cash on Delivery fee %s"
11
+ "Refund Cash on Delivery fee","Refund Cash on Delivery fee"
12
+ "Cost calculation","Cost calculation"
13
+ "Fixed","Fixed"
14
+ "Percentage","Percentage"
15
+ "Cost calculation base","Cost calculation base"
16
+ "Please enter an sales_flat_quote_address attribute code which will be taken as base for the cost calculation.","Please enter an sales_flat_quote_address attribute code which will be taken as base for the cost calculation."
17
  "Refund Cash on Delivery fee","Refund Cash on Delivery fee"
js/phoenix/cashondelivery/sales.js CHANGED
@@ -1,4 +1,23 @@
1
- /*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  * To change this template, choose Tools | Templates
3
  * and open the template in the editor.
4
  */
1
+ /**
2
+ * Magento
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com so we can send you a copy immediately.
13
+ *
14
+ * @category Phoenix
15
+ * @package Phoenix_CashOnDelivery
16
+ * @copyright Copyright (c) 2010 - 2013 PHOENIX MEDIA GmbH (http://www.phoenix-media.eu)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ /*
21
  * To change this template, choose Tools | Templates
22
  * and open the template in the editor.
23
  */
package.xml CHANGED
@@ -1,18 +1,19 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>CashOnDelivery</name>
4
- <version>1.0.6</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Cash on Delivery allows to book additional fee on delivery depending on inland or international delivery.</summary>
10
  <description>Cash on Delivery allows to book additional fee on delivery depending on inland or international delivery.</description>
11
- <notes>- code beautification</notes>
 
12
  <authors><author><name>Phoenix Medien</name><user>auto-converted</user><email>info@phoenix-medien.de</email></author></authors>
13
- <date>2012-06-11</date>
14
- <time>17:37:34</time>
15
- <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="cashondelivery.xml" hash="d958bd8b5f96a4d6cb093800155bbf08"/></dir><dir name="template"><dir name="cashondelivery"><dir name="pdf"><file name="info.phtml" hash="b40f4cff0103aac523ef3699354d9eaf"/></dir><dir name="sales"><dir name="order"><dir name="create"><dir name="totals"><file name="cod.phtml" hash="7422de3104549c82730ce838ca1fe6ac"/></dir></dir></dir></dir><file name="form.phtml" hash="93353b0505440a40e58cdbe6eb21c1f3"/><file name="info.phtml" hash="fa71f954c15e6404ef29845910766811"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="cashondelivery.xml" hash="f36ebac7ddc1b545afc1b455f60ab32a"/></dir><dir name="template"><dir name="cashondelivery"><dir name="checkout"><file name="cod.phtml" hash="32f3b650a32f742cbe9e7393c241151c"/></dir><file name="form.phtml" hash="50dc6f9e3b64f86d3e13fa36521c3fd1"/><file name="info.phtml" hash="e4595a0b3161234b6f1998df7b668258"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Phoenix_CashOnDelivery.csv" hash="d03007b6a0ecdd299f4938005b270705"/></dir><dir name="el_GR"><file name="Phoenix_CashOnDelivery.csv" hash="707f2191bf6e6fcd7b416153dc67ff3c"/></dir><dir name="en_US"><file name="Phoenix_CashOnDelivery.csv" hash="cd2ec780c7269dc23eec86bd61405329"/></dir><dir name="pl_PL"><file name="Phoenix_CashOnDelivery.csv" hash="0645f849c401d9ec5a059f8cfaf50518"/></dir></target><target name="mageweb"><dir name="js"><dir name="phoenix"><dir name="cashondelivery"><file name="sales.js" hash="3d499a43715b0226ece4e795aeffc967"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Phoenix_CashOnDelivery.xml" hash="399693025d037e98669e9495b5771a0b"/></dir></target><target name="magecommunity"><dir name="Phoenix"><dir name="CashOnDelivery"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Create"><dir name="Totals"><file name="Cod.php" hash="8f2290b436fdfdab800e7956cb255b6a"/></dir></dir><dir name="Creditmemo"><dir name="Totals"><file name="Cod.php" hash="f197a3ffaa8c34528f0aa4b5fd8ec5ed"/></dir></dir></dir></dir></dir><dir name="Checkout"><file name="Cod.php" hash="e8601cc2dc05103e65a410bead31cb7b"/></dir><dir name="Invoice"><dir name="Totals"><file name="Cod.php" hash="d9f7879bf57764105c44daad2cbc1b84"/></dir></dir><dir name="Order"><dir name="Totals"><file name="Cod.php" hash="84d3b46e2f93dbae5cd9bf8ff53867d2"/></dir></dir><file name="Form.php" hash="c2fa983f39dc54fe6a45671b59701dcb"/><file name="Info.php" hash="0518f170a5c638d28e1c9aeacf18947b"/></dir><dir name="etc"><file name="config.xml" hash="95191a0445d1774f886e30600e57e96c"/><file name="system.xml" hash="f71c54757c22b7f8eb52f603b08d55e6"/></dir><dir name="Helper"><file name="Data.php" hash="1c7d7ec2c8d085a790049d26c14e1c29"/></dir><dir name="Model"><dir name="Creditmemo"><file name="Total.php" hash="13f15ca311fced4c960191e40fdf9349"/></dir><dir name="Invoice"><file name="Tax.php" hash="e472d859623f7de7829aa2579cc54462"/><file name="Total.php" hash="837c8ece233a89abdcd29e01082a7c2c"/></dir><dir name="Quote"><file name="TaxTotal.php" hash="7bde2c7635b7d886ccc269e61733561a"/><file name="Total.php" hash="15446b914cffb03593e7dba388da3106"/></dir><dir name="Sales"><dir name="Pdf"><file name="Cod.php" hash="259719c22d34e0a21c439d2d1b56e787"/></dir></dir><dir name="Source"><file name="AvailableShipmentMethods.php" hash="0f32c1d7cb07d9f4b87d8ad5a33f8fe6"/></dir><file name="CashOnDelivery.php" hash="e0484c1b8ec85574d5db66c1f12ce6b6"/><file name="Observer.php" hash="0b0400de487f5308cb87d5176b16bec8"/></dir><dir name="sql"><dir name="cashondelivery_setup"><file name="mysql4-install-0.2.0.php" hash="d463e6ab6241dbc43486755a49efffa2"/><file name="mysql4-upgrade-0.2.0-0.2.1.php" hash="4dc5e368cc4e123e56a20a3ff66288c1"/><file name="mysql4-upgrade-0.3.2-0.3.3.php" hash="10f0c3c3c4941e3b1dab19270a24d5cf"/><file name="mysql4-upgrade-0.4.6-0.4.7.php" hash="22b07cb1ada2c86de4777f859f73ed85"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>CashOnDelivery</name>
4
+ <version>1.0.8</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Cash on Delivery allows to book additional fee on delivery depending on inland or international delivery.</summary>
10
  <description>Cash on Delivery allows to book additional fee on delivery depending on inland or international delivery.</description>
11
+ <notes>- Refactored the totals handling and added CoD totals to creditmemos and guest orders
12
+ - Fixed compatibility issues</notes>
13
  <authors><author><name>Phoenix Medien</name><user>auto-converted</user><email>info@phoenix-medien.de</email></author></authors>
14
+ <date>2013-06-25</date>
15
+ <time>07:19:06</time>
16
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="phoenix"><file name="cashondelivery.xml" hash="7936dba8cd00a9ff75dd08e55031f191"/></dir></dir><dir name="template"><dir name="phoenix"><dir name="cashondelivery"><dir name="pdf"><file name="info.phtml" hash="a5fd69ee024bc059c6e54352c5152026"/></dir><dir name="sales"><dir name="order"><dir name="create"><dir name="totals"><file name="cod.phtml" hash="f2033e04c6715ecf65ea5850685e7c18"/></dir></dir></dir></dir><file name="form.phtml" hash="bd8ddfc2e94be50f0f224c550c4b0621"/><file name="info.phtml" hash="c99584440162e21c0a880dc807d2450d"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="phoenix"><file name="cashondelivery.xml" hash="5906e4fe3c26f21c14024c103d27bd1b"/></dir></dir><dir name="template"><dir name="phoenix"><dir name="cashondelivery"><dir name="checkout"><file name="cod.phtml" hash="5cdc6a6eb2be9acc36d0b26079870f4c"/></dir><file name="form.phtml" hash="288a6b5da8dc6f7c82cd1676ae098375"/><file name="info.phtml" hash="f9181dd5a6c76a90c52eba486a301803"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Phoenix_CashOnDelivery.csv" hash="3c605e703f0cfc69d0ef8eb46e2e24b5"/></dir><dir name="el_GR"><file name="Phoenix_CashOnDelivery.csv" hash="707f2191bf6e6fcd7b416153dc67ff3c"/></dir><dir name="en_US"><file name="Phoenix_CashOnDelivery.csv" hash="cad6e8c22c900dfbd66edb1561000708"/></dir><dir name="pl_PL"><file name="Phoenix_CashOnDelivery.csv" hash="0645f849c401d9ec5a059f8cfaf50518"/></dir></target><target name="mageweb"><dir name="js"><dir name="phoenix"><dir name="cashondelivery"><file name="sales.js" hash="1c6fabcc6e9892018f5bde1686e12d43"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Phoenix_CashOnDelivery.xml" hash="ad4b4586c1f1eeb5084cf3cf89027731"/></dir></target><target name="magecommunity"><dir name="Phoenix"><dir name="CashOnDelivery"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Creditmemo"><dir name="Create"><file name="Totals.php" hash="34bebc48d5938c2750163207302007f5"/></dir></dir><dir name="Order"><dir name="Create"><dir name="Totals"><file name="Cod.php" hash="74a95dc79490ee3bc00bd5670a7b72d0"/></dir></dir></dir></dir></dir><dir name="Checkout"><file name="Cod.php" hash="b3127330db12b59087b8bfd095ef51e1"/></dir><dir name="Totals"><file name="Abstract.php" hash="3db4182327d67f7436a2a1cc4677871e"/><file name="Creditmemo.php" hash="ff94cd8294074061a8d80bc35f971227"/><file name="Invoice.php" hash="ed871dbf191549bc437e5cc5bd07dc73"/><file name="Order.php" hash="8f7fa52316f09466cc3c7fd11d43c6b0"/></dir><file name="Form.php" hash="755509cfc76b66d1d2a87e6cfa813fbf"/><file name="Info.php" hash="11fda568cd501caee195cc794603fb69"/></dir><dir name="etc"><file name="config.xml" hash="db6f17578bb21f432c1015a0a43da51d"/><file name="system.xml" hash="c538bd1632c9e7d4255b7a9c82baf5f4"/></dir><dir name="Helper"><file name="Data.php" hash="5e740e3abdba5276a87b30054edc66de"/></dir><dir name="Model"><dir name="Sales"><dir name="Creditmemo"><file name="Tax.php" hash="473307710ef6972cf6d958baeb4834f3"/><file name="Total.php" hash="dda5479486dfbb3acd251f4eeda3cb1e"/></dir><dir name="Invoice"><file name="Tax.php" hash="3b3de1583e8f64ce31d5e4602c77d211"/><file name="Total.php" hash="3a445db6d2a94c5763488cdb939bf18c"/></dir><dir name="Pdf"><file name="Cod.php" hash="e29b34db00d5efba9e376b9b1cb510df"/></dir><dir name="Quote"><file name="TaxTotal.php" hash="b823efb80b92db3b2276d97a020fd8f1"/><file name="Total.php" hash="36ba1cdfe3b5c04bc490760ca44dc458"/></dir></dir><dir name="Source"><file name="AvailableShipmentMethods.php" hash="5bc2f1480e8303b8688971bbdf3d7d66"/><file name="CostType.php" hash="338b23e05f364da7a3cd503b63cfc7a4"/></dir><file name="CashOnDelivery.php" hash="c659b464ef794f5d46a2d515a5be87b6"/><file name="Observer.php" hash="974b93bc2f31bd7ce0d8c7cf8453a491"/></dir><dir name="sql"><dir name="cashondelivery_setup"><file name="mysql4-install-0.2.0.php" hash="a3a489e1c56e2b04daa169645b15aaa5"/><file name="mysql4-upgrade-0.2.0-0.2.1.php" hash="4005ebd320ad650203ff86eddfa256e5"/><file name="mysql4-upgrade-0.3.2-0.3.3.php" hash="1c1ff6fd0c35d8ba86f2cab4cfce51a4"/><file name="mysql4-upgrade-0.4.6-0.4.7.php" hash="ce70a8e204e7d4f6e9018c23e458c1eb"/><file name="mysql4-upgrade-1.0.7-1.0.8.php" hash="2d6947f7b1f32222cc051bd98b70c0e3"/></dir></dir></dir></dir></target></contents>
17
  <compatible/>
18
  <dependencies/>
19
  </package>