I had some troubles myself and when updating ZenCart I completely forgot which files I had edited and changed to show Quantity by attributes in Stock by Attributes.
The old thread is rather outdated and I hope this thread can help users who are on 1.3.9h and later to show Quantity by attributes.
Code by Grayson:
In the file... /zencart/includes/modules/attributes.php
REPLACE
WITHCode:$sql = "select pov.products_options_values_id, pov.products_options_values_name, pa.* from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$_GET['products_id'] . "' and pa.options_id = '" . (int)$products_options_names->fields['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$_SESSION['languages_id'] . "' " . $order_by;
IN THE SAME FILE..Code:if ($products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_TEXT && $products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_FILE && $products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_READONLY) { $sql = "select pov.products_options_values_id, pov.products_options_values_name, pwas.quantity, pa.* from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas where pa.products_id = '" . (int)$_GET['products_id'] . "' and pa.options_id = '" . (int)$products_options_names->fields['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pwas.stock_attributes = pa.products_attributes_id and pov.language_id = '" . (int)$_SESSION['languages_id'] . "' " . $order_by; } else { $sql = "select pov.products_options_values_id, pov.products_options_values_name, pa.* from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$_GET['products_id'] . "' and pa.options_id = '" . (int)$products_options_names->fields['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$_SESSION['languages_id'] . "' " . $order_by; }
REPLACE
WITHCode:if ($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_CHECKBOX or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_RADIO or $products_options->RecordCount() == 1 or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_READONLY) { $products_options_value_id = $products_options->fields['products_options_values_id']; if ($products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_TEXT and $products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_FILE) { $products_options_details = $products_options->fields['products_options_values_name']; } else { // don't show option value name on TEXT or filename $products_options_details = ''; } if ($products_options_names->fields['products_options_images_style'] >= 3) { $products_options_details .= $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : ''); $products_options_details_noname = $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : ''); } else { $products_options_details .= $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : ''); $products_options_details_noname = $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : ''); } }
Then open... /zencart/includes/languages/english/product_info.phpCode:if ($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_CHECKBOX or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_RADIO or $products_options->RecordCount() == 1 or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_READONLY) { $products_options_value_id = $products_options->fields['products_options_values_id']; if ($products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_TEXT and $products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_FILE) { // $products_options_details = $products_options->fields['products_options_values_name']; // gbm - replaced original line above to display attribute stock amount beside attribute $products_options_details = $products_options->fields['products_options_values_name'] . ' [' . $products_options->fields['quantity'] . ' '. TEXT_ATTRIBUTES_PIECES . ']'; } else { // don't show option value name on TEXT or filename $products_options_details = ''; } if ($products_options_names->fields['products_options_images_style'] >= 3) { $products_options_details .= $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : ''); // $products_options_details_noname = $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : ''); // gbm - replaced original line above to display attribute stock amount beside attribute $products_options_details_noname = ' [' . $products_options->fields['quantity'] . ' '. TEXT_ATTRIBUTES_PIECES . '] ' . $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : ''); } else { $products_options_details .= $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : ''); // $products_options_details_noname = $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : ''); // gbm - replaced original line above to display attribute stock amount beside attribute $products_options_details_noname = ' [' . $products_options->fields['quantity'] . ' '. TEXT_ATTRIBUTES_PIECES . '] ' . $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : ''); } }
and add the following line..
Code:define('TEXT_ATTRIBUTES_PIECES','pieces');
ALL credit for the code goes to Grayson
All I've done is updated the file directories for people like me who are generally new to zencart.



