禁用仅付款选项的特定产品的货到付款-magento [英] Disable payment options-only cash on delivery for particular product-magento

查看:84
本文介绍了禁用仅付款选项的特定产品的货到付款-magento的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Magento 1.4.1.1,并且我想禁用某些产品的付款选项.我想仅显示某些产品的货到付款方式,而需要隐藏其他产品.

I am using Magento 1.4.1.1 and i want to disable payment option for some products.i want to show only Cash on Delivery method for some products and need to hide other.

有人在那里帮助我吗?我该如何管理?管理员是否有其他选择或需要自定义代码.如果可以,请给我提供代码和文件的确切路径吗?

Any body there to help me?How can i manage this?Is there any option at admin or do i need to customize the code.If so,could you please provide me a code and the exact path to the files?

先谢谢了.

推荐答案

一种不显眼的过滤付款方式的方法是为称为payment_method_is_active

的事件实现观察者 步骤
1>在config.xml中注册事件:"payment_method_is_active". 在app/code/local/MagePsycho/Paymentfilter/etc/config.xml中添加以下xml代码:

An unobtrusive way of filtering payment method is to implement observer for event called payment_method_is_active

Steps
1> Register the event: ‘payment_method_is_active’ in config.xml. Add the following xml code in app/code/local/MagePsycho/Paymentfilter/etc/config.xml:

...
<global>
    ...
    <events>
        <payment_method_is_active>
            <observers>
                <paymentfilter_payment_method_is_active>
                    <type>singleton</type>
                    <class>paymentfilter/observer</class>
                    <method>paymentMethodIsActive</method>
                </paymentfilter_payment_method_is_active>
            </observers>
        </payment_method_is_active>
    </events>
    ...
</global>
...

2>实施观察者模型 创建观察者文件:app/code/local/MagePsycho/Paymentfilter/Model/Observer.php并粘贴以下代码:

2> Implement the observer model Create observer file: app/code/local/MagePsycho/Paymentfilter/Model/Observer.php and paste the following code:

<?php
/**
 * @category   MagePsycho
 * @package    MagePsycho_Paymentfilter
 * @author     magepsycho@gmail.com
 * @website    http://www.magepsycho.com
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
    */
class MagePsycho_Paymentfilter_Model_Observer {

    public function paymentMethodIsActive(Varien_Event_Observer $observer) {
        $event           = $observer->getEvent();
        $method          = $event->getMethodInstance();
        $result          = $event->getResult();
        $currencyCode    = Mage::app()->getStore()->getCurrentCurrencyCode();


            if($someTrueConditionGoesHere){
                $result->isAvailable = true;
            }else{
                $result->isAvailable = false;
            }

    }

}

这篇关于禁用仅付款选项的特定产品的货到付款-magento的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆