Jump to content

[Solved] Hide Payment Method Based on id_carrier using in .php function


tonycajjo

Recommended Posts

So i want to disable a payment method based on carrier selection. for example i want to disable the paypal module under the following conditions: (in the paypal.php file in the hookPayment function)

 

if ($cart->id_carrier ==39) //Dont show paypal

return;

 

edit: Prestashop 1.5.3.1 and Using one page checkout, much nicer than the step through version.

Edited by tonycajjo (see edit history)
Link to comment
Share on other sites

i found this older thread and have been messing around with it.

 

http://www.prestasho...on-issue/#47632

 

$cart = new Cart(intval($params['cart']));

if (intval($cart->id_carrier==2)) return;

 

i know it would be a core change, but i'm fine with that.

 

what about a java script or something that just hides the DIV or moves them off screen?

Edited by tonycajjo (see edit history)
Link to comment
Share on other sites

the above code does not seem to work, but if i simply put if (1==1) return; it does in fact work. but i start to get errors with the saving of the address when i change it. dunno why.

 

so i moved the return to where it calls the tempalte express_checkout_payment.tpl

 

and had it bail there with an if / else where if it would call a blank template file i made in the directory. probably unnecessary but that's how i did it and it seems to work and its bed time.

 

 

at the top of the function i get the varriable this way:

$cartski = $params['cart'];
$carrierski = intval($cartski->id_carrier);

 

then lower i do this:

if ($carrierski==39)
               {
                   return $this->fetchTemplate('express_checkout_payment_hidden.tpl');;
               }
               else
               {
                   return $this->fetchTemplate('express_checkout_payment.tpl');
               }

 

 

i used a combination of var_dump and print_r to get it sorted in the end.

Edited by tonycajjo (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...