【发布时间】:2011-01-06 08:05:21
【问题描述】:
我需要启用支票/汇票付款方式,以使我们的客户呼叫中心团队能够在管理员中创建订单。
但是,我们不希望通过网站在线购买的客户使用这种付款方式。
有人知道我是怎么做到的吗?
问候, 菲奥娜
【问题讨论】:
标签: magento
我需要启用支票/汇票付款方式,以使我们的客户呼叫中心团队能够在管理员中创建订单。
但是,我们不希望通过网站在线购买的客户使用这种付款方式。
有人知道我是怎么做到的吗?
问候, 菲奥娜
【问题讨论】:
标签: magento
两个选项:
1)
覆盖(使用永远不要更改原始或添加 /local/Mage/ 覆盖)付款方式(或者如果它是您自己的方式,则只需修改它),并添加以下内容:
protected $_canUseInternal = true;
protected $_canUseCheckout = false;
protected $_canUseForMultishipping = false;
2)
在前端为“payment_method_is_active”事件创建一个观察者,并将你不想在前端显示的方法设置为非活动:
<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;
}
}
【讨论】:
如果您在全局配置视图中启用它,然后为您的商店/网站视图禁用它,这是否有效? (没有方便测试的系统...)
【讨论】:
我尝试了 Enriques 解决方案 #1 在前端隐藏一种付款方式,只在管理员中显示:
protected $_canUseInternal = true;
protected $_canUseCheckout = false;
protected $_canUseForMultishipping = false;
我在测试时似乎工作正常,而且总的来说......
但是.. 我有时仍然会收到使用我的“隐藏”付款方式的正常订单。就像 Magento 有时无法使用上面的代码。
任何人都知道为什么会发生这种情况,以及如何避免?
谢谢
-埃斯彭
【讨论】:
检查配置设置,如下例所示。
如果您想检查customcarrier_fastways 是否处于活动状态,请使用类似以下的代码:
$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...
}
虽然变量在xml文件中定义如下:
<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>
【讨论】:
刚找到这个,看起来就是你想要的: http://www.magentocommerce.com/boards/viewthread/38765/P15/
【讨论】: