Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Is this lne of code in payment.php correct

Is this lne of code in payment.php correct

Locked

Views: 1,843

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
2 Dec 2006, 11:34 PM
#1
ianetche avatar

ianetche

Zen Follower

Join Date:
Aug 2004
Posts:
138
Plugin Contributions:
0

Is this lne of code in payment.php correct

Hi

A quick question:

I was having trouble with one of the payment modules I am writing and noticed a problem with $_SESSION['payment'] failing an is_object() test on line 77 of checkout_confirmation/header.php.

Could someone please confirm that code on line 72 of classes/payment.php is correct looking like this:

if (!$credit_covers) $_SESSION['payment'] = $include_modules[0]['class'];

and given the assignment on line 65 above it,

$GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class'];

is there any chance it should come from the object held in $GLOBALS? - $include_modules[0]['class'] is a string at the moment i.e. the Real Question - is there any chance the code could like ...

if (!$credit_covers) $_SESSION['payment'] = $GLOBALS[$include_modules[0]['class']];

I have tried making the change and my module now works, however I have found very few bugs in ZC over the years and I would be really grateful for a steer as to whether I not I am on the right track.

Thanks, Ian

2 Dec 2006, 11:43 PM
#2
ianetche avatar

ianetche

Zen Follower

Join Date:
Aug 2004
Posts:
138
Plugin Contributions:
0

Re: Is this lne of code in payment.php correct

hehe missed being able to edit by a minute.

Wanted also to say that

I know this will require a change in checkout_confirmation _default which is what makes me doubt that I am correct, but I am definitely confused :) Thanks again, Ian

3 Dec 2006, 9:13 PM
#3
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,882
Plugin Contributions:
3

Re: Is this lne of code in payment.php correct

$_SESSION['payment'] is not meant to be an object only a referece to the class name of the payment method. Could u maybe show the code where the is_object test is being done.

The other Ian

3 Dec 2006, 11:19 PM
#4
ianetche avatar

ianetche

Zen Follower

Join Date:
Aug 2004
Posts:
138
Plugin Contributions:
0

Re: Is this lne of code in payment.php correct

Hi Ian

Thanks for the reply - I think you are probably THE Ian :)

I found the isobject() test in includes/modules/pages/checkout_confirmation/header_php.php on Line 77.

$payment_modules = new payment($_SESSION['payment']);
$payment_modules->update_status();
if (($_SESSION['payment'] == '' && !$credit_covers) || (is_array($payment_modules->modules)) && (sizeof($payment_modules->modules) > 1) && (!is_object($$_SESSION['payment'])) && (!$credit_covers) ) {
  $messageStack->add_session('checkout_payment', ERROR_NO_PAYMENT_MODULE_SELECTED, 'error');
}

I notice that the problem goes away if you only have one payment interface enabled - it skips the multiple module code.

Best regards, Ian

4 Dec 2006, 12:04 AM
#5
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,882
Plugin Contributions:
3

Re: Is this lne of code in payment.php correct

k, the actual test is for

is_object($$_SESSION['payment'])

as i said $_SESSION['payment'] is a string that references the class name of the payment method, hence the use of $$

So i still think the code as it stands is correct. Some more info about what u are trying to do with your payment module might help, and under what circumstances it breaks :)

4 Dec 2006, 6:18 PM
#6
ianetche avatar

ianetche

Zen Follower

Join Date:
Aug 2004
Posts:
138
Plugin Contributions:
0

Re: Is this lne of code in payment.php correct

Hi Ian

Thanks for that - must have been gettng tired or maybe just daft :) I had missed the $$.

The problem is strange, I have written a various payment modules and have released some where they might be useful to people, but I am having trouble with having more than two modules enabled at the moment.

I think that after your observation, I will just try reinstalling a clean system and running them from there.

I actually needed a UK type version of the CC module for a client and I am just writing one that deals with more cads including Switch, Maestro etc. It seems to work ok albeit it needs tidying up if I were to release it, but I had this strange problem. So I will try a solid test platform rather than my client's upgraded site. Do you think there would be any interest in an enhanced CC module - if so I will get it to a releasable format later in the month.

Hey many thanks for the help - I am hoping to get paid just after Christmas and will be sending you guys a late present.

Regards to all, Ian