【问题标题】:How to hide payment method like COD and online payment ,with the selection of shipping methods like 'cash on delivery' or 'Prepaid ' in magento 1.9如何隐藏 COD 和在线支付等付款方式,在 magento 1.9 中选择“货到付款”或“预付”等运输方式
【发布时间】:2018-06-06 09:28:51
【问题描述】:

我正在使用 magento 1.9 我有两种运输方式货到付款,另一种是预付。 如果客户选择预付运费或 如果客户选择预付送货方式--> 货到付款方式必须像没有选择一样隐藏

请尽快通知我

【问题讨论】:

    标签: php magento payment shipping


    【解决方案1】:

    您需要修改目录 app/code/core/Mage/Payment/Model/Method 中的 Payment methods 模型类文件,如 Cashondelivery.php 用于货到付款方式。要覆盖核心文件,您可以创建一个新模块来扩展这些付款方式类或将这些文件复制到本地文件夹,例如应用程序/代码/本地/法师/付款/模型/方法。然后您需要在这些文件中添加一个新功能来检查所选的运输方式,并在此基础上显示/隐藏特定的付款方式。我在下面的代码中为货到付款方法添加了功能,如下所示:- Mage_Payment_Model_Method_Cashondelivery 类扩展了 Mage_Payment_Model_Method_Abstract {

    /**
     * Payment method code
     *
     * @var string
     */
    protected $_code  = 'cashondelivery';
    
    /**
     * Cash On Delivery payment block paths
     *
     * @var string
     */
    protected $_formBlockType = 'payment/form_cashondelivery';
    protected $_infoBlockType = 'payment/info';
    
    /**
     * Get instructions text from config
     *
     * @return string
     */
    public function getInstructions()
    {
        return trim($this->getConfigData('instructions'));
    }
    /* custom function to check shipping method and show/hide this payment methods*/
    public function isApplicableToQuote($quote, $checksBitMask)
    {
        if ($quote->getShippingAddress()->getShippingMethod() == 'flatrate_flatrate') {
            return false;
        }
        return parent::isApplicableToQuote($quote, $checksBitMask);
    }
    

    您需要找到自定义运输方式的运输方式代码,并在函数中将其替换为 flatrate_flatrate 代码。

    【讨论】:

    • 没用!!我使用两种送货方式 1. s_method_premiumrate_ONLINE_PAYMENT 2.s_method_premiumrate_cashondelivery 和付款方式:
    • 请给我网址。
    • 看起来您正在使用自定义扩展来运输和支付方式,因此需要修改它们的类。请告诉我他们的名字。
    • 扩展名是matrix rate premium extension
    猜你喜欢
    • 2018-11-09
    • 2015-05-31
    • 2017-12-15
    • 2012-03-01
    • 1970-01-01
    • 2013-02-15
    • 2014-12-23
    • 1970-01-01
    • 2015-12-01
    相关资源
    最近更新 更多