![]() |
Can't get extra fields to show in other places
Hi - I'm trying to get an extra field of "Product size" which we've added to show up in the products_t.tpl where we have a list of products, however I can't get it to show.
The code I added in was the bit inbetween the "size field" comment {foreach from=$row item=product} {if $product} <td class="product-cell"> Size will go here {* ************************ Size Field ************************ *} {if $active_modules.Extra_Fields} {foreach from=$extra_fields item=v} {if $v.active eq "Y" && $v.field_value && $v.field == "Product size"} TESTING {$v.field_value} {/if} {/foreach} {/if} {* ************************************************** ************ *} <div class="image"> <a href="product.php?productid={$product.productid}&c at={$cat}&page={$navigation_page}">{include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.tmbn_x image_y=$product.tmbn_y product=$product.product tmbn_url=$product.tmbn_url}</a> etc. etc. .................................... It's showing "Size will go here" but not "TESTING" which is weird - I'm guessing it's not showing the size because maybe it doesn't have the product ID at that point to cross-reference in the "extra fields" list to get that value (need help with this) but interestingly it isn't showing the word "TESTING" either which suggests it isn't looping through the extra fields at all....... Can anyone give me a hand with this? |
Re: Can't get extra fields to show in other places
To debug - you can print out the values of $v.active, $v.field_value and $v.field before you go into the if statement. You can see if they are as you expect.
Also, note there is a difference between $v.value and $v.field_value You can use this tip to always see the variable values, to make sure they are what you think. |
Re: Can't get extra fields to show in other places
Thanks for that - using it as a guide I managed to work out what was wrong.....
I think a lot of it was to do with the difference between the $v.value and $v.field_value thing........ |
Re: Can't get extra fields to show in other places
Do you mind sharing the code you eventually used to get this to work? I'm using 4.2 and just cannot get extra fields to show up on products_t.tpl.
|
Re: Can't get extra fields to show in other places
{foreach from=$product.extra_fields item=v}
{if $v.active eq "Y" && $v.value ne "" && $v.field eq "*** Whatever your field is called ***"} <span class="*** Whatever you want (style sheet) ***">{$v.value}</span> {/if} {/foreach} For example your product field may be called "Size" etc. etc. - this code goes in the {foreach from=$row item=product} {if $product} loop. Hope that helps. Obviously if you're showing all the extra fields, you would omit the part that says '&& $v.field eq " blah blah " ' to show all of them. |
Re: Can't get extra fields to show in other places
Sorry to keep bothering you, but I still can't get it to work - did you have to edit products.php or any other PHP files to get extra fields to work on your products_t.tpl? If yes, do you remember what changes you made?
|
Re: Can't get extra fields to show in other places
To get it to work, you need to enclose it in the {foreach from=$row item=product}
{if $product} loop. Here's what I have in products_t.tpl to show any extra field that has a value: Code:
<tr{interline name=products_matrix}> |
Re: Can't get extra fields to show in other places
Quote:
Been trying to get extra fields to show up in my products list (products_list.tpl) in 4.3.1 with no luck. Tried your suggestion but nothing happens. The search continues. Edit: Got it working now: http://forum.x-cart.com/showpost.php?p=287479&postcount=10 |
Re: Can't get extra fields to show in other places
trying same for 4.3.2
no use |
Re: Can't get extra fields to show in other places
did anyone get this working with 4.3.2?
|
Re: Can't get extra fields to show in other places
{foreach from=$product.extra_fields item=v}
{if $v.active eq "Y" && $v.value ne ""} {if $v.field eq "Swatch"} {$v.value} {/if}{/if} {/foreach} replace swatch with your extra field name |
Re: Can't get extra fields to show in other places
Wanted to show extra field Pack in the product list, Xcart 4.5
Edited the file products_list.tpl in skin/ideal_comfort/customer/main/ added the code right after this code - {if $config.Appearance.display_productcode_in_list eq "Y" and $product.productcode ne ""} <div class="sku">{$lng.lbl_sku}: <span class="sku-value">{$product.productcode|escape}</span></div> {/if} Here is the code that I used - Pack: {$product.extra_fields[2].field_value} {foreach from=$product.extra_fields item=v} {if $v.active eq "Y" && $v.value ne ""} {if $v.field eq "Pack"} {$v.value} {/if}{/if} {/foreach} Thanks for your help - |
Re: Can't get extra fields to show in other places
in XC 4.5.1 I did the following which works:
Created new file in <skin>/modules/Extra_Fields/ product_extrafields_list.tpl: {foreach from=$product.extra_fields item=v} {if $v.service_name eq $xtrafieldservicename and $v.active eq "Y" and $v.field_value} <div> <span class="descr">{$v.field}: </span> <span class="descr">{$v.field_value}</span> </div> {/if} {/foreach} Called this file from products_list.tpl using: {if $active_modules.Extra_Fields} {include file="modules/Extra_Fields/product_extrafields_list.tpl" xtrafieldservicename="ORCHESTRATION"} {/if} If this helps you, maybe you can help me....I need to figure out how to show the same extra field data in the cart, this is important because it allows the customer to confirm that they have the exact right product in their cart before they start the check out process. Anyone can help? |
Re: Can't get extra fields to show in other places
Thanks this worked perfectly for me.
|
Re: Can't get extra fields to show in other places
any chance of getting the extra fields to show up on the order details page in admin end this would be a great feature
|
All times are GMT -8. The time now is 05:45 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.