Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

"Out of Stock" on product listing in columns page


iamcanadian

Recommended Posts

Here it is:

 

if ( tep_get_products_stock($listing['products_id']) < 1 ) {

$prod_quantity_display = 'Out Of Stock' ;

$lc_text = ' <font color=red><b>' . prod_quantity_display . '</b></font><br>';

}

 

Put the code above anywhere you want it to show on your page.

I put it in the

'case 'PRODUCT_LIST_BUY_NOW':' section

 

Hopefully this is enough, if not I could send you my product_listing.php, just let me know.

Link to comment
Share on other sites

Oops,

 

Forgot to mention that you should put the buy now button code in the else of the if statement. When you do it the way i implemented it the buy now button is not visible when products are out of stock otherwise the customer has to remove the items that are out of stock in the shoppingcart before checking out.

Link to comment
Share on other sites

  • 3 weeks later...

Sorry for the delay in responding.. Here is my complete code for the 'Buy It Now' Section in my product_listing_col.php Only thing is now I have a problem with my sale prices displaying -- not sure if this change caused it or not???

 

// Begin Buy Now button with attributes and quantity mod 
         if (PRODUCT_LIST_BUY_NOW) { 
     $lc_align = 'center'; 
	 $lc_text .= '<form name="buy_now_' . $listing['products_id'] . '" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now_form', 'NONSSL') . '">';
          //added for for Sold Out message
  if ( tep_get_products_stock($listing['products_id']) < 1 ) { 
 $lc_text .= ' <font color=red><b>';
	 $lc_text .= 'SOLD OUT';
 $lc_text .= '</b></font><br>';
 //eof Sold Out message
 }else{ 	 $lc_text .= '<input type="text" name="cart_quantity" value="1" maxlength="6" size="2">'; 
	 $lc_text .= '<input type="hidden" name="products_id" value="' . $listing['products_id'] . '">' . tep_image_submit('button_buy_now.gif', TEXT_BUY . $listing['products_name'] . TEXT_NOW) . ' ';
    }
	 $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . $listing['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "'"); 
           $product_info = tep_db_fetch_array($product_info_query); 
           $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); 
           $products_attributes = tep_db_fetch_array($products_attributes_query); 
           if ($products_attributes['total'] > 0) { 
           $lc_text .= '<table border="0" cellpadding="0" cellspacing"0">'; 
           $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); 
           while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { 
           $selected = 0; 
           $products_options_array = array(); 
           $lc_text .= '<tr><td class="main">' . $products_options_name['products_options_name'] . ':</td><td>' . "\n"; 
           $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $listing['products_id'] . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'"); 
           while ($products_options = tep_db_fetch_array($products_options_query)) { 
           $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']); 
           if ($products_options['options_values_price'] != '0') { 
           $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; 
         } 
       } 
       $lc_text .= tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']]); 
       $lc_text .= '</td></tr>'; 
     } 
     $lc_text .= '</table>'; 
   } 
     $lc_text .= '</form>'; 
    }       //break; 
// End Buy Now button mod

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...