Disallow invoice option when organisation in billing post array is not set to 1

I have a custom value 'organisation_type' that will be 1,2 or 3. If this is 1 I want to modify the existing code in the PurchaseOrder.php below to set canUseCheckout to true.

so for instance in the billing Post array on the checkout - if billing['organisation_type'] == 1, then canUseCheckout should be set to true otherwise set to false;

Can anyone suggest how this is done looking at my existing code? Is it possible using getQuote() to get all the values from the billing post array?

DisallowInvoice config.xml

<?xml version="1.0"?>

class AA_DisallowInvoice_Model_Payment_Method_Purchaseorder extends Mage_Payment_Model_Method_Purchaseorder {

public function canUseCheckout()
    return $this->_canUseCheckout;

 * If the shipping address is different to the billing address, prevent use within checkout
protected function _shippingAddressCheck()
    if (! Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getSameAsBilling()) {
        $this->_canUseCheckout = false;



Zabs,used the isAvailable function ,which is better solution:

public function isAvailable($quote = null)
        return parent::isAvailable($quote) && !empty($quote)
            && in_array(1,$quote->getBillingAddress()->getData('organisation_type'));

if this logic is not working .try below link https://stackoverflow.com/questions/24567979/set-payment-method-cash-on-delivery-on-particular-state-only/24568989

Just change code of filterpaymentmethod function

class Bh_ZeroSubtotalpaymentmethod_Model_Observer {
 public function filterpaymentmethod(Varien_Event_Observer $observer) {
            /* call get payment method */
        $method = $observer->getEvent()->getMethodInstance();

            $quote = $observer->getEvent()->getQuote();
            $BillAddress = $quote->getBillingAddress();
            $result = $observer->getEvent()->getResult();   
            $result->isAvailable = true;
            $result = $observer->getEvent()->getResult();   
            $result->isAvailable = false;

Similar questions

robots.txt Disallow: /checkout/ still myweb.com/checkout/cart/ Google still crawls
robots.txt still, myweb.com/checkout/cart/ Google still crawls, I have set robots from admin. Thank You!
Magento 1 remove Disallow: /tag/ in robot.txt
My robots.txt contain any code and this code Disallow: /tag/ Is it okay for SEO to delete this command?
Set Default Billing Address as Billing Address via knockout on checkout page
The Checkout page is currently loading Shipping address as billing and shipping address. I want to load default billing address on checkbox click and set it to order before save. I dont know how to do it. I tried and found a way to get default billing address through This line of code returns default billing address now i want to set it to order in...
Load invoice by invoice id and invoice increment id
I have an invoice id or an invoice increment id, is there a way to load an invoice using these?
How to Post data from ajax get by post not working in postman?
Below is my code when I try to post data but not working URL is http://localhost/test1/modulename/login/request my ajax code for javascript Below is my controller code, use Magento\Framework\App\RequestInterface; class Test extends \Magento\Framework\App\Action\Action { } So please help me. thanks I updated by exact controller code so hope not it w...
Blog Post Title and Read more Button doesn't link to post
I'm using Magento 1.9 and have a blog setup but whenever i create a post the post itself doesn't link to a separate page containing the full post instead of redirects to the index page. See below for an example: http://website.co.uk/blog the post should be linked to the following link: http://website.co.uk/blog/test but as you can see it says 404 N...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.