Seirios Posted November 26, 2016 Share Posted November 26, 2016 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 Link to comment Share on other sites More sharing options...
Krystian Podemski Posted November 26, 2016 Share Posted November 26, 2016 Just change $product['id_product'] to $product['id_product_attribute'] and this $disable_cod = array(7, 20, 22); into this $disable_cod = array(1,2); Link to comment Share on other sites More sharing options...
Seirios Posted November 27, 2016 Author Share Posted November 27, 2016 Dear Krystian Thank you for your solution. I seems to be working on my test site but not on my normal site (COD keeps showing no matter what). Both sites are identical (P.S 1.6.0.9) On my normal site i only have Greek language installed with language ID 2, English language ID 1 is deleted. On my test site i have both English ID 1 and Greek ID 2. Maybe the language ID is the problem? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now