magento disable payment method programmatically

magento disable payment method programmatically

In this post we will show you magento disable payment method programmatically, hear for magento disable payment method programmatically we will give you demo and example for implement.

how to magento disable payment method programmatically
how to magento disable payment method programmatically

Magento extend confronted a circumstance in which the Payment techniques should have been enabled/disabled progressively in light of the a few conditions. wrapping up the arrangement in this article. Magento gives the isAvailable() technique in the model of the every installment strategy. This technique tell Magento if the comparing installment strategy is accessible or not for checkout.

Dynamically Enable/Disable Payment Method in Magento

Assume we need to do it for ‘PurchaseOrder’ installment technique. At that point go to the model document ‘app/code/center/Mage/Payment/Model/Method/Purchaseorder.php’. In any case, the isAvailable() technique is absent there. It is by and large accessible for other installment strategies. So we will revise the model record in our custom module.

Step 1 # Open the config.xml in your custom module do following changes:


<config>
	<global>
		<!-- Rewrite the Purchase order model -->
		<payment>
			<rewrite>
				<method_purchaseorder>Onlinecode_Yourmodule_Model_Method_Purchaseorder</method_purchaseorder>
			</rewrite>
		</payment>
	</global>
</config>

Step 2 # Create the new Model file in your custom module at the location: app/code/local/Onlinecode/Yourmodule/Model/Method/Purchaseorder.php. In this file create the isAvailable() method as:

<?php
class Onlinecode_Yourmodule_Model_Method_Purchaseorder extends Mage_Payment_Model_Method_Purchaseorder
{
	/**
	* Check if use payment method is available 
	* @param type $quote
	* @return boolean
	*/
	public function isAvailable($quote = null) 
	{
		// Here write your logic for enabling or disabling the method
		// if this for enabling
		return true;
		// else for disabling
		rerturn false;
	}
}

And this is all. All custom logic goes in the isAvailable() methos for enabling or disabling the payment method.

Hope this code and post will helped you for implement magento disable payment method programmatically. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve onlincode. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs onlincode.org

Leave a Comment

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

  +  75  =  84

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US