I would like to change the following code on cashondelivery.php so during checkout if a product has attribute id 1 and value id 2 (inside the attribute id 1) the Cash on delivery option is automatically disabled.
As attribute id 1 i have created a group called "Warehouse"
As value id 2 i have created a value called "China"
------------------------------------------------------------------------
public function hookPayment($params) {
if (!$this->active)
return ;
global $smarty;
global $cart;
// Check if cart has product download
if ($this->hasProductDownload($params['cart']))
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.'/'
));
// list of all products, which can't be bought by cash on delivery method
$disable_cod = array(7, 20, 22);
// get all cart products
$products = $cart->getProducts();
// default value - show module
$show = true;
// loop through all products and check if
foreach ($products as $product) {
if (in_array($product['id_product'], $disable_cod))
$show = false; // cash on delivery is not allowed, hide it
}
// hide module, if cart contains any product from $disable_cod array above
if (!$show)
return ;
else
return $this->display(__FILE__, 'payment.tpl');
}
----------------------------------------------------------------------------------
Thanks in advance