Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Filtering Payment method for Cash on Delivery by Zip/Pin Code
 
hrm143
Jr. Member
 
Total Posts:  12
Joined:  2011-12-08
 

Hello,
I really dont have a technical knowledge if someone can help me with a solution.

I’m looking for a new features with Cash On Delivery implementation (COD). Though i already have a COD module already running as the payment option but cannot filter based on zip/postcode entered.

So I want to find a solution working in the following way.

- I should be able select/import/enter zip/Pincode from the admin area which are serviceable in the area as per specific country selected.
- So I should able to add serviceable zip/postcodes. zipcodes in this list will be called serviceable and others not in the list non-serviceable.

So if the customer’s shipping address input pincode is available in the lists of serviceable area, the customer will see the active radio button of COD on the checkout page. Though if the shipping address pin code entered by customer is non-serviceable, the COD radio button will be dead or inactive and the customer will see a message ‘This mode of payment is not available for your shipping address’.

I WANT TO FILTER THE COD method work based on Zip/Pincode inputs (COD method Availalable/not available automatically)

Any alternate option related to this function will be of great help.

Wish to run this function with a OneStep check out option module…
[size=3]
Please refer the screen shoots(example of a working module) the function seen from one of the website similarly I want to have ...PLEASE HELP smile[/size]

Image Attachments
cod-disabled.JPGcod-enabled.JPG
 
Magento Community Magento Community
Magento Community
Magento Community
 
hrm143
Jr. Member
 
Total Posts:  12
Joined:  2011-12-08
 

Somebody please help? I just need to modify the existing Cash on Delivery Module.....
http://www.magentocommerce.com/magento-connect/cashondelivery.html
or
this module
http://www.magentocommerce.com/magento-connect/ig-cashondelivery.html

Attached the screen shot again how it should look like in Admin panel.

Enter Zip/PostCode Field:
“Please enter the Pin/Zip Code for which COD is allowed comma suparated”

Image Attachments
Cod-admin.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
vasuscoin
Member
 
Avatar
Total Posts:  34
Joined:  2011-11-20
India
 

I got this extension....

http://www.ecommerce.infodesires.com/magento-modules/cash-on-delivery-with-restricted-zip-pin-codes.html

 
Magento Community Magento Community
Magento Community
Magento Community
 
mailamiton
Jr. Member
 
Total Posts:  7
Joined:  2011-06-30
 

Hi,

Can you confirm if this works on 1.7 and above ??

 
Magento Community Magento Community
Magento Community
Magento Community
 
InfoDesires
Jr. Member
 
Avatar
Total Posts:  12
Joined:  2011-07-31
UK
 

Yes that work for 1.7.0.2 as well.

 
Magento Community Magento Community
Magento Community
Magento Community
 
shopcart2424
Jr. Member
 
Total Posts:  2
Joined:  2012-11-23
 

Did you get the solution?

 
Magento Community Magento Community
Magento Community
Magento Community
 
vkt005
Jr. Member
 
Total Posts:  4
Joined:  2011-05-29
 

Follow the given step you will be able to Acheive COD (Cash on delivary) by Zip/Post code

STEP 1-
-----------------------------------------------------------------------------------------------
Go To file app\code\core\Mage\Payment\etc\system.xml
Line no Nearly 596 under the <cashondelivery translate="label"> xml Node
Add code

<pincode translate="label">
                          <
label>pincode</label>
                            <
frontend_type>textarea</frontend_type>
                            <
sort_order>63</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
</
pincode>
-------------------------------------------------------------------------------------------------------------------
STEP 2-
Go To File app\code\core\Mage\Payment\Model\Method\Cashondelivery.php
Ad following Function in Class Mage_Payment_Model_Method_Cashondelivery before closing tag }
/**
* Get All postcode allowed for COD cash on delivary module
* @return array
*/
    public function getCODPincodes(){
        $pincodes 
Mage::getStoreConfig('payment/cashondelivery/pincode');
        
$results=explode(',',$pincodes);
        
$postcodes=array();
        if(
count($results)>0){
        
foreach($results as $result){
        $postcodes[] 
$result;
        
}}
        
return $postcodes;
    
}
STEP- 3
----------------------------------------------------------------------------------------------
Go To File app\code\core\Mage\Payment\Block\Form\Container.php
Ad following Function in Class Mage_Payment_Block_Form_Container before closing tag }
/**
     * Chcek Payment Method is COD(cash on delivary) and Shiping Pin code is available in list
     * @return boolean
     */
    protected function checkmethodbypin($method){
        
if($method->getCode() == "cashondelivery"){
           $shippingPincode 
$this->getQuote()->getShippingAddress()->getData('postcode');
           
$pincodesMage::getModel('payment/method_cashondelivery')->getCODPincodes();
           if(
in_array($shippingPincode$pincodes)) return true ;else return false;
          
}
    }

Step 4-
------------------------------------------------------------------------------------------------------
Go to File app\design\frontend\base\default\template\checkout\onepage\payment\methods.phtml
Find code Near Line 43

<dt>
    
<?php if(!$oneMethod): ?>
        
<input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->htmlEscape($_method->getTitle()) ?>"  onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
    
<?php else: ?>
        
<span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /></span>
        
<?php $oneMethod $_code?>
    <?php 
endif; ?>
        
<label for="p_method_<?php echo $_code ?>"><?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> 
<?php
 
echo $this->getMethodLabelAfterHtml($_method?></label>
    </
dt>
-------------------------------
//Replace with
<?php if(($_method->getCode() == "cashondelivery")&& !$this->checkmethodbypin($_method)){?>
    
<dt><label style="color:red">COD (Cash on Delivarynot available on this pin code</label></dt>
    
<?php }else{?>
    
<dt>
    
<?php if(!$oneMethod): ?>
        
<input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->htmlEscape($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
    
<?php else: ?>
        
<span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /></span>
        
<?php $oneMethod $_code?>
    <?php 
endif; ?>
        
<label for="p_method_<?php echo $_code ?>"><?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> <?php echo $this->getMethodLabelAfterHtml($_method?></label>
    </
dt>
    
<?php } ?>
----------------------------
Image Attachments
COD-BY-Pincode.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
jatinguliani
Jr. Member
 
Total Posts:  4
Joined:  2013-03-19
 
vkt005 - 04 October 2013 12:46 AM

Follow the given step you will be able to Acheive COD (Cash on delivary) by Zip/Post code

STEP 1-
-----------------------------------------------------------------------------------------------
Go To file app\code\core\Mage\Payment\etc\system.xml
Line no Nearly 596 under the <cashondelivery translate="label"> xml Node
Add code

<pincode translate="label">
                          <
label>pincode</label>
                            <
frontend_type>textarea</frontend_type>
                            <
sort_order>63</sort_order>
                            <
show_in_default>1</show_in_default>
                            <
show_in_website>1</show_in_website>
                            <
show_in_store>1</show_in_store>
</
pincode>
-------------------------------------------------------------------------------------------------------------------
STEP 2-
Go To File app\code\core\Mage\Payment\Model\Method\Cashondelivery.php
Ad following Function in Class Mage_Payment_Model_Method_Cashondelivery before closing tag }
/**
* Get All postcode allowed for COD cash on delivary module
* @return array
*/
    public function getCODPincodes(){
        $pincodes 
Mage::getStoreConfig('payment/cashondelivery/pincode');
        
$results=explode(',',$pincodes);
        
$postcodes=array();
        if(
count($results)>0){
        
foreach($results as $result){
        $postcodes[] 
$result;
        
}}
        
return $postcodes;
    
}
STEP- 3
----------------------------------------------------------------------------------------------
Go To File app\code\core\Mage\Payment\Block\Form\Container.php
Ad following Function in Class Mage_Payment_Block_Form_Container before closing tag }
/**
     * Chcek Payment Method is COD(cash on delivary) and Shiping Pin code is available in list
     * @return boolean
     */
    protected function checkmethodbypin($method){
        
if($method->getCode() == "cashondelivery"){
           $shippingPincode 
$this->getQuote()->getShippingAddress()->getData('postcode');
           
$pincodesMage::getModel('payment/method_cashondelivery')->getCODPincodes();
           if(
in_array($shippingPincode$pincodes)) return true ;else return false;
          
}
    }

Step 4-
------------------------------------------------------------------------------------------------------
Go to File app\design\frontend\base\default\template\checkout\onepage\payment\methods.phtml
Find code Near Line 43
<dt>
    
<?php if(!$oneMethod): ?>
        
<input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->htmlEscape($_method->getTitle()) ?>"  onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
    
<?php else: ?>
        
<span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /></span>
        
<?php $oneMethod $_code?>
    <?php 
endif; ?>
        
<label for="p_method_<?php echo $_code ?>"><?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> 
<?php
 
echo $this->getMethodLabelAfterHtml($_method?></label>
    </
dt>
-------------------------------
//Replace with
<?php if(($_method->getCode() == "cashondelivery")&& !$this->checkmethodbypin($_method)){?>
    
<dt><label style="color:red">COD (Cash on Delivarynot available on this pin code</label></dt>
    
<?php }else{?>
    
<dt>
    
<?php if(!$oneMethod): ?>
        
<input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->htmlEscape($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
    
<?php else: ?>
        
<span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /></span>
        
<?php $oneMethod $_code?>
    <?php 
endif; ?>
        
<label for="p_method_<?php echo $_code ?>"><?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> <?php echo $this->getMethodLabelAfterHtml($_method?></label>
    </
dt>
    
<?php } ?>
----------------------------

Hi vkt005,
Thanks for posting your code. I have followed all the steps correctly but it is not working on the checkout page. I have listed the pin codes at the backend too under cash on delivery payment method. But it is not working. Can you please help me out.
Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
vkt005
Jr. Member
 
Total Posts:  4
Joined:  2011-05-29
 

Filtering Payment method for Cash on Delivery by Zip/Pin Code For Phoenix Cod Module

URL of module - http://www.magentocommerce.com/magento-connect/cashondelivery.html
Aleternative url of Formated code - https://www.evernote.com/shard/s324/sh/4246527d-2565-44c2-8915-578db6f40acb/2b8a12cfcc40f4ea914e2b8d2a4ca722

Steps Involved In order to Ad zip code functionality

STEP 1-
-----------------------------------------------------------------------------------------------
Go To file app\code\community\Phoenix\CashOnDelivery\etc\system.xml
under the <phoenix_cashondelivery translate="label" module="phoenix_cashondelivery"> xml Node
Add code

<pincode translate="label">
<label>pincode</label>
<frontend_type>textarea</frontend_type>
<sort_order>170</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</pincode>

-------------------------------------------------------------------------------------------------------------------
STEP 2-
Go To File app\code\community\Phoenix\CashOnDelivery\Model\CashOnDelivery.php
Ad following Function in class Phoenix_CashOnDelivery_Model_CashOnDelivery extends Mage_Payment_Model_Method_Abstract before closing tag }
/**
* Get All postcode allowed for COD cash on delivary module
* @return array
*/
public function getCODPincodes(){
$pincodes = Mage::getStoreConfig(’payment/phoenix_cashondelivery/pincode’);
$results=explode(’,’,$pincodes);
$postcodes=array();
if(count($results)>0){
foreach($results as $result){
$postcodes[] = $result;
}}
return $postcodes;
}

STEP- 3
----------------------------------------------------------------------------------------------
Go To File app\code\core\Mage\Payment\Block\Form\Container.php
Ad following Function in Class Mage_Payment_Block_Form_Container before closing tag }
/**
* Chcek Payment Method is COD(cash on delivary) and Shiping Pin code is available in list
* @return boolean
*/
protected function checkmethodbypin($method){
if($method->getCode() == “phoenix_cashondelivery"){
$shippingPincode = $this->getQuote()->getShippingAddress()->getData(’postcode’);
$pincodes= Mage::getModel(’Phoenix_CashOnDelivery_Model_CashOnDelivery’)->getCODPincodes();
if(in_array($shippingPincode, $pincodes)) return true ;else return false;
}
}

Step 4-
------------------------------------------------------------------------------------------------------
Go to File app\design\frontend\base\default\template\checkout\onepage\payment\methods.phtml

<dt>
<?php if(!$oneMethod): ?>
<input id="p_method_<?php echo $_code ?>” value="<?php echo $_code ?>” type="radio" name="payment[method]" title="<?php echo $this->htmlEscape($_method->getTitle()) ?>” onclick="payment.switchMethod(’<?php echo $_code ?>’)"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
<?php else: ?>
<span class="no-display"><input id="p_method_<?php echo $_code ?>” value="<?php echo $_code ?>” type="radio" name="payment[method]" checked="checked" class="radio" /></span>
<?php $oneMethod = $_code; ?>
<?php endif; ?>
<label for="p_method_<?php echo $_code ?>"><?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?>
<?php
echo $this->getMethodLabelAfterHtml($_method) ?></label>
</dt>
-------------------------------
//Replace with
<?php if(($_method->getCode() == "phoenix_cashondelivery")&& !$this->checkmethodbypin($_method)){?>
<dt><label style="color:red">COD (Cash on Delivary) not available on this pin code</label></dt>
<?php }else{?>
<dt>
<?php if(!$oneMethod): ?>
<input id="p_method_<?php echo $_code ?>” value="<?php echo $_code ?>” type="radio" name="payment[method]" title="<?php echo $this->htmlEscape($_method->getTitle()) ?>” onclick="payment.switchMethod(’<?php echo $_code ?>’)"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
<?php else: ?>
<span class="no-display"><input id="p_method_<?php echo $_code ?>” value="<?php echo $_code ?>” type="radio" name="payment[method]" checked="checked" class="radio" /></span>
<?php $oneMethod = $_code; ?>
<?php endif; ?>
<label for="p_method_<?php echo $_code ?>"><?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>
</dt>
<?php } ?>

 
Magento Community Magento Community
Magento Community
Magento Community
 
setubridge
Jr. Member
 
Avatar
Total Posts:  1
Joined:  2014-02-25
India
 

There is free extension available for that

http://www.magentocommerce.com/magento-connect/zipcode-based-cash-on-delivery-1.html

it works like charm

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top