Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

IF statement for custom fields

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 04-27-2011, 03:24 AM
 
Luke White Luke White is offline
 

Newbie
  
Join Date: Apr 2011
Posts: 4
 

Default 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.
__________________
X-Cart 4.4
Reply With Quote
  #2  
Old 04-27-2011, 01:36 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default 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
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #3  
Old 05-04-2011, 01:51 AM
 
Luke White Luke White is offline
 

Newbie
  
Join Date: Apr 2011
Posts: 4
 

Default 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.
__________________
X-Cart 4.4
Reply With Quote
  #4  
Old 05-04-2011, 03:09 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default 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
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #5  
Old 05-04-2011, 03:57 AM
 
Luke White Luke White is offline
 

Newbie
  
Join Date: Apr 2011
Posts: 4
 

Default 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
__________________
X-Cart 4.4
Reply With Quote
  #6  
Old 05-04-2011, 10:12 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default 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(.)
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #7  
Old 05-05-2011, 12:44 AM
 
Luke White Luke White is offline
 

Newbie
  
Join Date: Apr 2011
Posts: 4
 

Default 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.
__________________
X-Cart 4.4
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:40 AM.

   

 
X-Cart forums © 2001-2020