Okay it's done! Here is what has to be done for displaying attributes on the products listing and adapting the form process (for Zen Cart 1.3). This is not perfect but it will work for the shop I'm working on.
1. /catalog/includes/modules/product_listing.php:
1.1 Line 27 (approx.), I commented the last checks done to see if the product has attributes (and on my shop, all products have thier product_type as n°3):
Code:
// if (zen_has_product_attributes($chk_attributes->fields['products_id']) < 1 and $chk_attributes->fields['products_type'] != 3) {
$how_many++;
// }
1.2 Line 42 (approx.), I added an item to the $column_list array:
Code:
$column_list[2] = $column_list[1];
$column_list[1] = "PRODUCT_LIST_ATTRIBUTES";
1.3 Line 83 (approx.), I added a 'case' to the switch:
Code:
case 'PRODUCT_LIST_ATTRIBUTES':
$lc_text = TABLE_HEADING_ATTRIBUTES;
$lc_align = 'left';
$zc_col_count_description++;
break;
1.4 Line 182 (approx.), I added a 'case' to the second switch:
Code:
case 'PRODUCT_LIST_ATTRIBUTES':
$lc_align = 'center';
if (zen_has_product_attributes($listing->fields['products_id']))
{
$_GET['products_id'] = $listing->fields['products_id'];
$productsListing = true;
require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_ATTRIBUTES));
/**
* display the product attributes
*/
for($i = 0; $i < sizeof($options_name); $i++)
{
$lc_text = '<div id="productAttributes">';
$lc_text .= $options_name[$i];
$lc_text .= $options_menu[$i];
$lc_text .= '</div>';
}
}
else
{
$lc_text = '';
}
break;
2. /catalog/includes/classes/shopping_cart.php:
2.1 Line 1674 (approx.), I added a line to check for attributes and I added the third parameter to the add_cart() call:
Code:
$real_ids = isset($_POST['attrib'][$prodId]) ? $_POST['attrib'][$prodId] : "";
$this->add_cart($prodId, $this->get_quantity($prodId)+($new_qty), $real_ids);
3. /catalog/includes/modules/attributes.php:
3.1 Line 574 (approx.), I changed the way the HTML is generated when it is for a products listing:
Code:
if ($show_attributes_qty_prices_icon == 'true') {
$options_name[] = ATTRIBUTES_QTY_PRICE_SYMBOL . $products_options_names->fields['products_options_name'];
} else if (!$productsListing) {
$options_name[] = '<label class="attribsSelect" for="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '">' . $products_options_names->fields['products_options_name'] . '</label>';
} else {
$options_name[] = '<label class="attribsSelect" for="attrib[' . $_GET['products_id'] . '][' . $products_options_names->fields['products_options_id'] . ']">' . $products_options_names->fields['products_options_name'] . '</label>';
}
if (!$productsListing)
{
$options_menu[] = zen_draw_pull_down_menu('id[' . $products_options_names->fields['products_options_id'] . ']', $products_options_array, $selected_attribute, 'id="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '"') . "\n";
}
else
{
$options_menu[] = zen_draw_pull_down_menu('attrib['. $_GET['products_id'] .'][' . $products_options_names->fields['products_options_id'] . ']', $products_options_array, $selected_attribute, '') . "\n";
}
4. /includes/languages/english/index.php:
4.1 I added a definition for the attributes row heading:
Code:
define('TABLE_HEADING_ATTRIBUTES', 'Attributes');
----
I think that's all. I know it's not perfect, some checks missing. But this is for a small shop and it will work with our products. If anybody can improve it, answers appreciated.
Bookmarks