0

How can I disable all the payment options, when the cart value is 0. I heard about zero subtotal checkout, but when the cart value is 0, all the payment methods appear along with the zero subtotal checkout and if someone clicks on any other payment options, error comes.

So is there any way where I can disable all the payment options when the cart value comes to zero. please tell step by step as I am super new in Magento.

0

Megento have this option in admin section.

Go to System > Configuration > Payment Methods > Zero Subtotal Checkout

check this reference link

http://docs.magento.com/m1/ce/user_guide/payment/zero-subtotal-checkout.html

  • I used this last time, but even when the cart value is 0, it still shows other payment options and if you choose any of those then we get an error. – Pratik Apr 5 '18 at 9:35
  • another option you can hide with jquery, if total vaue is 0 then other option should be hide. – Wajahat Bashir Apr 5 '18 at 10:09
  • But how, can you tell me those steps. – Pratik Apr 5 '18 at 12:38
0

Do this using event observer.....create an event on payment_method_is_active and depends on grandtoatal group disable and enable payment method.

Enable Zero Subtotal Checkout : System > Configuration > Payment Methods > Zero Subtotal Checkout

check this reference link

Payment method - Zero Subtotal Checkout - hide all others

Create config.xml under app/code/local/Bh/ZeroSubtotalpaymentmethod/etc. code of this file is

<?xml version="1.0" ?>
<config>
<modules>
    <Bh_ZeroSubtotalpaymentmethod>
        <version>1.0.1</version>
    </Bh_ZeroSubtotalpaymentmethod>
</modules>
<global>
    <models>
        <zerosubtotalpaymentmethod>
        <class>Bh_ZeroSubtotalpaymentmethod_Model</class>
        </zerosubtotalpaymentmethod>
    </models>
</global>
<frontend>
    <events>
        <payment_method_is_active>
            <observers>
                <paymentfilter_payment_method_is_active>
                    <type>singleton</type>
                    <class>zerosubtotalpaymentmethod/observer</class>
                    <method>filterpaymentmethod</method>
                </paymentfilter_payment_method_is_active>
            </observers>
        </payment_method_is_active>
    </events>
</frontend>

Create Observer.php under app/code/local/Bh/ZeroSubtotalpaymentmethod/Model/ code is

<?php
class Bh_ZeroSubtotalpaymentmethod_Model_Observer {

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

$quote = $observer->getEvent()->getQuote();
/* this condition will disable rest of  payment method if grandtotal  <= 0 */
    if($method->getCode()!='free' && (Mage::app()->getStore()->roundPrice($quote->getGrandTotal())<=0))
    {   

        $result = $observer->getEvent()->getResult();   
        $result->isAvailable = false;

        return;
    }
/* this condtion prevent zero payment to display when grandtotal greater then 0 */
    if($method->getCode()=='free'){
        $quote = $observer->getEvent()->getQuote();
        if(Mage::app()->getStore()->roundPrice($quote->getGrandTotal())>0){
        $result = $observer->getEvent()->getResult();   
        $result->isAvailable = false;
        return;
        }
    }
    return;
  }
}
  • The link you share me, i didn't understand how it is done. can you please explain me in detail. – Pratik Apr 5 '18 at 9:34
  • @Pratik , check my updated answer. – Chirag Rajput Apr 5 '18 at 11:32
  • Hi, Chirag i tried the exact steps that you provided, but it still work. I still get other payment options when the cart value is 0. :( – Pratik Apr 5 '18 at 12:37
  • @Pratik Replace "free" with Zero Payment method code and try please – Chirag Rajput Apr 5 '18 at 13:06
  • What do you means by Zero Payment method code, sorry i am very new. so its hard for me to understand. – Pratik Apr 6 '18 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.