Display Error Message Under Payment Method if COD is Not Available

cash-on-deliverypayment-methods

i am using this following code to restrict the "cash on delivery" payment method based on pin code.

/app/code/core/Mage/Payment/Model/Method/Cashondelivery.php 

Please check code here

now if cash on delivery payment method is not visible means i want to display "cod is not available" under

payment method.

please help me to find solution.

Best Answer

You referral link can only remove the code from payment list at check payment step.If you set error message at session (Mage::getSingleton('core/session')->addError(Mage::helper('payment')->__('Code is not avaliable.'))) on function isAvaliable it can be shown on next step.

According my concept it will be good idea to do something at methods.phtml where all payment method has been listing during the checkout.

<?php
$isCodeAvalibale=0;
    foreach ($this->getMethods() as $_method):
        $_code = $_method->getCode();
    if($_code =='cashondelivery'):
    $isCodeAvalibale=1;
    endif;
    endforeach;
if($isCodeAvalibale==0):
echo Mage::helper('payment')->__('Code is not avaliable.'));
endif;
?>