Zen Cart Logo
Forums / General Questions / PHP / $_SESSION help please

PHP / $_SESSION help please

Locked

Views: 1,040

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
6 Oct 2008, 12:06 AM
#1
jeff_g avatar

jeff_g

Zen Follower

Join Date:
Oct 2007
Posts:
132
Plugin Contributions:
0

PHP / $_SESSION help please

I am trying to write a new observer class to check shipping method and minimum order amout. I am basing all this on the Minimum Order contrib that I have installed and working.

This works...

if($_SESSION['cart']->show_total() < MIN_ORDER_AMOUNT) { 
   $messageStack->add('checkout_payment', sprintf($_SESSION['shipping']['id'] . TEXT_ORDER_UNDER_MIN_CHECKOUT, $currencies->format(MIN_ORDER_AMOUNT)) . '<br />', 'caution');
          }

But, if I try to add the AND shipping method like this...

if($_SESSION['cart']->show_total() < MIN_ORDER_AMOUNT) && ($_SESSION['shipping']['id'] == 'flat_flat') {
     $messageStack->add('checkout_payment', sprintf($_SESSION['shipping']['id'] . TEXT_ORDER_UNDER_MIN_CHECKOUT, $currencies->format(MIN_ORDER_AMOUNT)) . '<br />', 'caution');
          }

The code fails.

What I don't understand is the $_SESSION['shipping']['id'] prints fine in the message. I assume that means I am using the right variable.

Did I use the wrong var, or am I doing something wrong with my compare or my AND?

Thanks,
Jeff

6 Oct 2008, 4:55 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: PHP / $_SESSION help please

You have mismatched parentheses.

You're using:

if (condition a) and (condition b) {

You probably should just do: ```
if (condition a and condition b) {

6 Oct 2008, 5:17 AM
#3
jeff_g avatar

jeff_g

Zen Follower

Join Date:
Oct 2007
Posts:
132
Plugin Contributions:
0

Re: PHP / $_SESSION help please

Perfect. :bigups: That was it.

I looked 5 times for mismatched delimiters. I've written thousands of AND statements in other langauges like my test. It never occurred to me to change the parentheses for php.

Thanks,
Jeff