1

I need to set the minimum order amount for a purchase order payment type only in the frontend for a particular store.

I used system/configuration/payment method/custom payment ->set minimum order to 100 for that store in the admin panel.

But this filter gets applied even when an order is placed from the admin side

I need the minimum order amount filtered only when an order is placed from the admin side.

Any thoughts will be really appreciated.

Thanks

2

I created this module to enable/disable a certain method of payment when a condition applies (in this case, to enable Money order only in the admin). You can fork it and modify it as you want to match the criteria you need. Key is in the Observer.php file where the logic you need to modify resides.

|improve this answer|||||
  • I added a new field named 'Enable filter in admin' in the store config for Purchase order and used an observer to monitor the payment event and based on the values set in the store config i show the payment method when an order is being placed in the admin. Thanks for pointing me to right direction. – Magento_Newbie Apr 3 '15 at 21:06
  • Amazing! Fork the extension and publish it for the community if you have some time! – mbalparda Apr 4 '15 at 0:26
  • Hi I am setting $result->isAvailable = true, and found while debugging that it is setting the paymethod to true but still the payment is not getting displayed. – Magento_Newbie Apr 6 '15 at 20:49
0

$event= $observer->getEvent();
$method= $event->getMethodInstance();
$result= $event->getResult();
$quoteObj=Mage::getSingleton('checkout/session')->getQuote();
$totals = $quoteObj->getTotals(); //Total object
$subtotal = round($totals["subtotal"]->getValue());

//use business logic .below am disabling the payment method if cart subtotal is less than 250

if($subtotal<=250){ $cardonly = true; //set message if subtotal <250$ in cart if($method->getName() == "checkmo"){
$result->isAvailable = false;}}

|improve this answer|||||
  • please dont add the direct code, just add atleast one bit of line of explanation in words. – Teja Bhagavan Kollepara Mar 22 '17 at 5:02
0

I found while debugging that it is setting the payment method to true but still the payment is not getting displayed. My code is as follows

public function poPaymentFilterIsActive($observer)
{
    $instance = $observer->getMethodInstance();
    if ($instance->getCode() == "purchaseorder")
    {
        //if the Purchase order payment method is active
        if(Mage::getStoreConfig('payment/purchaseorder/active',$observer->getQuote()->getStoreId()) == "1")
        {
            $result = $observer->getResult();
            //If the order is being placed from the admin
            if ((Mage::app()->getStore()->isAdmin()))
            {
                //If the flag Apply Filters in Admin? is set to No
                if(Mage::getStoreConfig('payment/purchaseorder/admin_filter',$observer->getQuote()->getStoreId()) == "0")
                {
                    $result->isAvailable = true;
                }
            }
        }
    }
}

In config.xml

<events>
   <payment_method_is_active>
            <observers>
                <paymentfilter_payment_method_is_active>
                    <My_checkout>
                        <type>singleton</type>
                        <class>My_checkout/Observer</class>
                        <method>poPaymentFilterIsActive</method>
                    </My_checkout>
                </paymentfilter_payment_method_is_active>
            </observers>
        </payment_method_is_active>
    </events>

Am I doing something wrong?

|improve this answer|||||

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.