Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2010
    Posts
    182
    Plugin Contributions
    0

    Default Display or not to display - compare two countries

    Goal: To display Insurance Variable on a custom slip. Though I'd like to see if Brazil or Mexico are the delivery_country to display or not.
    Basically the order has to be over $400 and not Brazil or Mexico.

    This works for 1 country:

    PHP Code:
    if (strtoupper($order_check->fields['delivery_country']) != 'BRAZIL' && $order_check->fields['order_total'] > 400) {
        echo 
    $ins;    

      else {
    // do nothing
    }
    ?> 
    This does not work with OR on 2 countries:

    PHP Code:
    if (strtoupper($order_check->fields['delivery_country']) != 'BRAZIL' || strtoupper($order_check->fields['delivery_country']) != 'MEXICO' && $order_check->fields['order_total'] > 400) {
        echo 
    $ins;    

      else {
    // do nothing
    }
    ?> 
    How does it work for both countries to not equal the statement? I tried a couple different routes and am stuck.

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,521
    Plugin Contributions
    88

    Default Re: Display or not to display - compare two countries

    Try this
    Code:
    if ( strtoupper($order_check->fields['delivery_country']) != 'BRAZIL' && strtoupper($order_check->fields['delivery_country']) != 'MEXICO' && $order_check->fields['order_total'] > 400) {
        echo $ins;    
    } 
      else {
    // do nothing
    }
    ?>
    Last edited by lat9; 3 Aug 2013 at 07:53 AM.

  3. #3
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: Display or not to display - compare two countries

    Hmmm ....

    try this one

    Code:
    if ((strtoupper($order_check->fields['delivery_country']) != 'BRAZIL') || (strtoupper($order_check->fields['delivery_country']) != 'MEXICO') && $order_check->fields['order_total'] > 400) {
        echo $ins;    
    } 
      else {
    // do nothing
    }
    ?>
    Last edited by frank18; 3 Aug 2013 at 09:57 AM.

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,521
    Plugin Contributions
    88

    Default Re: Display or not to display - compare two countries

    Quote Originally Posted by frank18 View Post
    Hmmm ....

    try this one

    Code:
    if ((strtoupper($order_check->fields['delivery_country']) != 'BRAZIL') || (strtoupper($order_check->fields['delivery_country']) != 'MEXICO') && $order_check->fields['order_total'] > 400) {
        echo $ins;    
    } 
      else {
    // do nothing
    }
    ?>
    Nope, needs the && like I mentioned before. If the delivery country is not Brazil AND it's not Mexico AND the total is more than $400 then ...

  5. #5
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: Display or not to display - compare two countries

    Quote Originally Posted by lat9 View Post
    Nope, needs the && like I mentioned before. If the delivery country is not Brazil AND it's not Mexico AND the total is more than $400 then ...
    Criteria of the poster:

    Though I'd like to see if Brazil or Mexico are the delivery_country to display or not.
    me thinks: (If the delivery country is not Brazil OR it's not Mexico) AND the total is more than $400 then ...
    Last edited by frank18; 3 Aug 2013 at 10:27 AM.

  6. #6
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: Display or not to display - compare two countries

    Quote Originally Posted by frank18 View Post
    me thinks: (If the delivery country is not Brazil OR it's not Mexico) AND the total is more than $400 then ...
    correction: (If (the delivery country is not Brazil OR it's not Mexico) AND the total is more than $400) then ...

  7. #7
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,521
    Plugin Contributions
    88

    Default Re: Display or not to display - compare two countries

    I can see that this is turning into "logic war" If parentheses were used in speech, the OP's statement would have been
    Code:
    Basically the order has to be over $400 and not (Brazil or Mexico).
    I used De Morgan's laws (http://en.wikipedia.org/wiki/De_Morgan%27s_laws) to 'twist' this into a comparison using != and &&.

    Using the following as the logical test
    Code:
    (If (the delivery country is not Brazil OR it's not Mexico) AND the total is more than $400)
    the clause would pass WHENEVER the total is more than $400. If the delivery country is Brazil, then it's not Mexico (and vice versa).

  8. #8
    Join Date
    Jan 2010
    Posts
    182
    Plugin Contributions
    0

    Default Re: Display or not to display - compare two countries

    Thanks to the both of you! Ended up I was able to take both your helpful roads and complete the whole thing.

    If not both Brazil AND Mexico and over $400, $ins
    If either Brazil OR Mexico and over $300, $ins

    All works perfectly! Thanks for the collaborative effort!

    PHP Code:
    <?php 
      
    if (strtoupper($order_check->fields['delivery_country']) != 'BRAZIL' && strtoupper($order_check->fields['delivery_country']) != 'MEXICO' && $order_check->fields['order_total'] > 400) {
        echo 
    $ins;    

      else {
    // do nothing  
    }
    ?>
    <?php 
      
    if (strtoupper($order_check->fields['delivery_country']) == 'BRAZIL' || strtoupper($order_check->fields['delivery_country']) == 'MEXICO' && $order_check->fields['order_total'] > 300) {
        echo 
    $ins;    

      else {
    // do nothing  
    }
    ?>
    With this code, the shipper easily knows to include insurance instead of listing the order totals, eyeballing and making a decision.
    We have a custom super_invoice. Since most of our orders are 10 items or less, we double up on one page now. The bottom half is for our internal picking/shipping and the top half is for customers. We are now saving A LOT on paper compared to printing two pages for each order.

  9. #9
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: Display or not to display - compare two countries

    Quote Originally Posted by sbbemn View Post
    Thanks to the both of you! Ended up I was able to take both your helpful roads and complete the whole thing.

    If not both Brazil AND Mexico and over $400, $ins
    If either Brazil OR Mexico and over $300, $ins

    All works perfectly! Thanks for the collaborative effort!
    Pleasure (always thought that there is something like being 'half right' )

    Congrats also to your paper saving efforts.

    Cheers / Frank

 

 

Similar Threads

  1. v151 Display countries shipped to
    By brillarmory in forum General Questions
    Replies: 2
    Last Post: 19 Sep 2014, 10:05 PM
  2. Display / not display when on hand is zero
    By liderbug in forum General Questions
    Replies: 1
    Last Post: 22 Jul 2009, 01:07 PM
  3. Display two currency $US and INR ?
    By boosters in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 2
    Last Post: 12 Jun 2009, 09:20 AM
  4. Display product attributes in two columns
    By DivaVocals in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 27 Dec 2007, 04:44 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR