Version Notes
Cash on Delivery allows to book additional fee on delivery depending on india or international delivery
Download this release
Release Info
Developer | RameshRamasamy |
Extension | hclcashondelivery6 |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Hcl/CashOnDelivery/Block/Adminhtml/Sales/Order/Create/Totals/Cod.php +91 -0
- app/code/community/Hcl/CashOnDelivery/Block/Adminhtml/Sales/Order/Creditmemo/Totals/Cod.php +36 -0
- app/code/community/Hcl/CashOnDelivery/Block/Checkout/Cod.php +98 -0
- app/code/community/Hcl/CashOnDelivery/Block/Form.php +40 -0
- app/code/community/Hcl/CashOnDelivery/Block/Info.php +82 -0
- app/code/community/Hcl/CashOnDelivery/Block/Invoice/Totals/Cod.php +55 -0
- app/code/community/Hcl/CashOnDelivery/Block/Order/Totals/Cod.php +55 -0
- app/code/community/Hcl/CashOnDelivery/Helper/Data.php +82 -0
- app/code/community/Hcl/CashOnDelivery/Model/CashOnDelivery.php +135 -0
- app/code/community/Hcl/CashOnDelivery/Model/Creditmemo/Total.php +68 -0
- app/code/community/Hcl/CashOnDelivery/Model/Invoice/Tax.php +71 -0
- app/code/community/Hcl/CashOnDelivery/Model/Invoice/Total.php +70 -0
- app/code/community/Hcl/CashOnDelivery/Model/Observer.php +97 -0
- app/code/community/Hcl/CashOnDelivery/Model/Quote/TaxTotal.php +120 -0
- app/code/community/Hcl/CashOnDelivery/Model/Quote/Total.php +90 -0
- app/code/community/Hcl/CashOnDelivery/Model/Sales/Pdf/Cod.php +78 -0
- app/code/community/Hcl/CashOnDelivery/Model/Source/AvailableShipmentMethods.php +44 -0
- app/code/community/Hcl/CashOnDelivery/etc/config.xml +198 -0
- app/code/community/Hcl/CashOnDelivery/etc/system.xml +187 -0
- app/code/community/Hcl/CashOnDelivery/sql/cashondelivery_setup/mysql4-install-0.2.0.php +57 -0
- app/code/community/Hcl/CashOnDelivery/sql/cashondelivery_setup/mysql4-upgrade-0.2.0-0.2.1.php +57 -0
- app/code/community/Hcl/CashOnDelivery/sql/cashondelivery_setup/mysql4-upgrade-0.3.2-0.3.3.php +36 -0
- app/code/community/Hcl/CashOnDelivery/sql/cashondelivery_setup/mysql4-upgrade-0.4.6-0.4.7.php +57 -0
- app/design/adminhtml/default/default/layout/cashondelivery.xml +98 -0
- app/etc/modules/Hcl_CashOnDelivery.xml +33 -0
- package.xml +20 -0
app/code/community/Hcl/CashOnDelivery/Block/Adminhtml/Sales/Order/Create/Totals/Cod.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Hcl
|
16 |
+
* @package Hcl_CashOnDelivery
|
17 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
18 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* COD fee Total Row Renderer
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Hcl_CashOnDelivery_Block_Adminhtml_Sales_Order_Create_Totals_Cod 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 |
+
*/
|
67 |
+
public function getCodFeeExcludeTax()
|
68 |
+
{
|
69 |
+
return $this->getTotal()->getAddress()->getCodFee();
|
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 |
+
}
|
app/code/community/Hcl/CashOnDelivery/Block/Adminhtml/Sales/Order/Creditmemo/Totals/Cod.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Hcl
|
12 |
+
* @package Hcl_CashOnDelivery
|
13 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
14 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
|
18 |
+
class Hcl_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/Hcl/CashOnDelivery/Block/Checkout/Cod.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Hcl
|
16 |
+
* @package Hcl_CashOnDelivery
|
17 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
18 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* COD fee Total Row Renderer
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Hcl_CashOnDelivery_Block_Checkout_Cod extends Mage_Checkout_Block_Total_Default
|
28 |
+
{
|
29 |
+
protected $_template = 'cashondelivery/checkout/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 |
+
$codFeeInclTax = 0;
|
59 |
+
foreach ($this->getTotal()->getAddress()->getQuote()->getAllShippingAddresses() as $address){
|
60 |
+
$codFeeInclTax += $address->getCodFee() + $address->getCodTaxAmount();
|
61 |
+
}
|
62 |
+
return $codFeeInclTax;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Get COD fee exclude tax
|
67 |
+
*
|
68 |
+
* @return float
|
69 |
+
*/
|
70 |
+
public function getCodFeeExcludeTax()
|
71 |
+
{
|
72 |
+
$codFeeExclTax = 0;
|
73 |
+
foreach ($this->getTotal()->getAddress()->getQuote()->getAllShippingAddresses() as $address){
|
74 |
+
$codFeeExclTax += $address->getCodFee();
|
75 |
+
}
|
76 |
+
return $codFeeExclTax;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Get label for COD fee include tax
|
81 |
+
*
|
82 |
+
* @return float
|
83 |
+
*/
|
84 |
+
public function getIncludeTaxLabel()
|
85 |
+
{
|
86 |
+
return $this->helper('cashondelivery')->__('Cash on Delivery fee (Incl.Tax)');
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Get label for COD fee exclude tax
|
91 |
+
*
|
92 |
+
* @return float
|
93 |
+
*/
|
94 |
+
public function getExcludeTaxLabel()
|
95 |
+
{
|
96 |
+
return $this->helper('cashondelivery')->__('Cash on Delivery fee (Excl.Tax)');
|
97 |
+
}
|
98 |
+
}
|
app/code/community/Hcl/CashOnDelivery/Block/Form.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Hcl
|
12 |
+
* @package Hcl_CashOnDelivery
|
13 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
14 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
|
18 |
+
class Hcl_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 |
+
return $this->getMethod()->getInfoInstance()->getQuote();
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getShippingAddress(){
|
32 |
+
return $this->getQuote()->getShippingAddress();
|
33 |
+
}
|
34 |
+
|
35 |
+
public function convertPrice($price, $format=false, $includeContainer = true)
|
36 |
+
{
|
37 |
+
return $this->getQuote()->getStore()->convertPrice($price, $format, $includeContainer);
|
38 |
+
}
|
39 |
+
|
40 |
+
}
|
app/code/community/Hcl/CashOnDelivery/Block/Info.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Hcl
|
12 |
+
* @package Hcl_CashOnDelivery
|
13 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
14 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
|
18 |
+
class Hcl_CashOnDelivery_Block_Info extends Mage_Payment_Block_Info
|
19 |
+
{
|
20 |
+
|
21 |
+
protected $_dataObject;
|
22 |
+
protected $_priceModel;
|
23 |
+
|
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 |
+
|
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 |
+
}
|
app/code/community/Hcl/CashOnDelivery/Block/Invoice/Totals/Cod.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Hcl
|
12 |
+
* @package Hcl_CashOnDelivery
|
13 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
14 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
|
18 |
+
class Hcl_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/Hcl/CashOnDelivery/Block/Order/Totals/Cod.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Hcl
|
12 |
+
* @package Hcl_CashOnDelivery
|
13 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
14 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
|
18 |
+
class Hcl_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 |
+
|
55 |
+
}
|
app/code/community/Hcl/CashOnDelivery/Helper/Data.php
ADDED
@@ -0,0 +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 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 Hcl
|
17 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
18 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
class Hcl_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] =
|
32 |
+
(int)Mage::getStoreConfig(Hcl_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(Hcl_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){
|
43 |
+
$pseudoProduct = new Varien_Object();
|
44 |
+
$pseudoProduct->setTaxClassId($this->getCodTaxClass($store));
|
45 |
+
|
46 |
+
$billingAddress = false;
|
47 |
+
if ($shippingAddress && $shippingAddress->getQuote() && $shippingAddress->getQuote()->getBillingAddress()) {
|
48 |
+
$billingAddress = $shippingAddress->getQuote()->getBillingAddress();
|
49 |
+
}
|
50 |
+
|
51 |
+
return Mage::helper('tax')->getPrice($pseudoProduct, $price, $includingTax, $shippingAddress, $billingAddress, $ctc, $store, $this->codPriceIncludesTax($store));
|
52 |
+
}
|
53 |
+
|
54 |
+
public function getCodFeeDisplayType($store = null)
|
55 |
+
{
|
56 |
+
|
57 |
+
$storeId = Mage::app()->getStore($store)->getId();
|
58 |
+
if (!isset($this->_shippingPriceDisplayType[$storeId])) {
|
59 |
+
$this->_shippingPriceDisplayType[$storeId] =
|
60 |
+
(int)Mage::getStoreConfig(Hcl_CashOnDelivery_Model_Quote_TaxTotal::CONFIG_XML_PATH_DISPLAY_COD, $store);
|
61 |
+
}
|
62 |
+
return $this->_shippingPriceDisplayType[$storeId];
|
63 |
+
}
|
64 |
+
|
65 |
+
public function displayCodFeeIncludingTax()
|
66 |
+
{
|
67 |
+
return $this->getCodFeeDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX;
|
68 |
+
}
|
69 |
+
|
70 |
+
public function displayCodFeeExcludingTax()
|
71 |
+
{
|
72 |
+
return $this->getCodFeeDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX;
|
73 |
+
}
|
74 |
+
|
75 |
+
public function displayCodBothPrices()
|
76 |
+
{
|
77 |
+
return $this->getCodFeeDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH;
|
78 |
+
}
|
79 |
+
|
80 |
+
}
|
81 |
+
|
82 |
+
?>
|
app/code/community/Hcl/CashOnDelivery/Model/CashOnDelivery.php
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* 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 Hcl
|
22 |
+
* @package Hcl_CashOnDelivery
|
23 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
24 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
class Hcl_CashOnDelivery_Model_CashOnDelivery extends Mage_Payment_Model_Method_Abstract
|
29 |
+
{
|
30 |
+
|
31 |
+
/**
|
32 |
+
* unique internal payment method identifier
|
33 |
+
*
|
34 |
+
* @var string [a-z0-9_]
|
35 |
+
*/
|
36 |
+
protected $_code = 'cashondelivery';
|
37 |
+
protected $_canUseForMultishipping = false;
|
38 |
+
|
39 |
+
protected $_formBlockType = 'cashondelivery/form';
|
40 |
+
protected $_infoBlockType = 'cashondelivery/info';
|
41 |
+
|
42 |
+
public function getCODTitle()
|
43 |
+
{
|
44 |
+
return $this->getConfigData('title');
|
45 |
+
}
|
46 |
+
|
47 |
+
public function getInlandCosts()
|
48 |
+
{
|
49 |
+
return floatval($this->getConfigData('inlandcosts'));
|
50 |
+
}
|
51 |
+
|
52 |
+
public function getForeignCountryCosts()
|
53 |
+
{
|
54 |
+
return floatval($this->getConfigData('foreigncountrycosts'));
|
55 |
+
}
|
56 |
+
|
57 |
+
public function getCustomText()
|
58 |
+
{
|
59 |
+
return $this->getConfigData('customtext');
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Returns COD fee for certain address
|
64 |
+
*
|
65 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
66 |
+
* @return decimal
|
67 |
+
*
|
68 |
+
*/
|
69 |
+
|
70 |
+
public function getAddressCosts(Mage_Customer_Model_Address_Abstract $address){
|
71 |
+
if ($address->getCountry() == Mage::getStoreConfig('shipping/origin/country_id')) {
|
72 |
+
return $this->getInlandCosts();
|
73 |
+
} else {
|
74 |
+
return $this->getForeignCountryCosts();
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
public function getAddressCodFee(Mage_Customer_Model_Address_Abstract $address, $value = null, $alreadyExclTax = false)
|
79 |
+
{
|
80 |
+
if (is_null($value)){
|
81 |
+
$value = $this->getAddressCosts($address);
|
82 |
+
}
|
83 |
+
if (Mage::helper('cashondelivery')->codPriceIncludesTax()) {
|
84 |
+
if (!$alreadyExclTax) {
|
85 |
+
$value = Mage::helper('cashondelivery')->getCodPrice($value, false, $address, $address->getQuote()->getCustomerTaxClassId());
|
86 |
+
}
|
87 |
+
}
|
88 |
+
return $value;
|
89 |
+
}
|
90 |
+
|
91 |
+
public function getAddressCodTaxAmount(Mage_Customer_Model_Address_Abstract $address, $value = null, $alreadyExclTax = false)
|
92 |
+
{
|
93 |
+
if (is_null($value)){
|
94 |
+
$value = $this->getAddressCosts($address);
|
95 |
+
}
|
96 |
+
if (Mage::helper('cashondelivery')->codPriceIncludesTax()) {
|
97 |
+
$includingTax = Mage::helper('cashondelivery')->getCodPrice($value, true, $address, $address->getQuote()->getCustomerTaxClassId());
|
98 |
+
if (!$alreadyExclTax) {
|
99 |
+
$value = Mage::helper('cashondelivery')->getCodPrice($value, false, $address, $address->getQuote()->getCustomerTaxClassId());
|
100 |
+
}
|
101 |
+
return $includingTax - $value;
|
102 |
+
}
|
103 |
+
return 0;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Return true if the method can be used at this time
|
108 |
+
*
|
109 |
+
* @return bool
|
110 |
+
*/
|
111 |
+
public function isAvailable($quote=null)
|
112 |
+
{
|
113 |
+
if (!parent::isAvailable($quote)) {
|
114 |
+
return false;
|
115 |
+
}
|
116 |
+
if (!is_null($quote)) {
|
117 |
+
if($this->getConfigData('shippingallowspecific', $quote->getStoreId())==1){
|
118 |
+
$country = $quote->getShippingAddress()->getCountry();
|
119 |
+
$availableCountries = explode(',', $this->getConfigData('shippingspecificcountry', $quote->getStoreId()));
|
120 |
+
if(!in_array($country, $availableCountries)){
|
121 |
+
return false;
|
122 |
+
}
|
123 |
+
|
124 |
+
}
|
125 |
+
if ($this->getConfigData('disallowspecificshippingmethods', $quote->getStoreId())==1) {
|
126 |
+
$shippingMethodCode = explode('_',$quote->getShippingAddress()->getShippingMethod());
|
127 |
+
$shippingMethodCode = $shippingMethodCode[0];
|
128 |
+
if (in_array($shippingMethodCode, explode(',',$this->getConfigData('disallowedshippingmethods', $quote->getStoreId())))) {
|
129 |
+
return false;
|
130 |
+
}
|
131 |
+
}
|
132 |
+
}
|
133 |
+
return true;
|
134 |
+
}
|
135 |
+
}
|
app/code/community/Hcl/CashOnDelivery/Model/Creditmemo/Total.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Hcl
|
16 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
17 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
class Hcl_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/Hcl/CashOnDelivery/Model/Invoice/Tax.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Hcl
|
16 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
17 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
class Hcl_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 |
+
/**
|
49 |
+
* Not isLast() invoice case handling
|
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 |
+
|
62 |
+
$invoice->setTaxAmount($newTotalTax);
|
63 |
+
$invoice->setBaseTaxAmount($newBaseTotalTax);
|
64 |
+
|
65 |
+
$invoice->setGrandTotal($invoice->getGrandTotal() - $totalTax + $newTotalTax);
|
66 |
+
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() - $baseTotalTax + $newBaseTotalTax);
|
67 |
+
}
|
68 |
+
|
69 |
+
return $this;
|
70 |
+
}
|
71 |
+
}
|
app/code/community/Hcl/CashOnDelivery/Model/Invoice/Total.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Hcl
|
16 |
+
* @package Hcl_CashOnDelivery
|
17 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
18 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
class Hcl_CashOnDelivery_Model_Invoice_Total extends Mage_Sales_Model_Order_Invoice_Total_Abstract
|
23 |
+
{
|
24 |
+
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
|
25 |
+
{
|
26 |
+
$order = $invoice->getOrder();
|
27 |
+
|
28 |
+
if ($order->getPayment()->getMethodInstance()->getCode() != 'cashondelivery'){
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
|
32 |
+
if (!$order->getCodFee()){
|
33 |
+
return $this;
|
34 |
+
}
|
35 |
+
|
36 |
+
foreach ($invoice->getOrder()->getInvoiceCollection() as $previusInvoice) {
|
37 |
+
if ($previusInvoice->getCodAmount() && !$previusInvoice->isCanceled()) {
|
38 |
+
$includeCodTax = false;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
$baseCodFee = $order->getBaseCodFee();
|
43 |
+
$baseCodFeeInvoiced = $order->getBaseCodFeeInvoiced();
|
44 |
+
$baseInvoiceTotal = $invoice->getBaseGrandTotal();
|
45 |
+
$codFee = $order->getCodFee();
|
46 |
+
$codFeeInvoiced = $order->getCodFeeInvoiced();
|
47 |
+
$invoiceTotal = $invoice->getGrandTotal();
|
48 |
+
|
49 |
+
if (!$baseCodFee || $baseCodFeeInvoiced==$baseCodFee) {
|
50 |
+
return $this;
|
51 |
+
}
|
52 |
+
|
53 |
+
$baseCodFeeToInvoice = $baseCodFee - $baseCodFeeInvoiced;
|
54 |
+
$codFeeToInvoice = $codFee - $codFeeInvoiced;
|
55 |
+
|
56 |
+
$baseInvoiceTotal = $baseInvoiceTotal + $baseCodFeeToInvoice;
|
57 |
+
$invoiceTotal = $invoiceTotal + $codFeeToInvoice;
|
58 |
+
|
59 |
+
$invoice->setBaseGrandTotal($baseInvoiceTotal);
|
60 |
+
$invoice->setGrandTotal($invoiceTotal);
|
61 |
+
|
62 |
+
$invoice->setBaseCodFee($baseCodFeeToInvoice);
|
63 |
+
$invoice->setCodFee($codFeeToInvoice);
|
64 |
+
|
65 |
+
$order->setBaseCodFeeInvoiced($baseCodFeeInvoiced+$baseCodFeeToInvoice);
|
66 |
+
$order->setCodFeeInvoiced($codFeeInvoiced+$codFeeToInvoice);
|
67 |
+
|
68 |
+
return $this;
|
69 |
+
}
|
70 |
+
}
|
app/code/community/Hcl/CashOnDelivery/Model/Observer.php
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* 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 Hcl
|
22 |
+
* @package Hcl_CashOnDelivery
|
23 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
24 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
class Hcl_CashOnDelivery_Model_Observer extends Mage_Core_Model_Abstract {
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Collects codFee from qoute/addresses to quote
|
32 |
+
*
|
33 |
+
* @param Varien_Event_Observer $observer
|
34 |
+
*
|
35 |
+
*/
|
36 |
+
|
37 |
+
public function sales_quote_collect_totals_after(Varien_Event_Observer $observer) {
|
38 |
+
$quote = $observer->getEvent()->getQuote();
|
39 |
+
$data = $observer->getInput();
|
40 |
+
$quote->setCodFee(0);
|
41 |
+
$quote->setBaseCodFee(0);
|
42 |
+
$quote->setCodTaxAmount(0);
|
43 |
+
$quote->setBaseCodTaxAmount(0);
|
44 |
+
foreach ($quote->getAllAddresses() as $address) {
|
45 |
+
$quote->setCodFee((float) $quote->getCodFee()+$address->getCodFee());
|
46 |
+
$quote->setBaseCodFee((float) $quote->getBaseCodFee()+$address->getBaseCodFee());
|
47 |
+
|
48 |
+
$quote->setCodTaxAmount((float) $quote->getCodTaxAmount()+$address->getCodTaxAmount());
|
49 |
+
$quote->setBaseCodTaxAmount((float) $quote->getBaseCodTaxAmount()+$address->getBaseCodTaxAmount());
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Adds codFee to order
|
55 |
+
* @param Varien_Event_Observer $observer
|
56 |
+
*/
|
57 |
+
|
58 |
+
public function sales_order_payment_place_end(Varien_Event_Observer $observer) {
|
59 |
+
$payment = $observer->getPayment();
|
60 |
+
if ($payment->getMethodInstance()->getCode() != 'cashondelivery'){
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
|
64 |
+
$order = $payment->getOrder();
|
65 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
66 |
+
if (! $quote->getId()) {
|
67 |
+
$quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
|
68 |
+
}
|
69 |
+
$order->setCodFee($quote->getCodFee());
|
70 |
+
$order->setBaseCodFee($quote->getBaseCodFee());
|
71 |
+
|
72 |
+
$order->setCodTaxAmount($quote->getCodTaxAmount());
|
73 |
+
$order->setBaseCodTaxAmount($quote->getBaseCodTaxAmount());
|
74 |
+
|
75 |
+
$order->save();
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Performs order_creage_loadBlock response update
|
80 |
+
* adds totals block to each response
|
81 |
+
* This function is depricated, the totals block update is implemented
|
82 |
+
* in Hcl/cashondelivery/sales.js (SalesOrder class extension)
|
83 |
+
* @param Varien_Event_Observer $observer
|
84 |
+
*/
|
85 |
+
|
86 |
+
public function controller_action_layout_load_before(Varien_Event_Observer $observer) {
|
87 |
+
$action = $observer->getAction();
|
88 |
+
if ($action->getFullActionName() != 'adminhtml_sales_order_create_loadBlock' || !$action->getRequest()->getParam('json')){
|
89 |
+
return;
|
90 |
+
}
|
91 |
+
$layout = $observer->getLayout();
|
92 |
+
$layout->getUpdate()->addHandle('adminhtml_sales_order_create_load_block_totals');
|
93 |
+
}
|
94 |
+
|
95 |
+
}
|
96 |
+
|
97 |
+
?>
|
app/code/community/Hcl/CashOnDelivery/Model/Quote/TaxTotal.php
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Hcl
|
16 |
+
* @package Hcl_CashOnDelivery
|
17 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
18 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
class Hcl_CashOnDelivery_Model_Quote_TaxTotal extends Mage_Sales_Model_Quote_Address_Total_Tax {
|
23 |
+
|
24 |
+
const CONFIG_XML_PATH_COD_TAX_CLASS = 'tax/classes/cod_tax_class';
|
25 |
+
const CONFIG_XML_PATH_COD_INCLUDES_TAX = 'tax/calculation/cod_includes_tax';
|
26 |
+
const CONFIG_XML_PATH_DISPLAY_COD = 'tax/display/cod_fee';
|
27 |
+
|
28 |
+
public function collect(Mage_Sales_Model_Quote_Address $address)
|
29 |
+
{
|
30 |
+
|
31 |
+
$paymentMethod = Mage::app()->getFrontController()->getRequest()->getParam('payment');
|
32 |
+
$paymentMethod = Mage::app()->getStore()->isAdmin() && isset($paymentMethod['method']) ? $paymentMethod['method'] : null;
|
33 |
+
if ($paymentMethod != 'cashondelivery' && (!count($address->getQuote()->getPaymentsCollection()) || !$address->getQuote()->getPayment()->hasMethodInstance())){
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
|
37 |
+
$paymentMethod = $address->getQuote()->getPayment()->getMethodInstance();
|
38 |
+
|
39 |
+
if ($paymentMethod->getCode() != 'cashondelivery') {
|
40 |
+
return $this;
|
41 |
+
}
|
42 |
+
|
43 |
+
$store = $address->getQuote()->getStore();
|
44 |
+
|
45 |
+
$items = $address->getAllItems();
|
46 |
+
if (!count($items)) {
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
$custTaxClassId = $address->getQuote()->getCustomerTaxClassId();
|
51 |
+
|
52 |
+
$taxCalculationModel = Mage::getSingleton('tax/calculation');
|
53 |
+
/* @var $taxCalculationModel Mage_Tax_Model_Calculation */
|
54 |
+
$request = $taxCalculationModel->getRateRequest($address, $address->getQuote()->getBillingAddress(), $custTaxClassId, $store);
|
55 |
+
$codTaxClass = Mage::helper('cashondelivery')->getCodTaxClass($store);
|
56 |
+
|
57 |
+
$codTax = 0;
|
58 |
+
$codBaseTax = 0;
|
59 |
+
|
60 |
+
if ($codTaxClass) {
|
61 |
+
if ($rate = $taxCalculationModel->getRate($request->setProductClassId($codTaxClass))) {
|
62 |
+
if (!Mage::helper('cashondelivery')->codPriceIncludesTax()) {
|
63 |
+
$codTax = $address->getCodFee() * $rate/100;
|
64 |
+
$codBaseTax= $address->getBaseCodFee() * $rate/100;
|
65 |
+
} else {
|
66 |
+
$codTax = $address->getCodTaxAmount();
|
67 |
+
$codBaseTax= $address->getBaseCodTaxAmount();
|
68 |
+
}
|
69 |
+
|
70 |
+
$codTax = $store->roundPrice($codTax);
|
71 |
+
$codBaseTax= $store->roundPrice($codBaseTax);
|
72 |
+
|
73 |
+
$address->setTaxAmount($address->getTaxAmount() + $codTax);
|
74 |
+
$address->setBaseTaxAmount($address->getBaseTaxAmount() + $codBaseTax);
|
75 |
+
|
76 |
+
$this->_saveAppliedTaxes(
|
77 |
+
$address,
|
78 |
+
$taxCalculationModel->getAppliedRates($request),
|
79 |
+
$codTax,
|
80 |
+
$codBaseTax,
|
81 |
+
$rate
|
82 |
+
);
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
if (!Mage::helper('cashondelivery')->codPriceIncludesTax()) {
|
87 |
+
$address->setCodTaxAmount($codTax);
|
88 |
+
$address->setBaseCodTaxAmount($codBaseTax);
|
89 |
+
}
|
90 |
+
|
91 |
+
$address->setGrandTotal($address->getGrandTotal() + $address->getCodTaxAmount());
|
92 |
+
$address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseCodTaxAmount());
|
93 |
+
|
94 |
+
return $this;
|
95 |
+
}
|
96 |
+
|
97 |
+
public function fetch(Mage_Sales_Model_Quote_Address $address)
|
98 |
+
{
|
99 |
+
$store = $address->getQuote()->getStore();
|
100 |
+
/**
|
101 |
+
* Modify subtotal
|
102 |
+
*/
|
103 |
+
if (Mage::getSingleton('tax/config')->displayCartSubtotalBoth($store) || Mage::getSingleton('tax/config')->displayCartSubtotalInclTax($store)) {
|
104 |
+
if ($address->getSubtotalInclTax() > 0) {
|
105 |
+
$subtotalInclTax = $address->getSubtotalInclTax();
|
106 |
+
} else {
|
107 |
+
$subtotalInclTax = $address->getSubtotal()+$address->getTaxAmount()-$address->getShippingTaxAmount()-$address->getCodTaxAmount();
|
108 |
+
}
|
109 |
+
|
110 |
+
$address->addTotal(array(
|
111 |
+
'code' => 'subtotal',
|
112 |
+
'title' => Mage::helper('sales')->__('Subtotal'),
|
113 |
+
'value' => $subtotalInclTax,
|
114 |
+
'value_incl_tax' => $subtotalInclTax,
|
115 |
+
'value_excl_tax' => $address->getSubtotal(),
|
116 |
+
));
|
117 |
+
}
|
118 |
+
return $this;
|
119 |
+
}
|
120 |
+
}
|
app/code/community/Hcl/CashOnDelivery/Model/Quote/Total.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Hcl
|
16 |
+
* @package Hcl_CashOnDelivery
|
17 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
18 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
class Hcl_CashOnDelivery_Model_Quote_Total extends Mage_Sales_Model_Quote_Address_Total_Abstract {
|
23 |
+
|
24 |
+
public function collect(Mage_Sales_Model_Quote_Address $address)
|
25 |
+
{
|
26 |
+
$address->setBaseCodFee(0);
|
27 |
+
$address->setCodFee(0);
|
28 |
+
$address->setCodTaxAmount(0);
|
29 |
+
$address->setBaseCodTaxAmount(0);
|
30 |
+
|
31 |
+
$paymentMethod = Mage::app()->getFrontController()->getRequest()->getParam('payment');
|
32 |
+
$paymentMethod = Mage::app()->getStore()->isAdmin() && isset($paymentMethod['method']) ? $paymentMethod['method'] : null;
|
33 |
+
if ($paymentMethod != 'cashondelivery' && (!count($address->getQuote()->getPaymentsCollection()) || !$address->getQuote()->getPayment()->hasMethodInstance())){
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
|
37 |
+
$paymentMethod = $address->getQuote()->getPayment()->getMethodInstance();
|
38 |
+
|
39 |
+
if ($paymentMethod->getCode() != 'cashondelivery') {
|
40 |
+
return $this;
|
41 |
+
}
|
42 |
+
|
43 |
+
$items = $address->getAllItems();
|
44 |
+
if (!count($items)) {
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
|
48 |
+
$baseTotal = $address->getBaseGrandTotal();
|
49 |
+
|
50 |
+
$baseCodFee = $paymentMethod->getAddressCodFee($address);
|
51 |
+
|
52 |
+
if (!$baseCodFee > 0 ) {
|
53 |
+
return $this;
|
54 |
+
}
|
55 |
+
|
56 |
+
// adress is the reference for grand total
|
57 |
+
$quote = $address->getQuote();
|
58 |
+
|
59 |
+
$store = $quote->getStore();
|
60 |
+
|
61 |
+
$baseTotal += $baseCodFee;
|
62 |
+
|
63 |
+
$address->setBaseCodFee($baseCodFee);
|
64 |
+
$address->setCodFee($store->convertPrice($baseCodFee,false));
|
65 |
+
|
66 |
+
// update totals
|
67 |
+
$address->setBaseGrandTotal($baseTotal);
|
68 |
+
$address->setGrandTotal($store->convertPrice($baseTotal, false));
|
69 |
+
|
70 |
+
//Updating cod tax if it is already included into a COD fee
|
71 |
+
$baseCodTaxAmount = $paymentMethod->getAddressCodTaxAmount($address);
|
72 |
+
$address->setBaseCodTaxAmount($baseCodTaxAmount);
|
73 |
+
$address->setCodTaxAmount($store->convertPrice($baseCodTaxAmount, false));
|
74 |
+
|
75 |
+
return $this;
|
76 |
+
}
|
77 |
+
|
78 |
+
public function fetch(Mage_Sales_Model_Quote_Address $address) {
|
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 |
+
}
|
90 |
+
}
|
app/code/community/Hcl/CashOnDelivery/Model/Sales/Pdf/Cod.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* 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 Hcl
|
22 |
+
* @package Hcl_CashOnDelivery
|
23 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
24 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
class Hcl_CashOnDelivery_Model_Sales_Pdf_Cod extends Mage_Sales_Model_Order_Pdf_Total_Default
|
29 |
+
{
|
30 |
+
/**
|
31 |
+
* Get array of arrays with totals information for display in PDF
|
32 |
+
* array(
|
33 |
+
* $index => array(
|
34 |
+
* 'amount' => $amount,
|
35 |
+
* 'label' => $label,
|
36 |
+
* 'font_size'=> $font_size
|
37 |
+
* )
|
38 |
+
* )
|
39 |
+
* @return array
|
40 |
+
*/
|
41 |
+
public function getTotalsForDisplay()
|
42 |
+
{
|
43 |
+
$store = $this->getOrder()->getStore();
|
44 |
+
$amount = $this->getOrder()->formatPriceTxt($this->getAmount());
|
45 |
+
$amountInclTax = $this->getAmount()+$this->getSource()->getCodTaxAmount();
|
46 |
+
$amountInclTax = $this->getOrder()->formatPriceTxt($amountInclTax);
|
47 |
+
$fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
|
48 |
+
|
49 |
+
if (Mage::helper('cashondelivery')->displayCodBothPrices()){
|
50 |
+
$totals = array(
|
51 |
+
array(
|
52 |
+
'amount' => $this->getAmountPrefix().$amount,
|
53 |
+
'label' => Mage::helper('cashondelivery')->__('Cash on Delivery fee (Excl.Tax)') . ':',
|
54 |
+
'font_size' => $fontSize
|
55 |
+
),
|
56 |
+
array(
|
57 |
+
'amount' => $this->getAmountPrefix().$amountInclTax,
|
58 |
+
'label' => Mage::helper('cashondelivery')->__('Cash on Delivery fee (Incl.Tax)') . ':',
|
59 |
+
'font_size' => $fontSize
|
60 |
+
),
|
61 |
+
);
|
62 |
+
} elseif (Mage::helper('cashondelivery')->displayCodFeeIncludingTax()) {
|
63 |
+
$totals = array(array(
|
64 |
+
'amount' => $this->getAmountPrefix().$amountInclTax,
|
65 |
+
'label' => Mage::helper('cashondelivery')->__($this->getTitle()) . ':',
|
66 |
+
'font_size' => $fontSize
|
67 |
+
));
|
68 |
+
} else {
|
69 |
+
$totals = array(array(
|
70 |
+
'amount' => $this->getAmountPrefix().$amount,
|
71 |
+
'label' => Mage::helper('cashondelivery')->__($this->getTitle()) . ':',
|
72 |
+
'font_size' => $fontSize
|
73 |
+
));
|
74 |
+
}
|
75 |
+
|
76 |
+
return $totals;
|
77 |
+
}
|
78 |
+
}
|
app/code/community/Hcl/CashOnDelivery/Model/Source/AvailableShipmentMethods.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* 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 Hcl
|
22 |
+
* @package Hcl_CashOnDelivery
|
23 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
24 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
class Hcl_CashOnDelivery_Model_Source_AvailableShipmentMethods
|
29 |
+
{
|
30 |
+
public function toOptionArray()
|
31 |
+
{
|
32 |
+
$options = array();
|
33 |
+
|
34 |
+
foreach (Mage::app()->getStore()->getConfig('carriers') as $code => $carrier) {
|
35 |
+
if ($carrier['active'] && isset($carrier['title'])){
|
36 |
+
$options[] = array(
|
37 |
+
'value' => $code,
|
38 |
+
'label' => $carrier['title']
|
39 |
+
);
|
40 |
+
}
|
41 |
+
}
|
42 |
+
return $options;
|
43 |
+
}
|
44 |
+
}
|
app/code/community/Hcl/CashOnDelivery/etc/config.xml
ADDED
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Hcl
|
17 |
+
* @package Hcl_CashOnDelivery
|
18 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
19 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
+
*/
|
22 |
+
-->
|
23 |
+
<config>
|
24 |
+
<modules>
|
25 |
+
<Hcl_CashOnDelivery>
|
26 |
+
<version>1.0.0</version>
|
27 |
+
</Hcl_CashOnDelivery>
|
28 |
+
</modules>
|
29 |
+
|
30 |
+
<global>
|
31 |
+
<models>
|
32 |
+
<cashondelivery>
|
33 |
+
<class>Hcl_CashOnDelivery_Model</class>
|
34 |
+
</cashondelivery>
|
35 |
+
</models>
|
36 |
+
<resources>
|
37 |
+
<cashondelivery_setup>
|
38 |
+
<setup>
|
39 |
+
<module>Hcl_CashOnDelivery</module>
|
40 |
+
</setup>
|
41 |
+
<connection>
|
42 |
+
<use>core_setup</use>
|
43 |
+
</connection>
|
44 |
+
</cashondelivery_setup>
|
45 |
+
<cashondelivery_write>
|
46 |
+
<use>core_write</use>
|
47 |
+
</cashondelivery_write>
|
48 |
+
<cashondelivery_read>
|
49 |
+
<use>core_read</use>
|
50 |
+
</cashondelivery_read>
|
51 |
+
</resources>
|
52 |
+
<helpers>
|
53 |
+
<cashondelivery>
|
54 |
+
<class>Hcl_CashOnDelivery_Helper</class>
|
55 |
+
</cashondelivery>
|
56 |
+
</helpers>
|
57 |
+
<blocks>
|
58 |
+
<cashondelivery><class>Hcl_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>
|
128 |
+
|
129 |
+
<default>
|
130 |
+
<payment>
|
131 |
+
<cashondelivery>
|
132 |
+
<active>0</active>
|
133 |
+
<model>cashondelivery/cashOnDelivery</model>
|
134 |
+
<order_status>1</order_status>
|
135 |
+
<title>Cash On Delivery</title>
|
136 |
+
<allowspecific>0</allowspecific>
|
137 |
+
<shippingallowspecific>0</shippingallowspecific>
|
138 |
+
<disallowspecificshippingmethods>0</disallowspecificshippingmethods>
|
139 |
+
<display_zero_fee>0</display_zero_fee>
|
140 |
+
</cashondelivery>
|
141 |
+
</payment>
|
142 |
+
<sales>
|
143 |
+
<totals_sort>
|
144 |
+
<cashondelivery>39</cashondelivery>
|
145 |
+
<cashondelivery_tax>97</cashondelivery_tax>
|
146 |
+
</totals_sort>
|
147 |
+
</sales>
|
148 |
+
<tax>
|
149 |
+
<classes>
|
150 |
+
<cod_tax_class></cod_tax_class>
|
151 |
+
</classes>
|
152 |
+
<calculation>
|
153 |
+
<cod_includes_tax>0</cod_includes_tax>
|
154 |
+
</calculation>
|
155 |
+
<display>
|
156 |
+
<cod_fee>1</cod_fee>
|
157 |
+
</display>
|
158 |
+
</tax>
|
159 |
+
</default>
|
160 |
+
|
161 |
+
<adminhtml>
|
162 |
+
<translate>
|
163 |
+
<modules>
|
164 |
+
<Hcl_CashOnDelivery>
|
165 |
+
<files>
|
166 |
+
<default>Hcl_CashOnDelivery.csv</default>
|
167 |
+
</files>
|
168 |
+
</Hcl_CashOnDelivery>
|
169 |
+
</modules>
|
170 |
+
</translate>
|
171 |
+
<layout>
|
172 |
+
<updates>
|
173 |
+
<cashondelivery>
|
174 |
+
<file>cashondelivery.xml</file>
|
175 |
+
</cashondelivery>
|
176 |
+
</updates>
|
177 |
+
</layout>
|
178 |
+
</adminhtml>
|
179 |
+
|
180 |
+
<frontend>
|
181 |
+
<layout>
|
182 |
+
<updates>
|
183 |
+
<cashondelivery>
|
184 |
+
<file>cashondelivery.xml</file>
|
185 |
+
</cashondelivery>
|
186 |
+
</updates>
|
187 |
+
</layout>
|
188 |
+
<translate>
|
189 |
+
<modules>
|
190 |
+
<Hcl_CashOnDelivery>
|
191 |
+
<files>
|
192 |
+
<default>Hcl_CashOnDelivery.csv</default>
|
193 |
+
</files>
|
194 |
+
</Hcl_CashOnDelivery>
|
195 |
+
</modules>
|
196 |
+
</translate>
|
197 |
+
</frontend>
|
198 |
+
</config>
|
app/code/community/Hcl/CashOnDelivery/etc/system.xml
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Hcl
|
17 |
+
* @package Hcl_CashOnDelivery
|
18 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
19 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
+
*/
|
22 |
+
-->
|
23 |
+
<config>
|
24 |
+
<sections>
|
25 |
+
<payment>
|
26 |
+
<groups>
|
27 |
+
<cashondelivery translate="label" module="payment">
|
28 |
+
<label>Cash On Delivery</label>
|
29 |
+
<frontend_type>text</frontend_type>
|
30 |
+
<sort_order>1</sort_order>
|
31 |
+
<show_in_default>1</show_in_default>
|
32 |
+
<show_in_website>1</show_in_website>
|
33 |
+
<show_in_store>1</show_in_store>
|
34 |
+
<fields>
|
35 |
+
<active translate="label">
|
36 |
+
<label>Enabled</label>
|
37 |
+
<frontend_type>select</frontend_type>
|
38 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
39 |
+
<sort_order>10</sort_order>
|
40 |
+
<show_in_default>1</show_in_default>
|
41 |
+
<show_in_website>1</show_in_website>
|
42 |
+
<show_in_store>1</show_in_store>
|
43 |
+
</active>
|
44 |
+
<display_zero_fee translate="label">
|
45 |
+
<label>Display Zero Fee</label>
|
46 |
+
<frontend_type>select</frontend_type>
|
47 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
48 |
+
<sort_order>11</sort_order>
|
49 |
+
<show_in_default>1</show_in_default>
|
50 |
+
<show_in_website>1</show_in_website>
|
51 |
+
<show_in_store>1</show_in_store>
|
52 |
+
</display_zero_fee>
|
53 |
+
<title translate="label">
|
54 |
+
<label>Title</label>
|
55 |
+
<frontend_type>text</frontend_type>
|
56 |
+
<sort_order>20</sort_order>
|
57 |
+
<show_in_default>1</show_in_default>
|
58 |
+
<show_in_website>1</show_in_website>
|
59 |
+
<show_in_store>1</show_in_store>
|
60 |
+
</title>
|
61 |
+
<order_status translate="label">
|
62 |
+
<label>New order status</label>
|
63 |
+
<frontend_type>select</frontend_type>
|
64 |
+
<source_model>adminhtml/system_config_source_order_status</source_model>
|
65 |
+
<sort_order>40</sort_order>
|
66 |
+
<show_in_default>1</show_in_default>
|
67 |
+
<show_in_website>1</show_in_website>
|
68 |
+
<show_in_store>1</show_in_store>
|
69 |
+
</order_status>
|
70 |
+
<sort_order translate="label">
|
71 |
+
<label>Sort order</label>
|
72 |
+
<frontend_type>text</frontend_type>
|
73 |
+
<sort_order>50</sort_order>
|
74 |
+
<show_in_default>1</show_in_default>
|
75 |
+
<show_in_website>1</show_in_website>
|
76 |
+
<show_in_store>1</show_in_store>
|
77 |
+
</sort_order>
|
78 |
+
<shippingallowspecific translate="label">
|
79 |
+
<label>Shipment to applicable countries</label>
|
80 |
+
<frontend_type>allowspecific</frontend_type>
|
81 |
+
<sort_order>60</sort_order>
|
82 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
83 |
+
<show_in_default>1</show_in_default>
|
84 |
+
<show_in_website>1</show_in_website>
|
85 |
+
<show_in_store>1</show_in_store>
|
86 |
+
</shippingallowspecific>
|
87 |
+
<shippingspecificcountry translate="label">
|
88 |
+
<label>Shipment to Specific countries</label>
|
89 |
+
<frontend_type>multiselect</frontend_type>
|
90 |
+
<sort_order>70</sort_order>
|
91 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
92 |
+
<show_in_default>1</show_in_default>
|
93 |
+
<show_in_website>1</show_in_website>
|
94 |
+
<show_in_store>1</show_in_store>
|
95 |
+
</shippingspecificcountry>
|
96 |
+
<inlandcosts translate="label">
|
97 |
+
<label>Costs for inland shipping</label>
|
98 |
+
<frontend_type>text</frontend_type>
|
99 |
+
<sort_order>80</sort_order>
|
100 |
+
<show_in_default>1</show_in_default>
|
101 |
+
<show_in_website>1</show_in_website>
|
102 |
+
<show_in_store>1</show_in_store>
|
103 |
+
</inlandcosts>
|
104 |
+
<foreigncountrycosts translate="label">
|
105 |
+
<label>Costs for shipping to foreign countries</label>
|
106 |
+
<frontend_type>text</frontend_type>
|
107 |
+
<sort_order>90</sort_order>
|
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 |
+
</foreigncountrycosts>
|
112 |
+
<customtext translate="label">
|
113 |
+
<label>Custom text for checkout page</label>
|
114 |
+
<frontend_type>text</frontend_type>
|
115 |
+
<sort_order>100</sort_order>
|
116 |
+
<show_in_default>1</show_in_default>
|
117 |
+
<show_in_website>1</show_in_website>
|
118 |
+
<show_in_store>1</show_in_store>
|
119 |
+
</customtext>
|
120 |
+
<disallowspecificshippingmethods translate="label">
|
121 |
+
<label>Disallow specific shipping methods</label>
|
122 |
+
<frontend_type>select</frontend_type>
|
123 |
+
<sort_order>110</sort_order>
|
124 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
125 |
+
<show_in_default>1</show_in_default>
|
126 |
+
<show_in_website>1</show_in_website>
|
127 |
+
<show_in_store>1</show_in_store>
|
128 |
+
</disallowspecificshippingmethods>
|
129 |
+
<disallowedshippingmethods translate="label">
|
130 |
+
<label>Disallowed shipping methods</label>
|
131 |
+
<frontend_type>multiselect</frontend_type>
|
132 |
+
<sort_order>120</sort_order>
|
133 |
+
<source_model>cashondelivery/source_availableShipmentMethods</source_model>
|
134 |
+
<show_in_default>1</show_in_default>
|
135 |
+
<show_in_website>1</show_in_website>
|
136 |
+
<show_in_store>1</show_in_store>
|
137 |
+
</disallowedshippingmethods>
|
138 |
+
</fields>
|
139 |
+
</cashondelivery>
|
140 |
+
</groups>
|
141 |
+
</payment>
|
142 |
+
<tax translate="label" module="tax">
|
143 |
+
<groups>
|
144 |
+
<classes translate="label">
|
145 |
+
<fields>
|
146 |
+
<cod_tax_class translate="label">
|
147 |
+
<label>Tax Class for Cash on Delivery Fee</label>
|
148 |
+
<frontend_type>select</frontend_type>
|
149 |
+
<source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
|
150 |
+
<sort_order>20</sort_order>
|
151 |
+
<show_in_default>1</show_in_default>
|
152 |
+
<show_in_website>1</show_in_website>
|
153 |
+
<show_in_store>1</show_in_store>
|
154 |
+
</cod_tax_class>
|
155 |
+
</fields>
|
156 |
+
</classes>
|
157 |
+
<calculation translate="label">
|
158 |
+
<fields>
|
159 |
+
<cod_includes_tax translate="label comment">
|
160 |
+
<label>Cash on Delivery fee include tax</label>
|
161 |
+
<frontend_type>select</frontend_type>
|
162 |
+
<!--<backend_model>tax/config_price_include</backend_model>-->
|
163 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
164 |
+
<sort_order>35</sort_order>
|
165 |
+
<show_in_default>1</show_in_default>
|
166 |
+
<show_in_website>1</show_in_website>
|
167 |
+
<show_in_store>1</show_in_store>
|
168 |
+
</cod_includes_tax>
|
169 |
+
</fields>
|
170 |
+
</calculation>
|
171 |
+
<display>
|
172 |
+
<fields>
|
173 |
+
<cod_fee translate="label">
|
174 |
+
<label>Display Cod Fee</label>
|
175 |
+
<frontend_type>select</frontend_type>
|
176 |
+
<source_model>tax/system_config_source_tax_display_type</source_model>
|
177 |
+
<sort_order>100</sort_order>
|
178 |
+
<show_in_default>1</show_in_default>
|
179 |
+
<show_in_website>1</show_in_website>
|
180 |
+
<show_in_store>1</show_in_store>
|
181 |
+
</cod_fee>
|
182 |
+
</fields>
|
183 |
+
</display>
|
184 |
+
</groups>
|
185 |
+
</tax>
|
186 |
+
</sections>
|
187 |
+
</config>
|
app/code/community/Hcl/CashOnDelivery/sql/cashondelivery_setup/mysql4-install-0.2.0.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* 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 Hcl
|
22 |
+
* @package Hcl_CashOnDelivery
|
23 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
24 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
$this->startSetup();
|
29 |
+
|
30 |
+
$this->_conn->addColumn($this->getTable('sales_flat_quote'), 'cod_fee', 'decimal(12,4)');
|
31 |
+
$this->_conn->addColumn($this->getTable('sales_flat_quote'), 'base_cod_fee', 'decimal(12,4)');
|
32 |
+
$this->_conn->addColumn($this->getTable('sales_flat_quote_address'), 'cod_fee', 'decimal(12,4)');
|
33 |
+
$this->_conn->addColumn($this->getTable('sales_flat_quote_address'), 'base_cod_fee', 'decimal(12,4)');
|
34 |
+
|
35 |
+
$eav = new Mage_Eav_Model_Entity_Setup('sales_setup');
|
36 |
+
|
37 |
+
$eav->addAttribute('order', 'cod_fee', array('type' => 'decimal',));
|
38 |
+
$eav->addAttribute('order', 'base_cod_fee', array('type' => 'decimal'));
|
39 |
+
|
40 |
+
$eav->addAttribute('order', 'cod_fee_invoiced', array('type' => 'decimal',));
|
41 |
+
$eav->addAttribute('order', 'base_cod_fee_invoiced', array('type' => 'decimal'));
|
42 |
+
|
43 |
+
//$eav->addAttribute('order', 'cod_fee_refunded', array('type' => 'decimal',));
|
44 |
+
//$eav->addAttribute('order', 'base_cod_fee_refunded', array('type' => 'decimal'));
|
45 |
+
|
46 |
+
//$eav->addAttribute('order', 'cod_fee_canceled', array('type' => 'decimal',));
|
47 |
+
//$eav->addAttribute('order', 'base_cod_fee_canceled', array('type' => 'decimal'));
|
48 |
+
|
49 |
+
$eav->addAttribute('invoice', 'cod_fee', array('type' => 'decimal',));
|
50 |
+
$eav->addAttribute('invoice', 'base_cod_fee', array('type' => 'decimal'));
|
51 |
+
|
52 |
+
//$eav->addAttribute('creditmemo', 'cod_fee', array('type' => 'decimal',));
|
53 |
+
//$eav->addAttribute('creditmemo', 'base_cod_fee', array('type' => 'decimal'));
|
54 |
+
|
55 |
+
$this->endSetup();
|
56 |
+
|
57 |
+
?>
|
app/code/community/Hcl/CashOnDelivery/sql/cashondelivery_setup/mysql4-upgrade-0.2.0-0.2.1.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* 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 Hcl
|
22 |
+
* @package Hcl_CashOnDelivery
|
23 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
24 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
$this->startSetup();
|
29 |
+
|
30 |
+
$this->_conn->addColumn($this->getTable('sales_flat_quote'), 'cod_tax_amount', 'decimal(12,4)');
|
31 |
+
$this->_conn->addColumn($this->getTable('sales_flat_quote'), 'base_cod_tax_amount', 'decimal(12,4)');
|
32 |
+
$this->_conn->addColumn($this->getTable('sales_flat_quote_address'), 'cod_tax_amount', 'decimal(12,4)');
|
33 |
+
$this->_conn->addColumn($this->getTable('sales_flat_quote_address'), 'base_cod_tax_amount', 'decimal(12,4)');
|
34 |
+
|
35 |
+
$eav = new Mage_Eav_Model_Entity_Setup('sales_setup');
|
36 |
+
|
37 |
+
$eav->addAttribute('order', 'cod_tax_amount', array('type' => 'decimal',));
|
38 |
+
$eav->addAttribute('order', 'base_cod_tax_amount', array('type' => 'decimal'));
|
39 |
+
|
40 |
+
$eav->addAttribute('order', 'cod_tax_amount_invoiced', array('type' => 'decimal',));
|
41 |
+
$eav->addAttribute('order', 'base_cod_tax_amount_invoiced', array('type' => 'decimal'));
|
42 |
+
|
43 |
+
//$eav->addAttribute('order', 'cod_tax_amount_refunded', array('type' => 'decimal',));
|
44 |
+
//$eav->addAttribute('order', 'base_cod_tax_amount_refunded', array('type' => 'decimal'));
|
45 |
+
|
46 |
+
//$eav->addAttribute('order', 'cod_tax_amount_canceled', array('type' => 'decimal',));
|
47 |
+
//$eav->addAttribute('order', 'base_cod_tax_amount_canceled', array('type' => 'decimal'));
|
48 |
+
|
49 |
+
$eav->addAttribute('invoice', 'cod_tax_amount', array('type' => 'decimal',));
|
50 |
+
$eav->addAttribute('invoice', 'base_cod_tax_amount', array('type' => 'decimal'));
|
51 |
+
|
52 |
+
//$eav->addAttribute('creditmemo', 'cod_tax_amount', array('type' => 'decimal',));
|
53 |
+
//$eav->addAttribute('creditmemo', 'base_cod_tax_amount', array('type' => 'decimal'));
|
54 |
+
|
55 |
+
$this->endSetup();
|
56 |
+
|
57 |
+
?>
|
app/code/community/Hcl/CashOnDelivery/sql/cashondelivery_setup/mysql4-upgrade-0.3.2-0.3.3.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* 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 Hcl
|
22 |
+
* @package Hcl_CashOnDelivery
|
23 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
24 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
$this->startSetup();
|
29 |
+
|
30 |
+
$this->run("
|
31 |
+
UPDATE {$this->getTable('core_config_data')} SET `value` = 0 WHERE `path` = 'payment/cashondelivery/allowspecific';
|
32 |
+
");
|
33 |
+
|
34 |
+
$this->endSetup();
|
35 |
+
|
36 |
+
?>
|
app/code/community/Hcl/CashOnDelivery/sql/cashondelivery_setup/mysql4-upgrade-0.4.6-0.4.7.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* 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 Hcl
|
22 |
+
* @package Hcl_CashOnDelivery
|
23 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
24 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
$this->startSetup();
|
29 |
+
|
30 |
+
$setup = new Mage_Sales_Model_Mysql4_Setup('sales_setup');
|
31 |
+
|
32 |
+
$setup->addAttribute('order', 'cod_fee', array('type' => 'decimal'));
|
33 |
+
$setup->addAttribute('order', 'base_cod_fee', array('type' => 'decimal'));
|
34 |
+
$setup->addAttribute('order', 'cod_fee_invoiced', array('type' => 'decimal'));
|
35 |
+
$setup->addAttribute('order', 'base_cod_fee_invoiced', array('type' => 'decimal'));
|
36 |
+
$setup->addAttribute('order', 'cod_tax_amount', array('type' => 'decimal'));
|
37 |
+
$setup->addAttribute('order', 'base_cod_tax_amount', array('type' => 'decimal'));
|
38 |
+
$setup->addAttribute('order', 'cod_tax_amount_invoiced', array('type' => 'decimal'));
|
39 |
+
$setup->addAttribute('order', 'base_cod_tax_amount_invoiced', array('type' => 'decimal'));
|
40 |
+
|
41 |
+
$setup->addAttribute('invoice', 'cod_fee', array('type' => 'decimal'));
|
42 |
+
$setup->addAttribute('invoice', 'base_cod_fee', array('type' => 'decimal'));
|
43 |
+
$setup->addAttribute('invoice', 'cod_tax_amount', array('type' => 'decimal'));
|
44 |
+
$setup->addAttribute('invoice', 'base_cod_tax_amount', array('type' => 'decimal'));
|
45 |
+
|
46 |
+
$setup->addAttribute('quote', 'cod_fee', array('type' => 'decimal'));
|
47 |
+
$setup->addAttribute('quote', 'base_cod_fee', array('type' => 'decimal'));
|
48 |
+
$setup->addAttribute('quote', 'cod_tax_amount', array('type' => 'decimal'));
|
49 |
+
$setup->addAttribute('quote', 'base_cod_tax_amount', array('type' => 'decimal'));
|
50 |
+
$setup->addAttribute('quote_address', 'cod_fee', array('type' => 'decimal'));
|
51 |
+
$setup->addAttribute('quote_address', 'base_cod_fee', array('type' => 'decimal'));
|
52 |
+
$setup->addAttribute('quote_address', 'cod_tax_amount', array('type' => 'decimal'));
|
53 |
+
$setup->addAttribute('quote_address', 'base_cod_tax_amount', array('type' => 'decimal'));
|
54 |
+
|
55 |
+
$this->endSetup();
|
56 |
+
|
57 |
+
?>
|
app/design/adminhtml/default/default/layout/cashondelivery.xml
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @category Hcl
|
24 |
+
* @package Hcl_CashOnDelivery
|
25 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
26 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
27 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
28 |
+
*/
|
29 |
+
-->
|
30 |
+
|
31 |
+
<layout>
|
32 |
+
<adminhtml_sales_order_view>
|
33 |
+
<!--
|
34 |
+
<reference name="sales.order.view.totals.main">
|
35 |
+
<block type="adminhtml/sales_order_totals_item" name="cod_fee" template="sales/order/totals/item.phtml" before="tax">
|
36 |
+
<action method="setSourceField"><value>cod_fee</value></action>
|
37 |
+
<action method="setLabel"><value>Cash on Delivery Fee</value></action>
|
38 |
+
</block>
|
39 |
+
</reference>
|
40 |
+
-->
|
41 |
+
<reference name="order_totals">
|
42 |
+
<block name="cod_fee" type="cashondelivery/order_totals_cod" before="tax"/>
|
43 |
+
</reference>
|
44 |
+
</adminhtml_sales_order_view>
|
45 |
+
|
46 |
+
<adminhtml_sales_order_invoice_view>
|
47 |
+
<!--
|
48 |
+
<reference name="sales.order.view.totals.main">
|
49 |
+
<block type="adminhtml/sales_order_totals_item" name="cod_fee" template="sales/order/totals/item.phtml" before="tax">
|
50 |
+
<action method="setSourceField"><value>cod_fee</value></action>
|
51 |
+
<action method="setLabel"><value>Cash on Delivery Fee</value></action>
|
52 |
+
</block>
|
53 |
+
</reference>
|
54 |
+
-->
|
55 |
+
<reference name="invoice_totals">
|
56 |
+
<block name="cod_fee" type="cashondelivery/invoice_totals_cod" before="tax"/>
|
57 |
+
</reference>
|
58 |
+
</adminhtml_sales_order_invoice_view>
|
59 |
+
|
60 |
+
<adminhtml_sales_order_invoice_new>
|
61 |
+
<!--
|
62 |
+
<reference name="sales.order.view.totals.main">
|
63 |
+
<block type="adminhtml/sales_order_totals_item" name="cod_fee" template="sales/order/totals/item.phtml" before="tax">
|
64 |
+
<action method="setSourceField"><value>cod_fee</value></action>
|
65 |
+
<action method="setLabel"><value>Cash on Delivery Fee</value></action>
|
66 |
+
</block>
|
67 |
+
</reference>
|
68 |
+
-->
|
69 |
+
<reference name="invoice_totals">
|
70 |
+
<block name="cod_fee" type="cashondelivery/invoice_totals_cod" before="tax"/>
|
71 |
+
</reference>
|
72 |
+
</adminhtml_sales_order_invoice_new>
|
73 |
+
|
74 |
+
<adminhtml_sales_order_creditmemo_new>
|
75 |
+
<reference name="sales.order.view.totals.main">
|
76 |
+
<block type="adminhtml/sales_order_totals_item" name="cod_fee" template="sales/order/totals/item.phtml" before="tax">
|
77 |
+
<action method="setSourceField"><value>cod_fee</value></action>
|
78 |
+
<action method="setLabel"><value>Cash on Delivery Fee</value></action>
|
79 |
+
</block>
|
80 |
+
</reference>
|
81 |
+
</adminhtml_sales_order_creditmemo_new>
|
82 |
+
|
83 |
+
<adminhtml_sales_order_creditmemo_view>
|
84 |
+
<reference name="sales.order.view.totals.main">
|
85 |
+
<block type="adminhtml/sales_order_totals_item" name="cod_fee" template="sales/order/totals/item.phtml" before="tax">
|
86 |
+
<action method="setSourceField"><value>cod_fee</value></action>
|
87 |
+
<action method="setLabel"><value>Cash on Delivery Fee</value></action>
|
88 |
+
</block>
|
89 |
+
</reference>
|
90 |
+
</adminhtml_sales_order_creditmemo_view>
|
91 |
+
|
92 |
+
<adminhtml_sales_order_create_index>
|
93 |
+
<reference name="head">
|
94 |
+
<action method="addJs"><file>Hcl/cashondelivery/sales.js</file></action>
|
95 |
+
</reference>
|
96 |
+
</adminhtml_sales_order_create_index>
|
97 |
+
|
98 |
+
</layout>
|
app/etc/modules/Hcl_CashOnDelivery.xml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Hcl
|
17 |
+
* @package Hcl_CashOnDelivery
|
18 |
+
* @copyright Copyright (c) 2011-2012 RAMESH RAMASAMY, BANGALORE
|
19 |
+
* @copyright Copyright (c) 2012 HCL Technologies Ltd (http://www.Hcl.com)
|
20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
+
*/
|
22 |
+
-->
|
23 |
+
<config>
|
24 |
+
<modules>
|
25 |
+
<Hcl_CashOnDelivery>
|
26 |
+
<active>true</active>
|
27 |
+
<codePool>community</codePool>
|
28 |
+
<depends>
|
29 |
+
<Mage_Payment />
|
30 |
+
</depends>
|
31 |
+
</Hcl_CashOnDelivery>
|
32 |
+
</modules>
|
33 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>hclcashondelivery6</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Cash on Delivery allows to book additional fee on delivery depending on india or international delivery</summary>
|
10 |
+
<description>Cash On Delivery This extension will install a new ready-to-use Cash-On-Delivery payment gateway in your Magento store.
|
11 |
+

|
12 |
+
Installation is very easy via Magento Connect and no coding experience is required to have module up-and-running.</description>
|
13 |
+
<notes>Cash on Delivery allows to book additional fee on delivery depending on india or international delivery</notes>
|
14 |
+
<authors><author><name>RameshRamasamy</name><user>rramesh_sat</user><email>rramesh_sat@yahoo.com</email></author></authors>
|
15 |
+
<date>2012-03-28</date>
|
16 |
+
<time>08:54:41</time>
|
17 |
+
<contents><target name="magecommunity"><dir name="Hcl"><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="1420c60ef1b07239160cd8d3319b752d"/></dir></dir><dir name="Creditmemo"><dir name="Totals"><file name="Cod.php" hash="6ae02b964782906e06a2ecebb2fdddf1"/></dir></dir></dir></dir></dir><dir name="Checkout"><file name="Cod.php" hash="3a1c964a9dc7fe025b2f8e4eed004c00"/></dir><file name="Form.php" hash="988303ee738e4f30d938a070d11127e6"/><file name="Info.php" hash="1374ffb00fb73bfffe641573df0026ea"/><dir name="Invoice"><dir name="Totals"><file name="Cod.php" hash="ab2dd93a454643c159755a92299fd31f"/></dir></dir><dir name="Order"><dir name="Totals"><file name="Cod.php" hash="5828df4e71ada041e8567291b0096728"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="34688e340ea2b43c4d5498503217d7bf"/></dir><dir name="Model"><file name="CashOnDelivery.php" hash="d2558fe4e933d66f77a19fd0d6b39578"/><dir name="Creditmemo"><file name="Total.php" hash="b8d00a4741e319020cf83f1fb0de7b72"/></dir><dir name="Invoice"><file name="Tax.php" hash="cdb959d52a0557a4fe75b5d34339d93e"/><file name="Total.php" hash="c78f833508e4726c7140ba90c6e2196c"/></dir><file name="Observer.php" hash="b438d8fb3c259b65d4a44d430223b37e"/><dir name="Quote"><file name="TaxTotal.php" hash="192c8f8d332e97311604df9aa2e4f3c9"/><file name="Total.php" hash="e7f7136df64045c93411e93221578983"/></dir><dir name="Sales"><dir name="Pdf"><file name="Cod.php" hash="041192ab385879b8e052b4ecb095e264"/></dir></dir><dir name="Source"><file name="AvailableShipmentMethods.php" hash="f6e301148abd5ddebf1940c7b8bbec5e"/></dir></dir><dir name="etc"><file name="config.xml" hash="17220daa063e2e02bd0b3be151e46ae8"/><file name="system.xml" hash="d8145462878ce3749b3648c37104b370"/></dir><dir name="sql"><dir name="cashondelivery_setup"><file name="mysql4-install-0.2.0.php" hash="10440e9c9760c1f4bcc0c772c4a44745"/><file name="mysql4-upgrade-0.2.0-0.2.1.php" hash="233d39d38368c9bc6e13fe5a9df4652c"/><file name="mysql4-upgrade-0.3.2-0.3.3.php" hash="7b3d733c7c67ff7a56f00b4c318f76f3"/><file name="mysql4-upgrade-0.4.6-0.4.7.php" hash="02727edda8237b685508542efae58291"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="cashondelivery.xml" hash="aa937b0d16218958bbb9959fca812f6a"/></dir></dir></dir></dir></target><target name="magelocal"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="cashondelivery.xml" hash=""/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Hcl_CashOnDelivery.xml" hash="0b61a324b89056dadcf5ec36be3cbe30"/></dir></target></contents>
|
18 |
+
<compatible/>
|
19 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Mage_Code_Moudles</name><channel>community</channel><min>1.6.0</min><max>1.7.0</max></package><extension><name>gd</name><min>2.0.2</min><max>3.0.0</max></extension></required></dependencies>
|
20 |
+
</package>
|