Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2004
    Posts
    684
    Plugin Contributions
    0

    Default New for 2007 - Under Product name

    I am trying to get a "New for 2006" or "New for 2007" statement under the product name. I've created a new field under table: products called product_is_new. I'm trying to call it with:

    if ($listing->fields['product_is_new'] == 1) {
    $new = '<font color=#ff0000><b>NEW FOR 2006</b></font>';
    } elseif ($listing->fields['product_is_new'] == 2) {
    $new = '<font color=#ff0000><b>NEW FOR 2007</b></font>';
    } else {
    $new = '';
    }
    I have the statement within the product_listing and all I ever get is "New for 2006" whether I have a 1 or a 2 in the database field. I'm sure it's a simple error on my part, but I can no longer see the forest through the trees.

    Thanks in advance,
    Marg

  2. #2
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    4,479
    Plugin Contributions
    121

    Default Re: New for 2007 - Under Product name

    You're sure the code says == 1 and not = 1?
    Scott C Wilson, That Software Guy, Plugin Moderator
    Contributions: Quantity Discounts, Better Together, SMS on Sale, Gift Wrap at Checkout, and more.

  3. #3
    Join Date
    Aug 2005
    Posts
    26,038
    Plugin Contributions
    9

    Default Re: New for 2007 - Under Product name

    SW -

    Yeah - that is the comparison operator rather than the math operator

    == is equal to
    != is not equal to
    Zen-Venom Get Bitten
    Get Your Business Found

  4. #4
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    4,479
    Plugin Contributions
    121

    Default Re: New for 2007 - Under Product name

    Yes, that was my point. I was wondering if Marg had perhaps typed the code in from memory (based on what she thought it said) when in fact it said "=". This would certainly explain the behavior she's seeing, and is probably the second most common "finger trouble" problem (where the first is missing the dollar sign in front of a variable).
    Scott C Wilson, That Software Guy, Plugin Moderator
    Contributions: Quantity Discounts, Better Together, SMS on Sale, Gift Wrap at Checkout, and more.

  5. #5
    Join Date
    Aug 2005
    Posts
    26,038
    Plugin Contributions
    9

    Default Re: New for 2007 - Under Product name

    SW -

    Gotcha - I assumed that what was posted was pasted from the file and you could very well be correct!!
    Zen-Venom Get Bitten
    Get Your Business Found

  6. #6
    Join Date
    Mar 2004
    Posts
    684
    Plugin Contributions
    0

    Default Re: New for 2007 - Under Product name

    It's exactly as I wrote it above.
    I keep getting just the NEW For 2006
    I'm sure there's a field with a 1 in it and a field with a 2 in it. In case that's wobbling around someone's head.
    Nothing seems to jump out?
    I'm really at a loss and am not all that good at the coding... So I'm finding out! hehe
    Marg

  7. #7
    Join Date
    Mar 2004
    Posts
    684
    Plugin Contributions
    0

    Default Re: New for 2007 - Under Product name

    $isnew = "($listing->fields['product_is_new']";
    if ($isnew = 1) {
    $new = '<font color=#ff0000><b>NEW FOR 2006</b></font>';
    }
    if ($isnew = 2) {
    $new = '<font color=#ff0000><b>NEW FOR 2007</b></font>';
    } else {

    }

    This gets me "New For 2007" on both 1 & 2 variables

    Whatta dilema. I know this should be simple...
    I ain't seein' it!
    Marg

  8. #8
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    4,479
    Plugin Contributions
    121

    Default Re: New for 2007 - Under Product name

    This was the problem I was describing. Saying

    if ($isnew = 1) {
    $new = '<font color=#ff0000><b>NEW FOR 2006</b></font>';
    }

    is the same as saying

    $isnew = 1;
    $new = '<font color=#ff0000><b>NEW FOR 2006</b></font>';

    Single equals is the assignment operator. Assigning a variable to a non-zero
    value always evaluates to true, so

    if ($isnew = 1) is true.

    You need if ($isnew == 1)

    Scott
    Scott C Wilson, That Software Guy, Plugin Moderator
    Contributions: Quantity Discounts, Better Together, SMS on Sale, Gift Wrap at Checkout, and more.

  9. #9
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    4,479
    Plugin Contributions
    121

    Default Re: New for 2007 - Under Product name

    If the original code you posted was what you have, then double check your data:

    echo "*** isnew is " . $listing->fields['product_is_new'] ;

    Scott
    Scott C Wilson, That Software Guy, Plugin Moderator
    Contributions: Quantity Discounts, Better Together, SMS on Sale, Gift Wrap at Checkout, and more.

 

 

Similar Threads

  1. Installed? Now create your own template
    By kuroi in forum Basic Configuration
    Replies: 21
    Last Post: 23 Sep 2007, 04:15 AM

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
  •