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

Need Help Using Extra Fields in customized function

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 11-05-2012, 03:27 PM
 
Thomasb134 Thomasb134 is offline
 

X-Adept
  
Join Date: Apr 2007
Location: USA
Posts: 789
 

Default Need Help Using Extra Fields in customized function

I would like to use the Extra Field feature as a global on-off flag to enable/disable a message based feature on the product's catalog page. I need some code guidance.

Just to be clear, the data entered in the Extra Field isn't shown to the customer. Instead, the field will be edited by Admin with a "Y" (yes) or "N" (no) character, which is used as a simple Boolean flag (to control a message/feature).

I started off by adding this code snippet to skin/common_files/customer/main/products_details.tpl:
Code:
{foreach from=$extra_fields item=v} {if $v.field eq "Message Notify Enabled" and $v.value eq "N"} {assign var="MsgNotifyValue" value= "N"} {* Set flag to NO *} {/if} {/foreach} {if $MsgNotifyValue neq "N"} {* Feature enabled = YES, execute the function located here *} {/if}

The $v.field correctly returns the expected "Message Notify Enabled" string. But the $v.value string that is returned is the Extra Field's default database value (stored in extra_fields table) which was defined on the Extra Fields admin page. Instead, I need the associated string value that was assigned to the Extra Field (stored in extra_field_values table) on the Product Management page. Any advice is appreciated.

.
__________________
Thomas / USA
XCart V4.4.5 Gold
XCart Mobile V1.4.12
XCart X-PDF
XCart X-HotProducts
AlteredCart Checkout One (One Page Checkout)
BCSE Back In Stock
CFL Holiday Message
CFL System Message
Smack Digital (WebsiteCM) Remember Anon Carts
xcartmods Testimonials
xcartmods reCAPTCHA for X-Cart Classic
Unix, PHP 7.0 (patched 5.4).
MySQL 5.6
Reply With Quote
  #2  
Old 11-06-2012, 02:58 AM
  vasilis's Avatar 
vasilis vasilis is offline
 

X-Adept
  
Join Date: Feb 2009
Posts: 761
 

Default Re: Need Help Using Extra Fields in customized function

Try '$v.field_value' instead of '$v.value'
__________________
Vasilis Vrontisis
X-Cart Development, Maintenance & Customization
https://[URL="http://www.craftforweb.com"]craftforweb.com[/url]
vasilis@craftforweb.com
Reply With Quote
  #3  
Old 11-06-2012, 06:34 PM
 
Thomasb134 Thomasb134 is offline
 

X-Adept
  
Join Date: Apr 2007
Location: USA
Posts: 789
 

Default Re: Need Help Using Extra Fields in customized function

Brilliant! That fixed the problem. Thank you.
__________________
Thomas / USA
XCart V4.4.5 Gold
XCart Mobile V1.4.12
XCart X-PDF
XCart X-HotProducts
AlteredCart Checkout One (One Page Checkout)
BCSE Back In Stock
CFL Holiday Message
CFL System Message
Smack Digital (WebsiteCM) Remember Anon Carts
xcartmods Testimonials
xcartmods reCAPTCHA for X-Cart Classic
Unix, PHP 7.0 (patched 5.4).
MySQL 5.6
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:48 PM.

   

 
X-Cart forums © 2001-2020