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

Coding With Product's Extra Fields

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 08-30-2004, 03:28 AM
 
willirl willirl is offline
 

eXpert
  
Join Date: Mar 2004
Location: OHIO
Posts: 271
 

Default Coding With Product's Extra Fields

In 4.x how do you use the product's extra_fields in code? Before we used paramxx but this now seems not to work. An small code example would help.
Reply With Quote
  #2  
Old 09-02-2004, 02:52 PM
 
Emerson Emerson is offline
 

X-Man
  
Join Date: Mar 2004
Location: Atlanta, GA
Posts: 2,209
 

Default

I am having this problem too.

I understand they moved the extra fields into it's own tables so how do we get this going?

Also, where the heck do you add more extra fields in 4.x ?
__________________
Emerson
Total Server Solutions LLC- Quality X-Cart Hosting
Recommended X-Cart Hosting Provider - US and UK servers
Does your host backup your site? We do EVERY HOUR!!!
Shared Hosting | Managed Cloud | Dedicated Servers
Reply With Quote
  #3  
Old 09-02-2004, 03:01 PM
 
Emerson Emerson is offline
 

X-Man
  
Join Date: Mar 2004
Location: Atlanta, GA
Posts: 2,209
 

Default

Ok, I found were they are.
I am using a Pro version and in 4.x the extrafields option only show for the provider now.
__________________
Emerson
Total Server Solutions LLC- Quality X-Cart Hosting
Recommended X-Cart Hosting Provider - US and UK servers
Does your host backup your site? We do EVERY HOUR!!!
Shared Hosting | Managed Cloud | Dedicated Servers
Reply With Quote
  #4  
Old 09-02-2004, 04:14 PM
 
willirl willirl is offline
 

eXpert
  
Join Date: Mar 2004
Location: OHIO
Posts: 271
 

Default

You can reference the extra fields in the product.tpl template like this:

$extra_fields[x].field_value

Where x is the field index - 0 is the first.

However my problem is I need the extra fields on the products.tpl also and I cannot figure out how to get to them. There a set of files in modules/extra_fields/ that are used for something but I can't figure out how.

Isn't there anyone out there who knows how this works?
Reply With Quote
  #5  
Old 09-02-2004, 04:25 PM
  TelaFirma's Avatar 
TelaFirma TelaFirma is offline
 

X-Adept
  
Join Date: Nov 2002
Location: North Carolina USA
Posts: 930
 

Default

{$extra_fields[X].field_value} where X = the field ID. Field ID's start at 0.

{$extra_fields[0].field_value}
{$extra_fields[1].field_value}
{$extra_fields[2].field_value}
{$extra_fields[3].field_value}
{$extra_fields[4].field_value}
...

This will display the field value. To display the field name:

{$extra_fields[X].field} where X = the field ID. Field ID's start at 0.

{$extra_fields[0].field}
{$extra_fields[1].field}
{$extra_fields[2].field}
{$extra_fields[3].field}
{$extra_fields[4].field}
...
Reply With Quote
  #6  
Old 09-02-2004, 08:33 PM
 
Emerson Emerson is offline
 

X-Man
  
Join Date: Mar 2004
Location: Atlanta, GA
Posts: 2,209
 

Default

Quote:
Originally Posted by TelaFirma
{$extra_fields[X].field_value} where X = the field ID. Field ID's start at 0.

{$extra_fields[0].field_value}
{$extra_fields[1].field_value}
{$extra_fields[2].field_value}
{$extra_fields[3].field_value}
{$extra_fields[4].field_value}
...

This will display the field value. To display the field name:

{$extra_fields[X].field} where X = the field ID. Field ID's start at 0.

{$extra_fields[0].field}
{$extra_fields[1].field}
{$extra_fields[2].field}
{$extra_fields[3].field}
{$extra_fields[4].field}
...

Awesome, thanks a lot
__________________
Emerson
Total Server Solutions LLC- Quality X-Cart Hosting
Recommended X-Cart Hosting Provider - US and UK servers
Does your host backup your site? We do EVERY HOUR!!!
Shared Hosting | Managed Cloud | Dedicated Servers
Reply With Quote
  #7  
Old 09-15-2004, 08:21 AM
 
mizzlewillz mizzlewillz is offline
 

Advanced Member
  
Join Date: Apr 2004
Posts: 45
 

Default

How would you go about calling the extra fields in the products.tpl. I was trying some stuff, but I am assuming you need to edit some php files. Has anyone had any success with adding extra fields to the products.tpl?


Thanks in advance,

Mike
Reply With Quote
  #8  
Old 09-15-2004, 03:38 PM
 
sportruck sportruck is offline
 

Advanced Member
  
Join Date: Dec 2003
Posts: 70
 

Default

I got it to work, you may have coded something wrong.

Here is an exmaple of what I did. I have many parts that drop ship, so instead of showing stock for these I show the paramater in an extra field, such as "Ships within 2-3 days" or "Custom order, 4-6 week build time". Make an extra field titled "Availability" and check the Show box to show this field on products. For products with nothing in that field it is not shown by default.

Then to turn off the regular stock level display for items that do have something in that field, search for the following code in /customer/main/product.tpl

Code:
{if $config.Appearance.show_in_stock eq "Y" and $config.General.unlimited_products ne "Y" and $product.distribution eq ""} <TR><TD width="30%">{$lng.lbl_quantity}</TD><TD nowrap><SPAN id="product_avail_txt">{if $product.avail gt 0}{$product.avail}</SPAN>{else}{$lng.txt_no}{/if} {$lng.txt_items_available}</TD></TR> {/if}

Simply surround that code with an if statement as shown:

Code:
{if $extra_fields[0].field_value eq null} {if $config.Appearance.show_in_stock eq "Y" and $config.General.unlimited_products ne "Y" and $product.distribution eq ""} <TR><TD width="30%">{$lng.lbl_quantity}</TD><TD nowrap><SPAN id="product_avail_txt">{if $product.avail gt 0}{$product.avail}</SPAN>{else}{$lng.txt_no}{/if} {$lng.txt_items_available}</TD></TR> {/if} {/if}
Reply With Quote
  #9  
Old 09-15-2004, 05:34 PM
 
mizzlewillz mizzlewillz is offline
 

Advanced Member
  
Join Date: Apr 2004
Posts: 45
 

Default

Has anyone been successful with adding extra fields to the products.tpl? So far I have not found a solution.

Any comments are welcome

Thanks in advance!

-Mike
Reply With Quote
  #10  
Old 09-15-2004, 05:54 PM
 
Emerson Emerson is offline
 

X-Man
  
Join Date: Mar 2004
Location: Atlanta, GA
Posts: 2,209
 

Default

You have the define the section:

Code:
{section name=field loop=$extra_fields} {if $extra_fields[field].active eq "Y" && $extra_fields[field].field_value} {$extra_fields[0].field_value} {$extra_fields[0].field} {/if} {/section}

You'll just need to adjust/add/remove the
Code:
{$extra_fields[0].field_value} {$extra_fields[0].field}
part to show the extra field you want to display
__________________
Emerson
Total Server Solutions LLC- Quality X-Cart Hosting
Recommended X-Cart Hosting Provider - US and UK servers
Does your host backup your site? We do EVERY HOUR!!!
Shared Hosting | Managed Cloud | Dedicated Servers
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 01:23 AM.

   

 
X-Cart forums © 2001-2020