[英]Disabling payment module in Hookpayment function PRESTASHOP
選擇某些運營商(ID為8)時,我需要隱藏COD付款模塊。 Ive決定使用hookpayment函數檢查運營商ID,如果ID匹配則返回false。 我的hookpayment函數看起來像這樣
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的載體,COD方法仍然存在。您能幫我調試或找到解決方案嗎? 謝謝
$ cart對象不存在,因此$ cart-> id_carrier永遠不會等於8。您需要使用(int)$ params ['cart']代替$ cart。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.