15/08/2022
We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
To disable the payment method, open the config.xml file and add the following code:
<global>
...
<events>
<payment_method_is_active>
<observers>
<disable_paymentmethod>
<class>Vendor_Extension_Model_Observer</class>
<method>paymentMethodIsActive</method>
</disable_paymentmethod>
</observers>
</payment_method_is_active>
</events>
...
</global>
The below code should be added to the Observer.php:
<?php
class VendorName_ModuleName_Model_Observer {
public function paymentMethodIsActive(Varien_Event_Observer $observer) {
$method = $observer->getMethodInstance();
if ($method->getCode() == 'payment_method_code') {
if (condition) {
$result = $observer->getResult();
$result->isAvailable = false;
}
}
}
}
If you are looking for Magento Developers, visit Magento Web Agency.