CashOnDelivery - Version 1.0.6

Version Notes

- code beautification

Download this release

Release Info

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


Code changes from version 1.0.5 to 1.0.6

app/code/community/Phoenix/CashOnDelivery/Block/Adminhtml/Sales/Order/Create/Totals/Cod.php CHANGED
@@ -23,7 +23,8 @@
23
*
24
*/
25
26
- class Phoenix_CashOnDelivery_Block_Adminhtml_Sales_Order_Create_Totals_Cod extends Mage_Adminhtml_Block_Sales_Order_Create_Totals_Default
27
{
28
protected $_template = 'cashondelivery/sales/order/create/totals/cod.phtml';
29
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
app/code/community/Phoenix/CashOnDelivery/Block/Adminhtml/Sales/Order/Creditmemo/Totals/Cod.php CHANGED
@@ -21,13 +21,13 @@ class Phoenix_CashOnDelivery_Block_Adminhtml_Sales_Order_Creditmemo_Totals_Cod e
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;
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;
app/code/community/Phoenix/CashOnDelivery/Block/Checkout/Cod.php CHANGED
@@ -55,7 +55,7 @@ class Phoenix_CashOnDelivery_Block_Checkout_Cod extends Mage_Checkout_Block_Tota
55
public function getCodFeeIncludeTax()
56
{
57
$codFeeInclTax = 0;
58
- foreach ($this->getTotal()->getAddress()->getQuote()->getAllShippingAddresses() as $address){
59
$codFeeInclTax += $address->getCodFee() + $address->getCodTaxAmount();
60
}
61
return $codFeeInclTax;
@@ -69,7 +69,7 @@ class Phoenix_CashOnDelivery_Block_Checkout_Cod extends Mage_Checkout_Block_Tota
69
public function getCodFeeExcludeTax()
70
{
71
$codFeeExclTax = 0;
72
- foreach ($this->getTotal()->getAddress()->getQuote()->getAllShippingAddresses() as $address){
73
$codFeeExclTax += $address->getCodFee();
74
}
75
return $codFeeExclTax;
55
public function getCodFeeIncludeTax()
56
{
57
$codFeeInclTax = 0;
58
+ foreach ($this->getTotal()->getAddress()->getQuote()->getAllShippingAddresses() as $address) {
59
$codFeeInclTax += $address->getCodFee() + $address->getCodTaxAmount();
60
}
61
return $codFeeInclTax;
69
public function getCodFeeExcludeTax()
70
{
71
$codFeeExclTax = 0;
72
+ foreach ($this->getTotal()->getAddress()->getQuote()->getAllShippingAddresses() as $address) {
73
$codFeeExclTax += $address->getCodFee();
74
}
75
return $codFeeExclTax;
app/code/community/Phoenix/CashOnDelivery/Block/Form.php CHANGED
@@ -24,11 +24,13 @@ class Phoenix_CashOnDelivery_Block_Form extends Mage_Payment_Block_Form
24
$this->setTemplate('cashondelivery/form.phtml');
25
}
26
27
- public function getQuote(){
28
return $this->getMethod()->getInfoInstance()->getQuote();
29
}
30
31
- public function getShippingAddress(){
32
return $this->getQuote()->getShippingAddress();
33
}
34
24
$this->setTemplate('cashondelivery/form.phtml');
25
}
26
27
+ public function getQuote()
28
+ {
29
return $this->getMethod()->getInfoInstance()->getQuote();
30
}
31
32
+ public function getShippingAddress()
33
+ {
34
return $this->getQuote()->getShippingAddress();
35
}
36
app/code/community/Phoenix/CashOnDelivery/Block/Info.php CHANGED
@@ -33,50 +33,53 @@ class Phoenix_CashOnDelivery_Block_Info extends Mage_Payment_Block_Info
33
return $this->toHtml();
34
}
35
36
- public function getRawCodFee(){
37
- if ($_dataObject = $this->_getDataObject()){
38
return $_dataObject->getCodFee();
39
}
40
return null;
41
}
42
43
- public function getCodFeeExclTax(){
44
- if ($_dataObject = $this->_getDataObject()){
45
- $_extra_fee_excl = $_dataObject->getCodFee() ?
46
- $this->_getPriceModel()->formatPrice($_dataObject->getCodFee()) : null;
47
- return $_extra_fee_excl;
48
}
49
return null;
50
}
51
52
- public function getCodFeeInclTax(){
53
- if ($_dataObject = $this->_getDataObject()){
54
- $_extra_fee_incl = $_dataObject->getCodFee() ?
55
- $this->_getPriceModel()->formatPrice($_dataObject->getCodFee()+$_dataObject->getCodTaxAmount()) : null;
56
- return $_extra_fee_incl;
57
}
58
return null;
59
}
60
61
- protected function _getDataObject(){
62
- if (!isset($this->_dataObject)){
63
if ($this->_dataObject = $this->getInfo()->getQuote()) {
64
- }elseif($this->_dataObject = $this->getInfo()->getOrder()){
65
}
66
}
67
return $this->_dataObject;
68
}
69
70
- protected function _getPriceModel(){
71
- if (!isset($this->_priceModel)){
72
- if($this->getInfo()->getQuote()){
73
$this->_priceModel = $this->getInfo()->getQuote()->getStore();
74
-
75
- }elseif($this->getInfo()->getOrder()){
76
$this->_priceModel = $this->getInfo()->getOrder();
77
}
78
}
79
return $this->_priceModel;
80
}
81
-
82
- }
33
return $this->toHtml();
34
}
35
36
+ public function getRawCodFee()
37
+ {
38
+ if ($_dataObject = $this->_getDataObject()) {
39
return $_dataObject->getCodFee();
40
}
41
return null;
42
}
43
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;
52
}
53
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;
62
}
63
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
}
73
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
}
85
+ }
app/code/community/Phoenix/CashOnDelivery/Block/Invoice/Totals/Cod.php CHANGED
@@ -22,14 +22,14 @@ class Phoenix_CashOnDelivery_Block_Invoice_Totals_Cod extends Mage_Core_Block_Ab
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();
@@ -38,14 +38,14 @@ class Phoenix_CashOnDelivery_Block_Invoice_Totals_Cod extends Mage_Core_Block_Ab
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
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();
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
app/code/community/Phoenix/CashOnDelivery/Block/Order/Totals/Cod.php CHANGED
@@ -18,18 +18,18 @@
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();
@@ -38,18 +38,17 @@ class Phoenix_CashOnDelivery_Block_Order_Totals_Cod extends Mage_Core_Block_Abst
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
-
55
}
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();
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/Helper/Data.php CHANGED
@@ -28,15 +28,20 @@ class Phoenix_CashOnDelivery_Helper_Data extends Mage_Core_Helper_Data
28
{
29
$storeId = Mage::app()->getStore($store)->getId();
30
if (!isset($this->_codPriceIncludesTax[$storeId])) {
31
- $this->_codPriceIncludesTax[$storeId] =
32
- (int)Mage::getStoreConfig(Phoenix_CashOnDelivery_Model_Quote_TaxTotal::CONFIG_XML_PATH_COD_INCLUDES_TAX, $store);
33
}
34
return $this->_codPriceIncludesTax[$storeId];
35
}
36
37
public function getCodTaxClass($store)
38
{
39
- return (int)Mage::getStoreConfig(Phoenix_CashOnDelivery_Model_Quote_TaxTotal::CONFIG_XML_PATH_COD_TAX_CLASS, $store);
40
}
41
42
public function getCodPrice($price, $includingTax = null, $shippingAddress = null, $ctc = null, $store = null)
@@ -59,8 +64,7 @@ class Phoenix_CashOnDelivery_Helper_Data extends Mage_Core_Helper_Data
59
60
if ($this->codPriceIncludesTax($store)) {
61
return $includingTax ? $price : $price - $tax;
62
- }
63
- else {
64
return $includingTax ? $price + $tax : $price;
65
}
66
}
@@ -69,8 +73,10 @@ class Phoenix_CashOnDelivery_Helper_Data extends Mage_Core_Helper_Data
69
{
70
$storeId = Mage::app()->getStore($store)->getId();
71
if (!isset($this->_shippingPriceDisplayType[$storeId])) {
72
- $this->_shippingPriceDisplayType[$storeId] =
73
- (int)Mage::getStoreConfig(Phoenix_CashOnDelivery_Model_Quote_TaxTotal::CONFIG_XML_PATH_DISPLAY_COD, $store);
74
}
75
return $this->_shippingPriceDisplayType[$storeId];
76
}
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)
64
65
if ($this->codPriceIncludesTax($store)) {
66
return $includingTax ? $price : $price - $tax;
67
+ } else {
68
return $includingTax ? $price + $tax : $price;
69
}
70
}
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
}
app/code/community/Phoenix/CashOnDelivery/Model/CashOnDelivery.php CHANGED
@@ -65,28 +65,43 @@ class Phoenix_CashOnDelivery_Model_CashOnDelivery extends Mage_Payment_Model_Met
65
}
66
}
67
68
- public function getAddressCodFee(Mage_Customer_Model_Address_Abstract $address, $value = null, $alreadyExclTax = false)
69
{
70
if (is_null($value)) {
71
$value = $this->getAddressCosts($address);
72
}
73
if (Mage::helper('cashondelivery')->codPriceIncludesTax()) {
74
if (!$alreadyExclTax) {
75
- $value = Mage::helper('cashondelivery')->getCodPrice($value, false, $address, $address->getQuote()->getCustomerTaxClassId());
76
}
77
}
78
return $value;
79
}
80
81
- public function getAddressCodTaxAmount(Mage_Customer_Model_Address_Abstract $address, $value = null, $alreadyExclTax = false)
82
{
83
if (is_null($value)) {
84
$value = $this->getAddressCosts($address);
85
}
86
if (Mage::helper('cashondelivery')->codPriceIncludesTax()) {
87
- $includingTax = Mage::helper('cashondelivery')->getCodPrice($value, true, $address, $address->getQuote()->getCustomerTaxClassId());
88
if (!$alreadyExclTax) {
89
- $value = Mage::helper('cashondelivery')->getCodPrice($value, false, $address, $address->getQuote()->getCustomerTaxClassId());
90
}
91
return $includingTax - $value;
92
}
@@ -104,18 +119,19 @@ class Phoenix_CashOnDelivery_Model_CashOnDelivery extends Mage_Payment_Model_Met
104
return false;
105
}
106
if (!is_null($quote)) {
107
- if($this->getConfigData('shippingallowspecific', $quote->getStoreId()) == 1) {
108
$country = $quote->getShippingAddress()->getCountry();
109
- $availableCountries = explode(',', $this->getConfigData('shippingspecificcountry', $quote->getStoreId()));
110
- if(!in_array($country, $availableCountries)){
111
return false;
112
}
113
114
}
115
if ($this->getConfigData('disallowspecificshippingmethods', $quote->getStoreId()) == 1) {
116
- $shippingMethodCode = explode('_',$quote->getShippingAddress()->getShippingMethod());
117
$shippingMethodCode = $shippingMethodCode[0];
118
- if (in_array($shippingMethodCode, explode(',', $this->getConfigData('disallowedshippingmethods', $quote->getStoreId())))) {
119
return false;
120
}
121
}
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
}
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
}
137
}
app/code/community/Phoenix/CashOnDelivery/Model/Creditmemo/Total.php CHANGED
@@ -25,7 +25,7 @@ class Phoenix_CashOnDelivery_Model_Creditmemo_Total extends Mage_Sales_Model_Ord
25
26
$order = $cm->getOrder();
27
28
- if ($order->getPayment()->getMethodInstance()->getCode() != 'cashondelivery'){
29
return $this;
30
}
31
@@ -38,16 +38,16 @@ class Phoenix_CashOnDelivery_Model_Creditmemo_Total extends Mage_Sales_Model_Ord
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
25
26
$order = $cm->getOrder();
27
28
+ if ($order->getPayment()->getMethodInstance()->getCode() != 'cashondelivery') {
29
return $this;
30
}
31
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
app/code/community/Phoenix/CashOnDelivery/Model/Invoice/Total.php CHANGED
@@ -24,11 +24,11 @@ class Phoenix_CashOnDelivery_Model_Invoice_Total extends Mage_Sales_Model_Order_
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
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
app/code/community/Phoenix/CashOnDelivery/Model/Observer.php CHANGED
@@ -17,7 +17,7 @@
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
@@ -79,7 +79,8 @@ class Phoenix_CashOnDelivery_Model_Observer extends Mage_Core_Model_Abstract
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' || !$action->getRequest()->getParam('json')) {
83
return;
84
}
85
$layout = $observer->getLayout();
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
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();
app/code/community/Phoenix/CashOnDelivery/Model/Quote/TaxTotal.php CHANGED
@@ -18,18 +18,16 @@
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
-
30
- $paymentMethod = Mage::app()->getFrontController()->getRequest()->getParam('payment');
31
- $paymentMethod = Mage::app()->getStore()->isAdmin() && isset($paymentMethod['method']) ? $paymentMethod['method'] : null;
32
- if ($paymentMethod != 'cashondelivery' && (!count($address->getQuote()->getPaymentsCollection()) || !$address->getQuote()->getPayment()->hasMethodInstance())){
33
return $this;
34
}
35
@@ -50,7 +48,12 @@ class Phoenix_CashOnDelivery_Model_Quote_TaxTotal extends Mage_Sales_Model_Quote
50
51
$taxCalculationModel = Mage::getSingleton('tax/calculation');
52
/* @var $taxCalculationModel Mage_Tax_Model_Calculation */
53
- $request = $taxCalculationModel->getRateRequest($address, $address->getQuote()->getBillingAddress(), $custTaxClassId, $store);
54
$codTaxClass = Mage::helper('cashondelivery')->getCodTaxClass($store);
55
56
$codTax = 0;
@@ -99,20 +102,24 @@ class Phoenix_CashOnDelivery_Model_Quote_TaxTotal extends Mage_Sales_Model_Quote
99
/**
100
* Modify subtotal
101
*/
102
- if (Mage::getSingleton('tax/config')->displayCartSubtotalBoth($store) || Mage::getSingleton('tax/config')->displayCartSubtotalInclTax($store)) {
103
if ($address->getSubtotalInclTax() > 0) {
104
$subtotalInclTax = $address->getSubtotalInclTax();
105
} else {
106
- $subtotalInclTax = $address->getSubtotal()+$address->getTaxAmount()-$address->getShippingTaxAmount()-$address->getCodTaxAmount();
107
}
108
109
- $address->addTotal(array(
110
- 'code' => 'subtotal',
111
- 'title' => Mage::helper('sales')->__('Subtotal'),
112
- 'value' => $subtotalInclTax,
113
- 'value_incl_tax' => $subtotalInclTax,
114
- 'value_excl_tax' => $address->getSubtotal(),
115
- ));
116
}
117
return $this;
118
}
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();
30
+ if ($collection->count() <= 0 || $address->getQuote()->getPayment()->getMethod() == null) {
31
return $this;
32
}
33
48
49
$taxCalculationModel = Mage::getSingleton('tax/calculation');
50
/* @var $taxCalculationModel Mage_Tax_Model_Calculation */
51
+ $request = $taxCalculationModel->getRateRequest(
52
+ $address,
53
+ $address->getQuote()->getBillingAddress(),
54
+ $custTaxClassId,
55
+ $store
56
+ );
57
$codTaxClass = Mage::helper('cashondelivery')->getCodTaxClass($store);
58
59
$codTax = 0;
102
/**
103
* Modify subtotal
104
*/
105
+ if (Mage::getSingleton('tax/config')->displayCartSubtotalBoth($store) ||
106
+ Mage::getSingleton('tax/config')->displayCartSubtotalInclTax($store)) {
107
if ($address->getSubtotalInclTax() > 0) {
108
$subtotalInclTax = $address->getSubtotalInclTax();
109
} else {
110
+ $subtotalInclTax = $address->getSubtotal()+ $address->getTaxAmount() -
111
+ $address->getShippingTaxAmount() - $address->getCodTaxAmount();
112
}
113
114
+ $address->addTotal(
115
+ array(
116
+ 'code' => 'subtotal',
117
+ 'title' => Mage::helper('sales')->__('Subtotal'),
118
+ 'value' => $subtotalInclTax,
119
+ 'value_incl_tax' => $subtotalInclTax,
120
+ 'value_excl_tax' => $address->getSubtotal()
121
+ )
122
+ );
123
}
124
return $this;
125
}
app/code/community/Phoenix/CashOnDelivery/Model/Quote/Total.php CHANGED
@@ -26,13 +26,12 @@ class Phoenix_CashOnDelivery_Model_Quote_Total extends Mage_Sales_Model_Quote_Ad
26
$address->setCodFee(0);
27
$address->setCodTaxAmount(0);
28
$address->setBaseCodTaxAmount(0);
29
-
30
- $paymentMethod = Mage::app()->getFrontController()->getRequest()->getParam('payment');
31
- $paymentMethod = Mage::app()->getStore()->isAdmin() && isset($paymentMethod['method']) ? $paymentMethod['method'] : null;
32
- if ($paymentMethod != 'cashondelivery' && (!count($address->getQuote()->getPaymentsCollection()) || !$address->getQuote()->getPayment()->hasMethodInstance())){
33
return $this;
34
}
35
-
36
$paymentMethod = $address->getQuote()->getPayment()->getMethodInstance();
37
38
if ($paymentMethod->getCode() != 'cashondelivery') {
@@ -79,11 +78,13 @@ class Phoenix_CashOnDelivery_Model_Quote_Total extends Mage_Sales_Model_Quote_Ad
79
$amount = $address->getCodFee();
80
if ($amount!=0) {
81
$quote = $address->getQuote();
82
- $address->addTotal(array(
83
- 'code' => $this->getCode(),
84
- 'title' => Mage::helper('cashondelivery')->__('Cash on Delivery fee'),
85
- 'value' => $amount,
86
- ));
87
}
88
return $this;
89
}
26
$address->setCodFee(0);
27
$address->setCodTaxAmount(0);
28
$address->setBaseCodTaxAmount(0);
29
+
30
+ $collection = $address->getQuote()->getPaymentsCollection();
31
+ if ($collection->count() <= 0 || $address->getQuote()->getPayment()->getMethod() == null) {
32
return $this;
33
}
34
+
35
$paymentMethod = $address->getQuote()->getPayment()->getMethodInstance();
36
37
if ($paymentMethod->getCode() != 'cashondelivery') {
78
$amount = $address->getCodFee();
79
if ($amount!=0) {
80
$quote = $address->getQuote();
81
+ $address->addTotal(
82
+ array(
83
+ 'code' => $this->getCode(),
84
+ 'title' => Mage::helper('cashondelivery')->__('Cash on Delivery fee'),
85
+ 'value' => $amount
86
+ )
87
+ );
88
}
89
return $this;
90
}
app/code/community/Phoenix/CashOnDelivery/Model/Source/AvailableShipmentMethods.php CHANGED
@@ -24,7 +24,7 @@ class Phoenix_CashOnDelivery_Model_Source_AvailableShipmentMethods
24
$options = array();
25
26
foreach (Mage::app()->getStore()->getConfig('carriers') as $code => $carrier) {
27
- if ($carrier['active'] && isset($carrier['title'])){
28
$options[] = array(
29
'value' => $code,
30
'label' => $carrier['title']
24
$options = array();
25
26
foreach (Mage::app()->getStore()->getConfig('carriers') as $code => $carrier) {
27
+ if ($carrier['active'] && isset($carrier['title'])) {
28
$options[] = array(
29
'value' => $code,
30
'label' => $carrier['title']
app/code/community/Phoenix/CashOnDelivery/etc/config.xml CHANGED
@@ -23,7 +23,7 @@
23
<config>
24
<modules>
25
<Phoenix_CashOnDelivery>
26
- <version>1.0.5</version>
27
</Phoenix_CashOnDelivery>
28
</modules>
29
23
<config>
24
<modules>
25
<Phoenix_CashOnDelivery>
26
+ <version>1.0.6</version>
27
</Phoenix_CashOnDelivery>
28
</modules>
29
package.xml CHANGED
@@ -1,19 +1,18 @@
1
<?xml version="1.0"?>
2
<package>
3
<name>CashOnDelivery</name>
4
- <version>1.0.5</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>- added min/max order amount config option
12
- - fixed some translations oddities</notes>
13
<authors><author><name>Phoenix Medien</name><user>auto-converted</user><email>info@phoenix-medien.de</email></author></authors>
14
- <date>2012-04-30</date>
15
- <time>13:12:25</time>
16
- <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="57b6ac50a1ab854e830c59f549418728"/></dir></dir><dir name="Creditmemo"><dir name="Totals"><file name="Cod.php" hash="519aadcd4036d02d46a42d38e2b20f24"/></dir></dir></dir></dir></dir><dir name="Checkout"><file name="Cod.php" hash="f086c179ff7e57fa8b90e0ddae279901"/></dir><dir name="Invoice"><dir name="Totals"><file name="Cod.php" hash="7c09dc9969f4b8a775f45978619a4789"/></dir></dir><dir name="Order"><dir name="Totals"><file name="Cod.php" hash="8682a4dc107a8c9c2ec82f521def3e3d"/></dir></dir><file name="Form.php" hash="98db85c8cd1c61518e916ae8b009d4b4"/><file name="Info.php" hash="2e179e95f534db2a2ba4474d8ff36710"/></dir><dir name="etc"><file name="config.xml" hash="d0458a1e3e03aea011da162e79ef3b9f"/><file name="system.xml" hash="f71c54757c22b7f8eb52f603b08d55e6"/></dir><dir name="Helper"><file name="Data.php" hash="2de69fb72472a0b9a0fe2452ad67abfa"/></dir><dir name="Model"><dir name="Creditmemo"><file name="Total.php" hash="1d1606f8730d37136e4f5824d7561986"/></dir><dir name="Invoice"><file name="Tax.php" hash="e472d859623f7de7829aa2579cc54462"/><file name="Total.php" hash="3de53861c195c311615537eadcefd5dd"/></dir><dir name="Quote"><file name="TaxTotal.php" hash="b16472223336a13d6a65208a24ad108e"/><file name="Total.php" hash="207f481153d00451ccaf9d200d1cb056"/></dir><dir name="Sales"><dir name="Pdf"><file name="Cod.php" hash="259719c22d34e0a21c439d2d1b56e787"/></dir></dir><dir name="Source"><file name="AvailableShipmentMethods.php" hash="2959c8ac25cd736b4c3c12eb67ed39d2"/></dir><file name="CashOnDelivery.php" hash="d7daa0d56648ce3c74c79c98ab63f17c"/><file name="Observer.php" hash="8177fc07f0cc41dfb7862275dba22ae5"/></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>
17
<compatible/>
18
<dependencies/>
19
</package>
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>