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)
-   -   Coding With Product's Extra Fields (https://forum.x-cart.com/showthread.php?t=9146)

willirl 08-30-2004 03:28 AM

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.

Emerson 09-02-2004 02:52 PM

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 ? 8O

Emerson 09-02-2004 03:01 PM

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.

willirl 09-02-2004 04:14 PM

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?

TelaFirma 09-02-2004 04:25 PM

{$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}
...

Emerson 09-02-2004 08:33 PM

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 ;)

mizzlewillz 09-15-2004 08:21 AM

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

sportruck 09-15-2004 03:38 PM

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}


mizzlewillz 09-15-2004 05:34 PM

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

Emerson 09-15-2004 05:54 PM

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 ;)


All times are GMT -8. The time now is 01:58 AM.

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