Version Notes
Zipcode based Cash on Delivery payment method at checkout
Download this release
Release Info
Developer | harpreet |
Extension | Mfp_Cod |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Mfp/Cod/Helper/Data.php +5 -0
- app/code/community/Mfp/Cod/Model/Observer.php +59 -0
- app/code/community/Mfp/Cod/etc/adminhtml.xml +29 -0
- app/code/community/Mfp/Cod/etc/config.xml +34 -0
- app/code/community/Mfp/Cod/etc/system.xml +51 -0
- app/etc/modules/Mfp_Cod.xml +10 -0
- package.xml +21 -0
app/code/community/Mfp/Cod/Helper/Data.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Mfp_Cod_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
}
|
5 |
+
|
app/code/community/Mfp/Cod/Model/Observer.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Mfp_Cod_Model_Observer {
|
3 |
+
|
4 |
+
public function getCashOnDelvery(Varien_Event_Observer $observer) {
|
5 |
+
$event = $observer->getEvent();
|
6 |
+
$method = $event->getMethodInstance();
|
7 |
+
$result = $event->getResult();
|
8 |
+
$isModuleEnable = Mage::getStoreConfig('cod/cod/enable');
|
9 |
+
|
10 |
+
if($isModuleEnable) {
|
11 |
+
|
12 |
+
if($method->getCode() == 'cashondelivery' ){
|
13 |
+
|
14 |
+
$quote = Mage::getSingleton('checkout/cart')->getQuote();
|
15 |
+
$add = $quote->getShippingAddress();
|
16 |
+
$postcode = $add->getData('postcode');
|
17 |
+
|
18 |
+
$comparisonMode = Mage::getStoreConfig('cod/cod/mode');
|
19 |
+
$zipCodes = Mage::getStoreConfig('cod/cod/zipcode');
|
20 |
+
$isExist = false;
|
21 |
+
|
22 |
+
if(trim($zipCodes) == '') {
|
23 |
+
$result->isAvailable = true;
|
24 |
+
} else {
|
25 |
+
|
26 |
+
if(strpos($zipCodes, $postcode) !== false) {
|
27 |
+
$isExist = true;
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
if($isExist != true) {
|
32 |
+
|
33 |
+
$zipCodesArray = explode(',', nl2br($zipCodes));
|
34 |
+
if(count($elementLineArray) > 1) {
|
35 |
+
foreach($zipCodesArray as $codzipLine) {
|
36 |
+
$elementLineArray = explode('-', $codzipLine);
|
37 |
+
if(count($elementLineArray) == 2 && ( $postcode >= $elementLineArray[0] && $postcode <= $elementLineArray[1] )) {
|
38 |
+
$isExist = true;
|
39 |
+
break;
|
40 |
+
} else if($postcode == $codzipLine) {
|
41 |
+
$isExist = true;
|
42 |
+
break;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
$returnValue = '';
|
49 |
+
$returnValue = ($isExist)?true:false;
|
50 |
+
|
51 |
+
$result->isAvailable = $returnValue;
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
app/code/community/Mfp/Cod/etc/adminhtml.xml
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @author Ecommerce Approch Team
|
5 |
+
* @copyright Copyright (c) 2015 Ecommerce Approch (http://www.ecommerceapproach.com/)
|
6 |
+
* @package Ecommerceapp_Cashdelivery
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<config>
|
10 |
+
<acl>
|
11 |
+
<resources>
|
12 |
+
<admin>
|
13 |
+
<children>
|
14 |
+
<system>
|
15 |
+
<children>
|
16 |
+
<config>
|
17 |
+
<children>
|
18 |
+
<cod translate="title">
|
19 |
+
<title>Cashondelivery by Zipcopde</title>
|
20 |
+
</cod>
|
21 |
+
</children>
|
22 |
+
</config>
|
23 |
+
</children>
|
24 |
+
</system>
|
25 |
+
</children>
|
26 |
+
</admin>
|
27 |
+
</resources>
|
28 |
+
</acl>
|
29 |
+
</config>
|
app/code/community/Mfp/Cod/etc/config.xml
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Mfp_Cod>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Mfp_Cod>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<cod>
|
11 |
+
<class>Mfp_Cod_Model</class>
|
12 |
+
</cod>
|
13 |
+
</models>
|
14 |
+
|
15 |
+
<helpers>
|
16 |
+
<cod>
|
17 |
+
<class>Mfp_Cod_Helper</class>
|
18 |
+
</cod>
|
19 |
+
</helpers>
|
20 |
+
</global>
|
21 |
+
<frontend>
|
22 |
+
<events>
|
23 |
+
<payment_method_is_active>
|
24 |
+
<observers>
|
25 |
+
<paymentfilter_payment_method_is_active>
|
26 |
+
<type>singleton</type>
|
27 |
+
<class>Mfp_Cod_Model_Observer</class>
|
28 |
+
<method>getCashOnDelvery</method>
|
29 |
+
</paymentfilter_payment_method_is_active>
|
30 |
+
</observers>
|
31 |
+
</payment_method_is_active>
|
32 |
+
</events>
|
33 |
+
</frontend>
|
34 |
+
</config>
|
app/code/community/Mfp/Cod/etc/system.xml
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<mfp_extensions>
|
5 |
+
<label>Cash On Delivery</label>
|
6 |
+
<sort_order>200</sort_order>
|
7 |
+
</mfp_extensions>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<cod translate="label">
|
11 |
+
<class>separator-top</class>
|
12 |
+
<label>Cashondelivery by Zipcopde</label>
|
13 |
+
<tab>mfp_extensions</tab>
|
14 |
+
<frontend_type>text</frontend_type>
|
15 |
+
<sort_order>10</sort_order>
|
16 |
+
<show_in_default>1</show_in_default>
|
17 |
+
<show_in_website>1</show_in_website>
|
18 |
+
<show_in_store>1</show_in_store>
|
19 |
+
<groups>
|
20 |
+
<cod translate="label">
|
21 |
+
<label>Setting</label>
|
22 |
+
<frontend_type>text</frontend_type>
|
23 |
+
<sort_order>10</sort_order>
|
24 |
+
<show_in_default>1</show_in_default>
|
25 |
+
<show_in_website>1</show_in_website>
|
26 |
+
<show_in_store>1</show_in_store>
|
27 |
+
<fields>
|
28 |
+
<enable translate="label">
|
29 |
+
<label>Enable Extension</label>
|
30 |
+
<frontend_type>select</frontend_type>
|
31 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
32 |
+
<sort_order>10</sort_order>
|
33 |
+
<show_in_default>1</show_in_default>
|
34 |
+
<show_in_website>1</show_in_website>
|
35 |
+
<show_in_store>1</show_in_store>
|
36 |
+
</enable>
|
37 |
+
<zipcode translate="label">
|
38 |
+
<label>Zipcodes</label>
|
39 |
+
<frontend_type>textarea</frontend_type>
|
40 |
+
<sort_order>30</sort_order>
|
41 |
+
<show_in_default>1</show_in_default>
|
42 |
+
<show_in_website>1</show_in_website>
|
43 |
+
<show_in_store>1</show_in_store>
|
44 |
+
<comment><![CDATA[Add Zipcodes in Comma separated. Ex: 10001,10002,10003]]></comment>
|
45 |
+
</zipcode>
|
46 |
+
</fields>
|
47 |
+
</cod>
|
48 |
+
</groups>
|
49 |
+
</cod>
|
50 |
+
</sections>
|
51 |
+
</config>
|
app/etc/modules/Mfp_Cod.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Mfp_Cod>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<version>1.0.0</version>
|
8 |
+
</Mfp_Cod>
|
9 |
+
</modules>
|
10 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Mfp_Cod</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Zipcode based Cash on Delivery payment method at checkout
|
10 |
+
</summary>
|
11 |
+
<description>Zipcode based Cash on Delivery payment method at checkout
|
12 |
+
</description>
|
13 |
+
<notes>Zipcode based Cash on Delivery payment method at checkout
|
14 |
+
</notes>
|
15 |
+
<authors><author><name>harpreet</name><user>harpreet</user><email>harpreetsinghphp@gmail.com</email></author></authors>
|
16 |
+
<date>2015-10-27</date>
|
17 |
+
<time>15:47:45</time>
|
18 |
+
<contents><target name="magecommunity"><dir name="Mfp"><dir name="Cod"><dir name="Helper"><file name="Data.php" hash="527a41a2cd6d55794045eb72e0de5b6d"/></dir><dir name="Model"><file name="Observer.php" hash="87d7f78a6aee69c93eeaa67d843973a7"/></dir><dir name="etc"><file name="adminhtml.xml" hash="8a25ac338a12c60a4ad0db1cb0b7395f"/><file name="config.xml" hash="1691c51e9b9afd6056a723f26b84a818"/><file name="system.xml" hash="59cae795369d4b2ba5fe4878ce402ef5"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mfp_Cod.xml" hash="a9b8f5e99c69ea35b219d201fce95fb3"/></dir></target></contents>
|
19 |
+
<compatible/>
|
20 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
21 |
+
</package>
|