问题
I am using magento for a time now. I wanted to know is it possible to enable Cash On Delivery option for admin use only. I want to use it as Store Pickup...
So this way manual orders can be only created in admin panel for those who want Store Pickup.
I dont want this to be shown in Magento Frontend Store.
Can you all help me out ???
回答1:
There are a number of ways to achieve this, but they require a familiarity with the Magento ecosystem. I would discourage using CSS to hide it from the end user, because someone that was slightly knowledgeable about CSS could easily unhide it and gain free access to purchase your products.
I also suggest not override core files (even if you are not editing them), as that will cause upgrade problems in the future.
The solid way:
My favorite method would be to enable to Check/Money order method, and create yourself a small module, like this. Neither of the previous considerations make any effect here.
/app/etc/modules/Company_Module.xml
<?xml version="1.0"?>
<config>
<modules>
<Company_Module>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Payment/>
</depends>
</Company_Module>
</modules>
</config>
/app/code/local/Company/Module/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Company_Module>
<version>0.0.1</version>
</Company_Module>
</modules>
<global>
<models>
<Company_Module>
<class>Company_Module_Model</class>
</Company_Module>
</models>
<events>
<payment_method_is_active>
<observers>
<company_module>
<type>singleton</type>
<class>Company_Module/Observer</class>
<method>paymentMethodIsActive</method>
</company_module>
</observers>
</payment_method_is_active>
</events>
</global>
</config>
/app/code/local/Company/Module/Model/Observer.php
<?php
class Company_Module_Model_Observer
{
public function paymentMethodIsActive($observer)
{
$instance = $observer->getMethodInstance();
$result = $observer->getResult();
if ($instance->getCode() == "checkmo") {
if (Mage::app()->getStore()->isAdmin()) {
$result->isAvailable = true;
} else {
$result->isAvailable = false;
}
}
}
}
回答2:
To hide in the front end, you must be set to false to the protected $_canUseCheckout = false; to your payment method.
To display in the admin end, you must be set to true to the protected $_canUseInternal = true; to your payment method.
回答3:
A very easy way, but maybe not the cleanest way you could do this:
- Enable Cash On Delivery for the store.
- Hide it from the front end using CSS.
Using CSS to achieve this would hide the option from the general public, but would not prevent a web developer who is knowledgable with CSS to go find it and place a cash on delivery order - though I cant think of any reason someone would purposely do this since they won't achieve much by placing the order.
EDIT :
To hide Cash On Delivery add this to your CSS:
input#p_method_cashondelivery { display: none; }
label[for=p_method_cashondelivery] { display: none; }
来源:https://stackoverflow.com/questions/14022921/cash-on-delivery-activated-admin-only-not-frontend-enabled-magento