Set minimum order amount for a payment method only in frontend for a store
-
12-12-2019 - |
Domanda
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
Soluzione
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.
Altri suggerimenti
$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;}}
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?