网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > X-Cart
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Reply
 
Thread Tools Display Modes
  #1   IP: 117.95.1.180
Old 2016-03-17, 07:48 AM
Allamuchy Allamuchy is offline
初级会员
 
Join Date: 2013-02-24
Posts: 1
Allamuchy 现在声名狼藉
Default How to add extra field values to the product list page

Thought I would share this since the older answers do not really work...in XCart 4.7, if you want to have extra fields on the product listing page, you must add the fields to the product loop in products.php...i struggled with this for a few days, but with xcart support's help, i was able to craft this very simple code for my extra fields to show on the product listing page...

In products.php

just before the line

$smarty->assign('cat_products', isset($products) ? $products : array());

add this code and be sure to change the values to match your extra fields...

foreach($products as $c => $v) {
$products[$c]['calories'] = func_query_first_cell("SELECT value FROM $sql_tbl[extra_field_values] WHERE productid='$v[productid]' AND fieldid = '2'");
$products[$c]['protein'] = func_query_first_cell("SELECT value FROM $sql_tbl[extra_field_values] WHERE productid='$v[productid]' AND fieldid = '3'");
$products[$c]['fat'] = func_query_first_cell("SELECT value FROM $sql_tbl[extra_field_values] WHERE productid='$v[productid]' AND fieldid = '5'");
$products[$c]['carbs'] = func_query_first_cell("SELECT value FROM $sql_tbl[extra_field_values] WHERE productid='$v[productid]' AND fieldid = '4'");
}
$smarty->assign('calories', $calories);
$smarty->assign('protein', $protein);
$smarty->assign('fat', $fat);
$smarty->assign('carbs', $carbs);

pay attention to the 'fieldid' in the script...it is at the end of each line and you must figure out which fieldid in the database you want to have the value from...look in the table 'xcart_extra_field_values' and look at the 'fieldid' column and match that to the extra field you are trying to show[/b]

in my example, i have some food stuff...

Calories, Fat, Protein, Carbs...they are all extra fields and i went into the aforementioned tabled and got their 'fieldid's and then i put them into this script...

THEN in products_t.tpl
add these smarty tags wherever you want to show the extra field values...be sure to add these tags inside the {foreach}{/foreach} loop

{$product.calories}
{$product.protein}
{$product.fat}
{$product.carbs}
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirect to Product Page when only One product in category Pace X-Cart 2 2016-02-14 07:44 PM
Display product extra field data on Invoice Hahira X-Cart 0 2015-12-02 06:47 PM
htaccess 301 redirect tutorial yahoo 服务器环境搭建 0 2009-09-06 12:45 AM
What are the Strongest Directories? smiling 网站链接开发 1 2007-07-28 09:26 PM
Building for the user and the bot. admin 建站交流 0 2006-01-17 03:54 PM

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 10:46 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.