Jump to content
Sign in to follow this  
markmOS

"Show Sold Out Items" contribution showing "Sold Out" in category view

Recommended Posts

I installed "Show Sold Out Items" and all looks to be working except for viewing categories.

 

All items are showing the "sold out" button when looking at categories.

 

Can anyone off a suggestion?

 

 

Thanks.

Edited by Jan Zonjee

Share this post


Link to post
Share on other sites

error in product listing.php or index.php

 

you could add Product Listing Enhancements, Thumbnails & Manufacturer Headings http://addons.oscommerce.com/info/6051 that replaces product_listing.php & displays sold out


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.

Share this post


Link to post
Share on other sites

The contribution works for me in the product_info.php, but it doesn't work on the includes/modules/productlisting.php

 

Here is the modified code:

 

/** original **/ //$p_button =  $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now1.gif', IMAGE_BUTTON_BUY_NOW) . '</a>';
		/** show-soldout-v1.0 **/
if($listing['products_quantity'] <= 0 || $listing['products_status']==0)
$lc_text = tep_image_button('button_sold_out.gif', IMAGE_BUTTON_SOLD_OUT) . ' ';
else
$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now1.gif', IMAGE_BUTTON_BUY_NOW) . '</a>';
/** end show-soldout-v1.0 **/

 

Here is the page code:

 

<?php
/*
 $Id: product_listing.php 1739 2007-12-20 00:52:16Z hpdl $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<?php echo tep_draw_title_top();?>

			<?php echo $breadcrumb->trail(' » ')?>

<?php echo tep_draw_title_bottom();?>	

<?php echo tep_draw3_top();?>

<?php
 $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');

 if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>

<?php echo tep_draw_result1_top(); ?> 

	<table border="0" cellspacing="0" cellpadding="0" class="result result_top_padd">
         <tr>
           <td><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
           <td class="result_right" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
         </tr>
       </table>

<?php echo tep_draw_result1_bottom(); ?> 

<?php
 }

$info_box_contents = array();
 $list_box_contents = array();
$my_row = 0;
$my_col = 0;


 for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
   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);
   }

   $list_box_contents[0][] = array('align' => $lc_align,
                                   'params' => 'class="productListing-heading"',
                                   'text' => ' ' . $lc_text . ' ');
 }

 if ($listing_split->number_of_rows > 0) {
   $rows = 0;
   $listing_query = tep_db_query($listing_split->sql_query);
   while ($listing = tep_db_fetch_array($listing_query)) {
     $rows++;

     if (($rows/2) == floor($rows/2)) {
       $list_box_contents[] = array('params' => 'class="productListing-even"');
     } else {
       $list_box_contents[] = array('params' => 'class="productListing-odd"');
     }

     $cur_row = sizeof($list_box_contents) - 1;

     for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
       $lc_align = '';

       switch ($column_list[$col]) {
         case 'PRODUCT_LIST_MODEL':
           $lc_align = '';

           $p_model = '<tr>
						<td><b><font>'.TABLE_HEADING_MODEL.' :</font></b></td>
						<td align="right"><font>' . $listing['products_model'] . '</font></td>
					</tr>';
           break;
         case 'PRODUCT_LIST_NAME':
           $lc_align = '';
           if (isset($HTTP_GET_VARS['manufacturers_id'])) {
           $p_name = $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
           } else {
           $p_name = $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
           }
           break;
         case 'PRODUCT_LIST_MANUFACTURER':
           $lc_align = '';
           $p_manufact = '<tr>
						<td><b><font>'.TABLE_HEADING_MANUFACTURER.' :</font></b></td>
						<td align="right"><font><a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a></font></td>
					</tr>';
           break;
         case 'PRODUCT_LIST_PRICE':
           $lc_align = 'right';
           if (tep_not_null($listing['specials_new_products_price'])) {
          $p_price = $lc_text = '<s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>    <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>';
           } else {
          $p_price = $lc_text = '<span class="productSpecialPrice">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>';
           }
           break;
         case 'PRODUCT_LIST_QUANTITY':
           $lc_align = 'right';
           $p_qty = '<tr>
						<td><b><font>'.TABLE_HEADING_QUANTITY.' :</font></b></td>
						<td align="right"><font>' . $listing['products_quantity'] . '</font></td>
					</tr>';
           break;
         case 'PRODUCT_LIST_WEIGHT':
           $lc_align = 'right';
           $p_weight = '<tr>
						<td><b><font>'.TABLE_HEADING_WEIGHT.' :</font></b></td>
						<td align="right"><font>' . $listing['products_weight'] . '</font></td>
					</tr>';
           break;
         case 'PRODUCT_LIST_IMAGE':
           $lc_align = 'center';
           if (isset($HTTP_GET_VARS['manufacturers_id'])) {
             $p_pic = '<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>';
           } else {
             $p_pic = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
           }
           break;
         case 'PRODUCT_LIST_BUY_NOW':
           $lc_align = 'center';

           /** original **/ //$p_button =  $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now1.gif', IMAGE_BUTTON_BUY_NOW) . '</a>';
		/** show-soldout-v1.0 **/
if($listing['products_quantity'] <= 0 || $listing['products_status']==0)
$lc_text = tep_image_button('button_sold_out.gif', IMAGE_BUTTON_SOLD_OUT) . ' ';
else
$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now1.gif', IMAGE_BUTTON_BUY_NOW) . '</a>';
/** end show-soldout-v1.0 **/
           break;
       }

$product_query = tep_db_query("select products_description, products_id from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$listing['products_id'] . "' and language_id = '" . (int)$languages_id . "'");
     $product = tep_db_fetch_array($product_query);
      	$p_desc = substr(strip_tags($product['products_description']), 0, MAX_DESCR_1).'...<br>';

  if (PRODUCT_LIST_MODEL != 0 || PRODUCT_LIST_MANUFACTURER != 0 || PRODUCT_LIST_QUANTITY != 0 || PRODUCT_LIST_WEIGHT != 0) {
	$p_listing = '<table cellpadding="0" cellspacing="0" border="0" class="listing">'.$p_model.''.$p_manufact.'' . ''.$p_qty.'' . ''.$p_weight.'</table>';
	}

       $p_id = $product['products_id'];

/*		$list_box_contents[$cur_row][] = array('align' => $lc_align,
                                              'params' => '',
                                              'text'  => $lc_text); */

}

 $p_details = '<a href="' . tep_href_link('product_info.php?products_id='.$p_id) . '">'.tep_image_button('button_details.gif', '', ' class="btn1"').'</a>';
 $p_buy_now = '<a href="'.tep_href_link("products_new.php","action=buy_now&products_id=".$p_id).'">'.tep_image_button('button_add_to_cart1.gif', '', ' class="btn1"').'</a>';


$info_box_contents[$my_row][$my_col] = array('align' => 'center',
                                          'params' => ' style="width:25%;"',
                                          'text' => '
'.tep_draw_prod2_top().'
<table cellpadding="0" cellspacing="0" border="0">
	<tr><td class="name name2_padd">'.$p_name.'</td></tr>
	<tr><td class="pic2_padd">'.tep_draw_prod_pic_top().''.$p_pic.''.tep_draw_prod_pic_bottom().'</td></tr>
	<tr><td class="desc desc2_padd">'.$p_desc.'</td></tr>
	<tr><td class="listing2_padd">'.$p_listing.'</td></tr>
	<tr><td class="price2_padd">'.$p_price.'</td></tr>
	<tr><td class="button2_padd button_marg">'.$p_details.' '.$p_buy_now .'</td></tr>
</table>
'.tep_draw_prod2_bottom().'');

   $my_col ++;
   if ($my_col > 3) {
     $my_col = 0;
	$my_row ++;
     }
   }
new contentBox($info_box_contents); 
//    new productListingBox($list_box_contents);
} else {  ?>
<?php   echo tep_draw1_top(); ?>



			<table cellpadding="0" cellspacing="0" class="main">
				<tr><td><?php echo TEXT_NO_PRODUCTS ?></td></tr>
			</table>

<?php echo tep_draw1_bottom();  ?>                

<?php			
}
 if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>

<?php echo tep_draw_result2_top(); ?> 

	<table border="0" cellspacing="0" cellpadding="0" class="result result_bottom_padd">
         <tr>
           <td><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
           <td class="result_right" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
         </tr>
       </table>

<?php echo tep_draw_result2_bottom(); ?> 

<?php
 }
?>

 

Can anyone see the problem?

Share this post


Link to post
Share on other sites

Ok I fixed the product_listing.php module but now I'm trying to apply the same logic to my "featured products" module, and it's kicking my ass.

 

Here's the code:

 

<?php
/*
 $Id: featured.php,v 1.7 2008/08/22 22:30:20 aa0001 Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License

 Featured Products V1.1
 Displays a list of featured products, selected from admin
 For use as an Infobox instead of the "New Products" Infobox  
*/
?>
<!-- featured_products //-->
<?php
if( defined('FEATURED_PRODUCTS_DISPLAY') AND FEATURED_PRODUCTS_DISPLAY == 'true' ) {
 $featured_products_category_id = $new_products_category_id;
 $cat_name_query = tep_db_query('SELECT `categories_name` FROM ' . TABLE_CATEGORIES_DESCRIPTION . " WHERE `categories_id` = '" . $featured_products_category_id . "' limit 1");
 $cat_name_fetch = tep_db_fetch_array($cat_name_query);
 $cat_name = $cat_name_fetch['categories_name'];
 $info_box_contents = array();

 list($usec, $sec) = explode(' ', microtime());
 srand( (float) $sec + ((float) $usec * 100000) );
 $mtm= rand();

 if ( (!isset($featured_products_category_id)) || ($featured_products_category_id == '0') ) {
 	$info_box_contents[] = array('align' => 'left', 'text' => '<a class="headerNavigation" href="' . tep_href_link(FILENAME_FEATURED_PRODUCTS) . '">' . TABLE_HEADING_FEATURED_PRODUCTS . '</a>');

   // Phocea Optimize featured query
   // Ben: Option to only show featured products on sale
   $query = 'SELECT p.products_id, p.products_image, p.products_tax_class_id, IF (s.status, s.specials_new_products_price, NULL) AS specials_new_products_price, p.products_price, pd.products_name ';

if ( defined('FEATURED_PRODUCTS_SPECIALS_ONLY') AND FEATURED_PRODUCTS_SPECIALS_ONLY == 'true' ) {
     $query .= 'FROM ' . TABLE_SPECIALS . ' s LEFT JOIN ' . TABLE_PRODUCTS . ' p ON s.products_id = p.products_id ';
} else {
     $query .= 'FROM ' . TABLE_PRODUCTS . ' p LEFT JOIN ' . TABLE_SPECIALS . ' s ON p.products_id = s.products_id ';
}

   $query .= 'LEFT JOIN ' . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id AND pd.language_id = '" . $languages_id . "'
   LEFT JOIN " . TABLE_FEATURED . " f ON p.products_id = f.products_id
   WHERE  f.status = '1' order by rand($mtm) DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS;

   $featured_products_query = tep_db_query( $query );	
 } else {
   $info_box_contents[] = array('align' => 'left', 'text' => sprintf(TABLE_HEADING_FEATURED_PRODUCTS_CATEGORY, $cat_name));
   $subcategories_array = array();
   tep_get_subcategories($subcategories_array, $featured_products_category_id);
   $featured_products_category_id_list = tep_array_values_to_string($subcategories_array);
   if ($featured_products_category_id_list == '') {
     $featured_products_category_id_list .= $featured_products_category_id;
   } else {
     $featured_products_category_id_list .= ',' . $featured_products_category_id;
   }

if ( defined('FEATURED_PRODUCTS_SUB_CATEGORIES') AND FEATURED_PRODUCTS_SUB_CATEGORIES == 'true' ) {
     // current catID as starting value
     $cats[] = $new_products_category_id; 
     // put cat-IDs of all cats nested in current branch into $cats array, 
     // go through all subbranches
     for($i=0; $i<count($cats); $i++) {
       $categorie_query = tep_db_query('SELECT `categories_id` FROM ' . TABLE_CATEGORIES . " WHERE parent_id = '" . (int)$cats[$i] . "'"); 
       while ($categorie = tep_db_fetch_array($categorie_query)) {
         $cats[] = $categorie['categories_id'];
       }
    // sort out doubles
       $cats = array_unique($cats);
     }
     $catIdSql = implode(', ', $cats);
} else {
     $catIdSql = $featured_products_category_id_list;
}

   // Phocea Optimize featured query
$query = 'SELECT distinct p.products_id, p.products_image, p.products_tax_class_id, IF (s.status, s.specials_new_products_price, NULL) AS specials_new_products_price, p.products_price, pd.products_name
   FROM ' . TABLE_PRODUCTS . ' p LEFT JOIN ' . TABLE_PRODUCTS_TO_CATEGORIES . ' p2c using(products_id)
   LEFT JOIN ' . TABLE_CATEGORIES . ' c USING (categories_id)
   LEFT JOIN ' . TABLE_FEATURED . ' f ON p.products_id = f.products_id
   LEFT JOIN ' . TABLE_SPECIALS . ' s ON p.products_id = s.products_id
   LEFT JOIN ' . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id AND pd.language_id = '" . $languages_id . "' 
   where c.categories_id IN(" . $catIdSql . ") AND  f.status = '1' ";

if ( defined('FEATURED_PRODUCTS_SPECIALS_ONLY') AND FEATURED_PRODUCTS_SPECIALS_ONLY == 'true' ) {
	$query .= " AND s.status = '1' ";
}
$query .= 'ORDER BY rand(' . $mtm . ') DESC LIMIT ' . MAX_DISPLAY_FEATURED_PRODUCTS;

   $featured_products_query = tep_db_query( $query );
}

 $row = 0;
 $col = 0; 
 $num = 0;



 while ($featured_products = tep_db_fetch_array($featured_products_query)) {
  // $num ++;
  // if ($num == 1) {
    // new contentBoxHeading($info_box_contents); 
   //}
// If on special show regular and sale price
 	//if (tep_not_null($featured_products['specials_new_products_price'])) {
     $products_price = '<s>' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</s><br>';
    $p_name = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] . '</a>';

  $p_price = '<span class="productSpecialPrice">'.$currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])).'</span>';

 $p_details = '<a href="' . tep_href_link('product_info.php?products_id='.$p_id) . '">'.tep_image_button('button_details.gif', '', ' class="btn1"').'</a>';


    	$products_price .= '<span class="productSpecialPrice">' . $currencies->display_price($featured_products['specials_new_products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</span>';


   //} else {
    // $products_price = $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id']));
  // }
//    $info_box_contents[$row][$col] = array('align' => 'center',
//                                          'params' => 'class="smallText" width="33%" valign="top"',
//                                          'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] . '</a><br>' . $products_price);
//    $col ++;
//    if ($col > 2) {
//      $col = 0;
//      $row ++;
//    }
//  }
//  if($num) {
//      
//      new contentBox($info_box_contents);
//  }
//} else {
//   // If it's disabled, then include the original New Products box
//   // include (DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); // disable for dont show if desactive the feature module
//}

if($product_info['products_quantity'] <= 0 || $product_info['products_status']==0) {
 $p_buy_now = tep_image_button('button_sold_out.gif', IMAGE_BUTTON_SOLD_OUT) . ' ';
} else {
  $p_buy_now = '<a href="'.tep_href_link("products_new.php","action=buy_now&products_id=".$p_id).'">'.tep_image_button('button_add_to_cart1.gif', '', ' class="btn2"').'</a>';
}

$info_box_contents[$row][$col] = array('align' => 'center',
                                          'params' => ' style="width:25%;"',
                                          'text' => '
'.tep_draw_prod2_top().'
<table cellpadding="0" cellspacing="0" border="0">
	<tr><td class="name name2_padd">'.$p_name.'</td></tr>
	<tr><td class="pic2_padd"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td></tr>
	<tr><td class="price2_padd">'.$p_price.'</td></tr>
	<tr><td class="button2_padd button_marg">'.$p_details.' '.$p_buy_now .'</td></tr>
</table>
'.tep_draw_prod2_bottom().'');

   $col ++;
   if ($col > 3) {
     $col = 0;
     $row ++;
   }
 }
 new contentBox($info_box_contents);
 }
?>
<!-- featured_products_eof //-->

 

Please Help if u can.

Share this post


Link to post
Share on other sites

Problem solved.

 

It would be handy to know what solved it to save needless posting in the future :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×