Forums / General Questions / New for 2007 - Under Product name

New for 2007 - Under Product name

Locked

Started by marg on 7 Mar 2007, 8:56 PM · Views: 1,359

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
7 Mar 2007, 8:56 PM
#1
marg avatar

marg

Totally Zenned

Join Date:
Mar 2004
Posts:
642
Plugin Contributions:
0

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

7 Mar 2007, 10:29 PM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,735
Plugin Contributions:
56

Re: New for 2007 - Under Product name

You're sure the code says == 1 and not = 1?

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

7 Mar 2007, 10:50 PM
#3
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

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

7 Mar 2007, 10:55 PM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,735
Plugin Contributions:
56

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

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

7 Mar 2007, 10:58 PM
#5
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

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

7 Mar 2007, 11:06 PM
#6
marg avatar

marg

Totally Zenned

Join Date:
Mar 2004
Posts:
642
Plugin Contributions:
0

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

8 Mar 2007, 12:19 AM
#7
marg avatar

marg

Totally Zenned

Join Date:
Mar 2004
Posts:
642
Plugin Contributions:
0

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 Mar 2007, 12:52 AM
#8
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,735
Plugin Contributions:
56

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

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

8 Mar 2007, 12:53 AM
#9
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,735
Plugin Contributions:
56

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

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.