Php 在Hookpayment功能PRESTASHOP中禁用付款模块
我需要在选择某个运营商(ID为8)时隐藏C.O.D.支付模块。我决定使用hookpayment功能检查承运人ID,如果ID匹配,则返回false。我的付款函数如下所示Php 在Hookpayment功能PRESTASHOP中禁用付款模块,php,module,smarty,prestashop,payment,Php,Module,Smarty,Prestashop,Payment,我需要在选择某个运营商(ID为8)时隐藏C.O.D.支付模块。我决定使用hookpayment功能检查承运人ID,如果ID匹配,则返回false。我的付款函数如下所示 public function hookPayment($params) { if (!$this->active) return ; global $smarty; // Check if cart has product download
public function hookPayment($params)
{
if (!$this->active)
return ;
global $smarty;
// Check if cart has product download
if ($this->hasProductDownload($params['cart']))
return false;
if ($cart->id_carrier == 8)
return false;
$smarty->assign(array(
'this_path' => $this->_path, //keep for retro compat
'this_path_cod' => $this->_path,
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/'
));
return $this->display(__FILE__, 'payment.tpl');
}
问题是,即使我选择ID为8的承运人,C.O.D.方法仍然存在。你能帮助我如何调试或找到解决方案吗?谢谢,由于$cart对象不存在,因此$cart->id\u carrier永远不会等于8。您需要使用(int)$params['cart']而不是$cart。可能$cart->id\u carrier不等于8,但还有其他值。请遵循此答案,以便接受