如何隐藏COD和在线支付等付款方式,选择magento 1.9中的“货到付款”或“预付款”等运输方式

时间:2018-06-06 09:28:51

标签: php magento payment shipping

我使用的是magento 1.9 我有两种送货方式货到付款,另一种是预付款。 如果客户选择预付运费或者我想隐藏COD付款方式 如果客户选择预付运费方式 - >必须隐藏COD付款方式,如无选择

enter image description here

请尽快通知我

enter image description here

1 个答案:

答案 0 :(得分:0)

您需要修改目录app / code / core / Mage / Payment / Model / Method(如Cashondelivery.php)中的付款方式模型类文件,以获取货到付款方式。要覆盖核心文件,您可以创建新模块以扩展这些付款方式类,或将这些文件复制到本地文件夹,例如应用程序/代码/本地/法师/支付/型号/法。然后,您需要在这些文件中添加新功能以检查选定的送货方式,并根据您可以显示/隐藏特定的付款方式。我在下面的代码中添加了以下功能:Cash On Delivery方法如下: - 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代码替换它们。