Create a small module to full fill the goal

1. /app/etc/modules/Techievolve_Codadminonly.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Techievolve_Codadminonly>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Payment/>
            </depends>
        </Techievolve_Codadminonly>
    </modules>
</config>

2. /app/code/local/Techievolve/Codadminonly/etc/config.xml

<?xml version="1.0"?>
<config>
<modules>
    <Techievolve_Codadminonly>
        <version>0.0.1</version>
    </Techievolve_Codadminonly>
</modules>

<global>
    <models>
        <Techievolve_Codadminonly>
            <class>Techievolve_Codadminonly_Model</class>
        </Techievolve_Codadminonly>
    </models>
    <events>
        <payment_method_is_active>
            <observers>
                <techievolve_codadminonly>
                    <type>singleton</type>
                    <class>Techievolve_Codadminonly/Observer</class>
                    <method>paymentMethodIsActive</method>
                </techievolve_codadminonly>
            </observers>
        </payment_method_is_active>
    </events>
</global>
</config>

3. /app/code/local/Techievolve/Codadminonly/Model/Observer.php

<?php

class Techievolve_Codadminonly_Model_Observer {
    
    public function paymentMethodIsActive($observer) {
        
        $instance = $observer->getMethodInstance();
        $result = $observer->getResult();

        if ($instance->getCode() == "cashondelivery") {
            if (Mage::app()->getStore()->isAdmin()) {
                $result->isAvailable = true;
            } else {
                $result->isAvailable = false;
            }
        }
    }
}


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *