【问题标题】:magento payment methods - enable for admin onlymagento 付款方式 - 仅对管理员启用
【发布时间】:2011-01-06 08:05:21
【问题描述】:

我需要启用支票/汇票付款方式,以使我们的客户呼叫中心团队能够在管理员中创建订单。

但是,我们不希望通过网站在线购买的客户使用这种付款方式。

有人知道我是怎么做到的吗?

问候, 菲奥娜

【问题讨论】:

标签: magento


【解决方案1】:

两个选项:

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;
      }

 }

【讨论】:

  • 这是最相关和最准确的评论。在开发新模块时,您还需要考虑未来的使用。您目前不允许模块的前端使用,但您将来可以。通过这种方式,您可以稍后在付款方式对客户可见时应用限制(订单价值、特殊物品等)。 Magento 中的观察者真的很强大,学习使用它们。
  • 如果你开发一个模块,你可以在后端为此添加一个选项。
【解决方案2】:

如果您在全局配置视图中启用它,然后为您的商店/网站视图禁用它,这是否有效? (没有方便测试的系统...)

【讨论】:

  • 感谢 Greg 的建议,但不幸的是,这并没有奏效。刚刚试了一下。
  • 这是个好建议,但不起作用,因为管理员订单创建屏幕将使用客户网站的配置范围
【解决方案3】:

我尝试了 Enriques 解决方案 #1 在前端隐藏一种付款方式,只在管理员中显示:

protected $_canUseInternal              = true;
protected $_canUseCheckout              = false; 
protected $_canUseForMultishipping      = false;

我在测试时似乎工作正常,而且总的来说......

但是.. 我有时仍然会收到使用我的“隐藏”付款方式的正常订单。就像 Magento 有时无法使用上面的代码。

任何人都知道为什么会发生这种情况,以及如何避免?

谢谢

-埃斯彭

【讨论】:

    【解决方案4】:

    检查配置设置,如下例所示。 如果您想检查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>
    

    【讨论】:

      【解决方案5】:

      刚找到这个,看起来就是你想要的: http://www.magentocommerce.com/boards/viewthread/38765/P15/

      【讨论】:

        猜你喜欢
        • 2012-12-10
        • 2016-01-29
        • 2012-03-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-10-17
        • 2014-09-17
        • 2015-02-27
        相关资源
        最近更新 更多