magento payment methods - enable for admin only
I need to enable the Cheque / Money Order payment method to enable our clients 开发者_如何学运维call centre team to create orders in the admin.
However we do not want customers buying online through the website to use this payment method.
Does anybody know how I might be able to do this?
Regards, Fiona
Two options:
1)
Override (using never change the original or add a /local/Mage/ override) the payment method (or just modify it if it's your own method), and add this:
protected $_canUseInternal = true;
protected $_canUseCheckout = false;
protected $_canUseForMultishipping = false;
2)
Create an observer on the frontend for "payment_method_is_active" event, and set to inactive the methods you don't want to show on the frontend:
<config>
<frontend>
<events>
<payment_method_is_active>
<observers>
... your observer here
public function your_observer($event){
$method = $event->getMethodInstance();
$result = $event->getResult();
if( $method should not be active in frontend ){
$result->isAvailable = false;
}
}
If you enable it in the global config-view and then disable it for your store/website view does that work? (Don't have a system handy to test...)
I tried Enriques solution # 1 to hide one payment method in frontend, only to show it in admin:
protected $_canUseInternal = true;
protected $_canUseCheckout = false;
protected $_canUseForMultishipping = false;
Seems to work fine when I am testing, and in general..
BUT.. I still sometimes get normal orders that uses my "hidden" payment method. Like Magento sometimes fails to use the piece of code above.
Anyone knows why this happens, and how to avoid?
Thanks
-Espen
Check config setting like below example.
If you want to check that customcarrier_fastways
is active then use code similar to this:
$shippingMethod="customcarrier_fastways";
$shippingMethodActive= Mage::getStoreConfig('carriers/'.$shippingMethod.'/active', Mage::app()->getStore()->getId());
$showAtFront= Mage::getStoreConfig('carriers/'.$shippMethod.'/showatfront', Mage::app()->getStore()->getId());
if($shippingMethodActive && $showAtFront){
// do something here...
}
While variables is defined in xml file as below:
<carriers translate="label" module="shipping">
<groups>
<customcarrier_fastways translate="label">
<label>Fastways</label>
<frontend_type>text</frontend_type>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<active translate="label">
<label>Enabled</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</active>
<showatfront translate="label">
<label>Show on checkout</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</showatfront>
</fields>
</customcarrier_fastways>
</groups>
</carriers>
Just found this, looks like it's what you're after: http://www.magentocommerce.com/boards/viewthread/38765/P15/
精彩评论