View Single Post
  #6  
Old 06-18-2008, 10:59 PM
  DrQuietus's Avatar 
DrQuietus DrQuietus is offline
 

Advanced Member
  
Join Date: Dec 2005
Posts: 81
 

Default Re: Extra Fields on Products.tpl

Six months later...I had another site to make, this one I could not get away with hard coding the extra fields and I found the solution.

In products.tpl I finally made a table that outputs a <th> with the extra field names, and <td> with the extra field values, and excludes the extra fields without a value. This only works if all the products in the current category have the same extra fields, which was the case with this project. Combined with the bcse buy now mod, this makes for a fast and easy way for customers to order a bunch of products.

Code:
<table width="100%" cellpadding="2" cellspacing="0" class="productlisttable"> <tr> <th>Part #</th> {section name=product loop=$products} {if $smarty.section.product.first} {foreach from=$products[product].extra_fields item=extra_field name=field} {if $extra_field.value ne ''} <th>{$extra_field.field}</th> {/if} {/foreach} {/if} {/section} <th>{$lng.lbl_price}</th> <th>Place Your Order</th> </tr> {section name=product loop=$products} <tr {cycle values="class='odd', class='even'"}> <td> {$products[product].productcode} </td> {if $products[product].extra_fields ne ''} {foreach from=$products[product].extra_fields item=extra_field} {if $extra_field.value ne ''} <td>{$extra_field.value}</td> {/if} {/foreach} {/if} <td> {include file="currency.tpl" value=$products[product].taxed_price} </td> <td class="purchasingbutton"> {if $usertype eq "C" and $config.Appearance.buynow_button_enabled eq "Y"} {include file="customer/main/bcse_buy_now.tpl" product=$products[product] format_mode="list"} {/if} </td> </tr> {/section} </table>
__________________
Dave Jones
dave@industrialwebworks.net
Mostly 4.7.2 - 4.7.5
Reply With Quote