View Single Post
  #4  
Old 01-24-2010, 11:05 AM
 
willieram willieram is offline
 

Newbie
  
Join Date: Jan 2010
Posts: 6
 

Default Re: Extra Fields in Cart using 4.2.2

The solution outlined did not work for me as I needed more than one extra field, actually a set of them. You'll have to know a little about smarty, php and SQL to "understand and adapt" though

Here's my mod, it works for 4.3 but ymmv.

Look into module /xcart/include/func/func.cart.php
(on 4.3) around line 1775 you will find the following, add the following code (the one that starts with //@willy

PHP Code:
if ($products_array) {
            
$products_array func_array_merge($product_data$products_array);

//@willy - add extra fields
            
if (!empty($active_modules['Extra_Fields'])) {
                
//var_dump($products_array);
                
$products_ef func_query_hash("SELECT $sql_tbl[extra_fields].*, $sql_tbl[extra_field_values].*, IF($sql_tbl[extra_fields_lng].field != '', $sql_tbl[extra_fields_lng].field, $sql_tbl[extra_fields].field) as field FROM $sql_tbl[extra_field_values]$sql_tbl[extra_fields] LEFT JOIN $sql_tbl[extra_fields_lng] ON $sql_tbl[extra_fields].fieldid = $sql_tbl[extra_fields_lng].fieldid AND $sql_tbl[extra_fields_lng].code = '$shop_language' WHERE $sql_tbl[extra_fields].fieldid = $sql_tbl[extra_field_values].fieldid AND $sql_tbl[extra_field_values].productid = '$productid' AND $sql_tbl[extra_fields].active = 'Y' ORDER BY $sql_tbl[extra_fields].orderby""productid");
                foreach (
$products_ef as $ef) {
                    
$products_array['extra_fields'] = $ef;
                }
                
//echo "<hr>"; var_dump($products_array); exit;
            
}
//@willy - add extra fields 

Then on skin1/customer/main/cart.tpl you could access the extra fields (all of them) like this:

PHP Code:
{$product.extra_fields.0.field}
{
$product.extra_fields.0.value

Change 0 by the index number of your field, which you could find on the extra fields section on the admin side. You could loop them also.

Of course $product is a variable inside a loop on the cart that represents a product of the cart. Look in cart.tpl it's straighforward.
__________________
Willie
Reply With Quote