Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / How do I disable paypal if another shipping method is selected?

How do I disable paypal if another shipping method is selected?

Locked

Views: 3,123

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
16 Mar 2009, 12:55 PM
#1
soskuthy avatar

soskuthy

New Zenner

Join Date:
Mar 2009
Posts:
23
Plugin Contributions:
0

How do I disable paypal if another shipping method is selected?

Hi all!

Can you please tell me what code i need to insert into some files (im using zencart 1.38a, paypal website standards) if i want to
Disable paypal from paying methods if the user chooses CASH ON DELIVERY... ?!

Its quite embarassing that when somebody choose COD he has to pay with paypal, because they want to pay at the post office.

Please help!

16 Mar 2009, 2:09 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: How do I disable paypal if another shipping method is selected?

No link so I am guessing - -

Enable the Cash on Delivery method in admin > modules > payment

16 Mar 2009, 5:38 PM
#3
soskuthy avatar

soskuthy

New Zenner

Join Date:
Mar 2009
Posts:
23
Plugin Contributions:
0

Re: How do I disable paypal if another shipping method is selected?

Lol thanks.... i had to rewrite a shipping method to COD because somehow i didnt uploaded my COD modul. thanks!

19 Mar 2009, 1:36 PM
#4
soskuthy avatar

soskuthy

New Zenner

Join Date:
Mar 2009
Posts:
23
Plugin Contributions:
0

Re: How do I disable paypal if another shipping method is selected?

Hello!

I noticed that 17 people read my article and no one could hep so i try to solve the problem in another way.

I've found in an article that i can disable paypal payment if a customer reaches a certain amount, so i think i can disable paypal if a customer selects a certain shipping method like, item,table and other shipping methods by changing the $_SESSION['cart']->total > 900 to the variable name of the shipping method

paypal.php

if (IS_ADMIN_FLAG === false && $_SESSION['cart']->total > 900) {
      $this->enabled = false;

Now i only want to know what are the variable names for the shipping methods. My code should look like:

if (IS_ADMIN_FLAG === false && $_SESSION['shipping_method'] == "freeoptions" || $_SESSION['shipping_method'] == "table" || $_SESSION['shipping_method'] == "item") {
      $this->enabled = false;

please somebody give me the variable names, or give me where can i look after them.

19 Mar 2009, 3:51 PM
#5
soskuthy avatar

soskuthy

New Zenner

Join Date:
Mar 2009
Posts:
23
Plugin Contributions:
0

Re: How do I disable paypal if another shipping method is selected?

Hello!

I noticed that 17 people read my article and no one could hep so i try to solve the problem in another way.

I've found in an article that i can disable paypal payment if a customer reaches a certain amount, so i think i can disable paypal if a customer selects a certain shipping method like, item,table and other shipping methods by changing the code in paypal.php

paypal.php

if (IS_ADMIN_FLAG === false && $_SESSION['cart']->total > 900) {
      $this->enabled = false;

The code above is working, so i only need to replace the $_SESSION['cart']->total > 900 to the right variable
like $_SESSION['shipping_method']->title == "item" or $_SESSION['shipping_metgod'] == "perunit"

my code should look like this

if (IS_ADMIN_FLAG === false && $_SESSION['shipping_method'] == "freeoptions" || $_SESSION['shipping_method'] == "table" || $_SESSION['shipping_method'] == "item") {
      $this->enabled = false;

please tell me the variable names for shipping methods!

19 Mar 2009, 8:02 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do I disable paypal if another shipping method is selected?

Using the:
$_SESSION['shipping']['id']

will give you the shipping ...

Do a test and echo that out on the checkout_payment page for the various methods as you will find that the names will be a tad odd ...

/includes/modules/order_total/ot_cod_fee.php

shows the use of this for many of the shipping methods but again watch for how it is used to identify them ...

Specific shipping methods for things like USPS and UPS are even more fun ... :cool:

19 Mar 2009, 8:58 PM
#7
soskuthy avatar

soskuthy

New Zenner

Join Date:
Mar 2009
Posts:
23
Plugin Contributions:
0

Re: How do I disable paypal if another shipping method is selected?

WOW!!! IT worked !!!! Thank you very much!!

For people who don't understand:

go to includes/modules/pages/checkout_payment/header_php.php

then you will find some line:

// Load the selected shipping module(needed to calculate tax correctly)
require(DIR_WS_CLASSES . 'shipping.php');
$shipping_modules = new shipping($_SESSION['shipping']);
require(DIR_WS_CLASSES . 'order_total.php');
$order_total_modules = new order_total;
$order_total_modules->collect_posts();
$order_total_modules->pre_confirmation_check();

put this code after the above code:

echo $_SESSION['shipping']['id'];

and go to your page make a checkout and you can see the ID of the shipping method at the top of your page, after you saved the ids you can delete this

then go to paypal.php and edit the code to:

if (PROJECT_VERSION_MAJOR != '1' && substr(PROJECT_VERSION_MINOR, 0, 3) != '3.8') $this->enabled = false;
	//This is where you disable paypal
	if (IS_ADMIN_FLAG === false && $_SESSION['shipping']['id'] == "HERE_COMES_THE_ID_LIKE: FLAT_FLAT" || $_SESSION['shipping']['id'] == "storepickup_storepickup" ) {
      $this->enabled = false;
    }

And it works! THanks!:) <3

19 Mar 2009, 11:02 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do I disable paypal if another shipping method is selected?

Thanks for the update that this worked for you and for posting the step by step on the testing and helping to understand that concept ...

The "echo" can be your best friend ... :cool:

11 Jul 2009, 11:26 AM
#9
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,875
Plugin Contributions:
7

Re: How do I disable paypal if another shipping method is selected?

Hi,
firstly very useful post.

An observation for the nit pickers is that adding the code
echo $_SESSION['shipping']['id'];
causes the font size on that payment options page to "go large" in all browsers except Firefox. Why would it do that?

regards
Steve

11 Jul 2009, 3:34 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do I disable paypal if another shipping method is selected?

You are tossing out an echo with no regard to html/css format and making a mess ... such is the life of an elf ... :cool: