Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product_Listing.php new product field help


cclayton

Recommended Posts

I would like to add a couple of fields I have added to the products table into the product_listing.php page. My current code for this page is below, and where it says "test" and "test2" I would like to add the fields products_location and products_duration.

 

Any ideas how I can add these in? Everything I do doesnt appear to work properly because of the mix of php and html.

 

<?php
/*
 $Id$
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Copyright (c) 2010 osCommerce
 Released under the GNU General Public License
*/
 $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');
?>
 <div class="contentText">
<?php
 if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
   <div>
  <span style="float: right;"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></span>
  <span><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></span>
   </div>
   <br />
<?php
 }
 $prod_list_contents = '<div class="ui-widget infoBoxContainer">' .
				    '  <div class="ui-widget-header ui-corner-top infoBoxHeading">' .
				    '    <table border="0" width="100%" cellspacing="0" cellpadding="2" class="productListingHeader">' .
				    '	  <tr>';
 for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
   $lc_align = '';
   switch ($column_list[$col]) {
  case 'PRODUCT_LIST_MODEL':
    $lc_text = TABLE_HEADING_MODEL;
    $lc_align = '';
    break;
  case 'PRODUCT_LIST_NAME':
    $lc_text = TABLE_HEADING_PRODUCTS;
    $lc_align = '';
    break;
  case 'PRODUCT_LIST_MANUFACTURER':
    $lc_text = TABLE_HEADING_MANUFACTURER;
    $lc_align = '';
    break;
  case 'PRODUCT_LIST_PRICE':
    $lc_text = TABLE_HEADING_PRICE;
    $lc_align = 'right';
    break;
  case 'PRODUCT_LIST_QUANTITY':
    $lc_text = TABLE_HEADING_QUANTITY;
    $lc_align = 'right';
    break;
  case 'PRODUCT_LIST_WEIGHT':
    $lc_text = TABLE_HEADING_WEIGHT;
    $lc_align = 'right';
    break;
  case 'PRODUCT_LIST_IMAGE':
    $lc_text = TABLE_HEADING_IMAGE;
    $lc_align = 'center';
    break;
  case 'PRODUCT_LIST_BUY_NOW':
    $lc_text = TABLE_HEADING_BUY_NOW;
    $lc_align = 'center';
    break;
   }
   if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
  $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);
   }
   $prod_list_contents .= '	    <td' . (tep_not_null($lc_align) ? ' align="' . $lc_align . '"' : '') . '>' . $lc_text . '</td>';
 }
 $prod_list_contents .= '	  </tr>' .
					 '    </table>' .
					 '  </div>';
 if ($listing_split->number_of_rows > 0) {
   $rows = 0;
   $listing_query = tep_db_query($listing_split->sql_query);
   $prod_list_contents .= '  <div class="ui-widget-content ui-corner-bottom productListTable">' .
					   '    <table border="0" width="100%" cellspacing="0" cellpadding="2" class="productListingData">';
   while ($listing = tep_db_fetch_array($listing_query)) {
  $rows++;
  $prod_list_contents .= '	  <tr>';
  for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
    switch ($column_list[$col]) {
	  case 'PRODUCT_LIST_MODEL':
	    $prod_list_contents .= '	    <td>' . $listing['products_model'] . '</td>';
	    break;
	  case 'PRODUCT_LIST_NAME':
	    if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
		  $prod_list_contents .= '	    <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td>';
	    } else {
		  $prod_list_contents .= '	    <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a><br><strong>Location:</strong> Test<br><strong>Features:</strong> Test</td>';
	    }
	    break;
	  case 'PRODUCT_LIST_MANUFACTURER':
	    $prod_list_contents .= '	    <td><a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a></td>';
	    break;
	  case 'PRODUCT_LIST_PRICE':
	    if (tep_not_null($listing['specials_new_products_price'])) {
		  $prod_list_contents .= '	    <td align="right"><del>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</del>  <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span></td>';
	    } else {
		  $prod_list_contents .= '	    <td align="right">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</td>';
	    }
	    break;
	  case 'PRODUCT_LIST_QUANTITY':
	    $prod_list_contents .= '	    <td align="right">' . $listing['products_quantity'] . '</td>';
	    break;
	  case 'PRODUCT_LIST_WEIGHT':
	    $prod_list_contents .= '	    <td align="right">' . $listing['products_weight'] . '</td>';
	    break;
	  case 'PRODUCT_LIST_IMAGE':
	    if (isset($HTTP_GET_VARS['manufacturers_id'])  && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
		  $prod_list_contents .= '	    <td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>';
	    } else {
		  $prod_list_contents .= '	    <td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image($listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>';
	    }
	    break;
	  case 'PRODUCT_LIST_BUY_NOW':
	    $prod_list_contents .= '	    <td align="center">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id'])) . '</td>';
	    break;
    }
  }
  $prod_list_contents .= '	  </tr>';
   }
   $prod_list_contents .= '</table>' .
					   '  </div>' .
					   '</div>';
   echo $prod_list_contents;
 } else {
?>
   <p><?php echo TEXT_NO_PRODUCTS; ?></p>
<?php
 }
 if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
   <br />
   <div>
  <span style="float: right;"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></span>
  <span><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></span>
   </div>
<?php
 }
?>
 </div>

 

Thanks,

Founder & Director at CSC Tours Ltd

Link to comment
Share on other sites

product_listing.php uses a query built elswhere (usually index.php) so you must start there

 

you'll need to ensure you include the fields in the selection ie:

 

 $select_column_list .= 'test, ';

 

or your query won't get the data

 

Then remember that product_listing.php uses the split page class, so your query is modified there.

 

 

 

PS Please don't create extra wide posts, it makes it hard to see what your talking about

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

I added the code in (highlighted in Bold Italic) to index.php:

 

$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_location, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";

 

But nothing is still showing output. :(

Founder & Director at CSC Tours Ltd

Link to comment
Share on other sites

2 points:

 

There are an number of $listing_sql = "select " ... did you add to all?

 

Have you added $listing['products_location'] to product_listing.php for output?

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...