【发布时间】:2018-06-06 09:28:51
【问题描述】:
我正在使用 magento 1.9 我有两种运输方式货到付款,另一种是预付。 如果客户选择预付运费或 如果客户选择预付送货方式--> 货到付款方式必须像没有选择一样隐藏
请尽快通知我
【问题讨论】:
标签: php magento payment shipping
我正在使用 magento 1.9 我有两种运输方式货到付款,另一种是预付。 如果客户选择预付运费或 如果客户选择预付送货方式--> 货到付款方式必须像没有选择一样隐藏
请尽快通知我
【问题讨论】:
标签: php magento payment shipping
您需要修改目录 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 代码。
【讨论】: