X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   IF statement for custom fields (https://forum.x-cart.com/showthread.php?t=59092)

Luke White 04-27-2011 03:24 AM

IF statement for custom fields
 
I would like to make a image visable when an extra fires is set to 'Yes' in the product.tpl


My current code look like:


{if $bestsellers.extra_fields[0]value eq "Yes"}
<img src="lifetimelabour.jpg"/>


{/if}

But fails to work. Can someone please point me in the correct direction.

cflsystems 04-27-2011 01:36 PM

Re: IF statement for custom fields
 
There is no such thing as $bestsellers.extra_fields unless you have some customization done. It will be either $product.extra_fields ot $extra_fields

Luke White 05-04-2011 01:51 AM

Re: IF statement for custom fields
 
Quote:

Originally Posted by cflsystems
There is no such thing as $bestsellers.extra_fields unless you have some customization done. It will be either $product.extra_fields ot $extra_fields


Many thanks,

I am trying to query a the result of a custom field "SERVICE_NAME01" to then output the image "lifetimelabour.jpg"

I have basic experience in C++ and Java but not this and am not able to find any api information relating to the reference location of the variables. Can you please advise me where I need to reference or where I can find the information needed.



I have experance in C++ and Java but not this and am not able to fine any api information relating to the referance location of the verables. can you please advise me where I need to referance or where I can find the information needed.

cflsystems 05-04-2011 03:09 AM

Re: IF statement for custom fields
 
Turn the debuging console on from admin/general settings - it will show you all variables on a page and their structure. Also if you are on 4.4.0 consider upgrading either to 4.4.2 or 4.4.3 (in about a week) - 4.4.0 is extremely buggy

Luke White 05-04-2011 03:57 AM

Re: IF statement for custom fields
 
Quote:

Originally Posted by cflsystems
Turn the debuging console on from admin/general settings - it will show you all variables on a page and their structure. Also if you are on 4.4.0 consider upgrading either to 4.4.2 or 4.4.3 (in about a week) - 4.4.0 is extremely buggy


Thanks again but I'm still having difficulty this one. My debugging console has the following under {$bestsellers}

Array (5)
0 => Array (22)
productid => "17651"
provider => "1"
product => "Beko DVTC60W Vented Dryer"
productcode => "DVTC60W"
avail => "0"
price => "184.95"
fclassid => null
is_clist => ""
variantid => "0"
weight => "0.00"
is_product_options => "Y"
is_variant => ""
taxid => "1"
taxed_price => "184.95"
extra_fields => Array (5)
0 => Array (7)
fieldid => "1"
provider => "1"
field => "Life Time Labour Free Available?"
value => "Yes"
active => "Y"
orderby => "1"
service_name => "SERVICE_NAME01"

That I would take to mean bestsellers.extra_fields(1)(4) or extra_fields(1)(4) for the yes/no variable. Can you please let me know the error of my ways.

Thanks again

cflsystems 05-04-2011 10:12 AM

Re: IF statement for custom fields
 
{if $bestsellers.extra_fields[0].value eq "Yes"}
<img src="lifetimelabour.jpg"/>
{/if}

It may work with your original code but you were missing a dot(.)

Luke White 05-05-2011 12:44 AM

Re: IF statement for custom fields
 
Quote:

Originally Posted by cflsystems
{if $bestsellers.extra_fields[0].value eq "Yes"}
<img src="lifetimelabour.jpg"/>
{/if}

It may work with your original code but you were missing a dot(.)


Perfect. Code I used in the end was
{if $extra_fields[0].field_value eq "Yes"}
<img src="lifetimelabour.jpg"/>
{/if}

but that's because I made the mistake of thinking value was the field value.

I couldn't have managed this without your help. Many thanks.


All times are GMT -8. The time now is 09:31 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.