ostiepok Posted April 12, 2015 Share Posted April 12, 2015 Hello, i have four delivery methods and three payment methods. Problem is, that one of the delivery options cant be payed with one of the payment method. I couldnt found any existing solution to this or any documentation regarding this problem. I want to ask, if there is already some solution to this and if not, what are your suggestions because iam new to prestashop and the whole structure is still big questionmark for me. The delivery option is courier added through backoffice. Payment method is C.O.D. (Ive changed it a bit to behave as "payment on the spot") Link to comment Share on other sites More sharing options...
bellini13 Posted April 12, 2015 Share Posted April 12, 2015 I'm not aware of any configuration or module that would do this. However you could accomplish this by modifying the COD payment module, and updating the hookpayment function so that it would check for the selected carrier ID, and then have the COD module hide itself depending on the carrier ID. Also, depending on your Prestshop version, you could do this via a module override instead of modifying the original module. 1 Link to comment Share on other sites More sharing options...
jgamio Posted April 12, 2015 Share Posted April 12, 2015 You can do in may ways but the easy way is hide the other option in the js file Are you use the 1 step or the 5 steps for the order Link to comment Share on other sites More sharing options...
ostiepok Posted April 12, 2015 Author Share Posted April 12, 2015 You can do in may ways but the easy way is hide the other option in the js file Are you use the 1 step or the 5 steps for the order Iam using 5steps right now. I will look into this ASAP when ill have some time and let u know how its going Link to comment Share on other sites More sharing options...
ostiepok Posted April 14, 2015 Author Share Posted April 14, 2015 I'm not aware of any configuration or module that would do this. However you could accomplish this by modifying the COD payment module, and updating the hookpayment function so that it would check for the selected carrier ID, and then have the COD module hide itself depending on the carrier ID. Also, depending on your Prestshop version, you could do this via a module override instead of modifying the original module. Ok, so in cashondelivery.php is a function, ive edited it a bit so it looks like this public function hookPayment($params) { if (!$this->active) return ; global $smarty; // 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.'/' )); {if isset($cart->id_carrier) && $cart->id_carrier == 8} // STUFF to hide module {/if} return $this->display(__FILE__, 'payment.tpl'); } The question is, how can i hide the module ? ive tried returning false, ive tried displaying new payment.tpl which was called payment_no_cod.tpl which was empty, and i just got blank page after both of my attempts. I would appreciate ur help. Thanks Link to comment Share on other sites More sharing options...
bellini13 Posted April 14, 2015 Share Posted April 14, 2015 you simply return false to hide it {if isset($cart->id_carrier) && $cart->id_carrier == 8} // STUFF to hide module return false; {/if} Link to comment Share on other sites More sharing options...
ostiepok Posted April 14, 2015 Author Share Posted April 14, 2015 you simply return false to hide it {if isset($cart->id_carrier) && $cart->id_carrier == 8} // STUFF to hide module return false; {/if} I did, and ive expected the COD payment not to show on payment page, but whole payment page was gone, ive got only blank page :/ 1 Link to comment Share on other sites More sharing options...
bellini13 Posted April 15, 2015 Share Posted April 15, 2015 then you likely have a code syntax problem in the code you have added. enable debug mode and you will see an error message instead of a blank white page Link to comment Share on other sites More sharing options...
ostiepok Posted April 16, 2015 Author Share Posted April 16, 2015 (edited) then you likely have a code syntax problem in the code you have added. enable debug mode and you will see an error message instead of a blank white page So ive shrinked it a bit to look like this if ($cart->id_carrier == 8) return false; Now, everything is fine, i get the whole payment page, but with no change. When ive selected my carrier(with ID 8), the payment method C.O.D. was still there on payment page :/ Edited April 16, 2015 by ostiepok (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted April 16, 2015 Share Posted April 16, 2015 (edited) is $cart ever defined in the function? If not, then you are trying to use an object that does not exist. What if you do this instead if ($this->context->cart->id_carrier == 8) return false; Edited April 16, 2015 by bellini13 (see edit history) 3 Link to comment Share on other sites More sharing options...
ostiepok Posted April 16, 2015 Author Share Posted April 16, 2015 is $cart ever defined in the function? If not, then you are trying to use an object that does not exist. What if you do this instead if ($this->context->cart->id_carrier == 8) return false; Yep, that was it, thanks for help (i feel shame ) 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