Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2007
    Posts
    132
    Plugin Contributions
    0

    Default 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...
    PHP Code:
    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...
    PHP Code:
    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

  2. #2
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: PHP / $_SESSION help please

    You have mismatched parentheses.

    You're using:
    Code:
    if (condition a) and (condition b) {
    You probably should just do:
    Code:
    if (condition a and condition b) {
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Oct 2007
    Posts
    132
    Plugin Contributions
    0

    Default Re: PHP / $_SESSION help please

    Perfect. 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

 

 

Similar Threads

  1. v153 Sharing PHP variables ($_SESSION question)
    By flyvholm in forum General Questions
    Replies: 5
    Last Post: 4 Nov 2014, 06:15 PM
  2. Replies: 12
    Last Post: 16 Jun 2014, 05:55 AM
  3. Replies: 4
    Last Post: 26 Mar 2013, 06:12 PM
  4. Replies: 1
    Last Post: 21 Apr 2010, 06:37 PM
  5. Replies: 3
    Last Post: 10 Apr 2009, 10:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg