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

4.6 Change in Extra Fields IF Statement

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 06-06-2014, 12:12 PM
  drheath's Avatar 
drheath drheath is offline
 

Advanced Member
  
Join Date: Nov 2010
Location: Wisconsin
Posts: 53
 

Default 4.6 Change in Extra Fields IF Statement

I am in the process of upgrading our 4.5.4 store to 4.6.1 . Our template has some modifications which are transferring over for the most part, but I am having a hard time with IF Statements for Extrafields.

Previously I had the following code in skin/templateX/customer/main/product.tpl . The result would the that a message would display directly below the image if we marked the extra field.

Code:
{****** Product Page Sub-Image Messages ******} {if $extra_fields.5.field_value ne ""} <div id="product-details-backorder"> Currently on Manufacture Backorder </div> {/if} {if $extra_fields.11.field_value ne ""} <div style="color: #ff0000"> {$lng.lbl_haz_prod_short} </div> {/if} {****** END Product Page Sub-Image Messages ******}

It worked famously in 4.5 but is evading me now. Any suggestions would be greatly appreciated.
Thanks,
__________________
Business Edition 5.2.10
Gold Plus 4.6.1
Reply With Quote
  #2  
Old 06-06-2014, 05:51 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,191
 

Default Re: 4.6 Change in Extra Fields IF Statement

You are calling the extra fields arrays with very specific numbers. Are you sure they are just like that with the new upgraded cart? It will be actually more cleaner and error prove if you loop through the extra fields array and have your ifs compare the extra field service name to make sure it is the one you need
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #3  
Old 06-12-2014, 01:51 PM
  drheath's Avatar 
drheath drheath is offline
 

Advanced Member
  
Join Date: Nov 2010
Location: Wisconsin
Posts: 53
 

Default Re: 4.6 Change in Extra Fields IF Statement

Thanks Steve. We have used this mod for several versions and to be honest I have not thought to really dig too much into it since it worked. Though, if $extra_fields.x.field_value is only referring to the array position and not the field id, I'm not really sure how it worked in the past since we do not use all fields for all products.

Either way, I modified the syntax to call the service_name instead as shown below. I cannot use the extra_fileds product.tpl as is because we have a different output for the same field in different situations. It seems to me that there must be a more efficient way to do this through variable assignment so I could call a generic template file that would allow me to customize the output based on the call. But perhaps it would be more effort than it is worth.

Code:
{foreach from=$extra_fields item=v} {if $v.service_name eq "Hazardous" and $v.field_value} {$lng.lbl_haz_prod} </div> {/if} {/foreach}
__________________
Business Edition 5.2.10
Gold Plus 4.6.1
Reply With Quote

The following user thanks drheath for this useful post:
Petepots (06-13-2014)
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 06:50 AM.

   

 
X-Cart forums © 2001-2020