defender39 Posted January 13, 2004 Share Posted January 13, 2004 I want to somehow change the quantity display to show SOLD OUT if the quantity is zero...I prefer to not show exact quantities of items in stock but I do need to display sold out in the search results too. I want to either make the buy it now button change to sold out if product is less than 1 or change the case of PRODUCT_LIST_QUANTITY to something I have similar in my products_info page Which is this: $prod_quantity = $product_info_values['products_quantity']; switch ($prod_quantity) { case 0: print "<center><b>SOLD OUT</b></center>"; break; case 1: print "Only 1 in stock"; break; case 2: print "Only 2 in stock"; break; case 3: print "Only 3 in stock"; break; case 4: print "Only 4 in stock"; break; default: print ""; } Here is the original code that I believe I need to change. switch ($column_list[$col]) { case 'PRODUCT_LIST_MODEL': $select_column_list .= 'p.products_model'; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'm.manufacturers_name'; break; case 'PRODUCT_LIST_QUANTITY': $select_column_list .= 'p.products_quantity'; break; case 'PRODUCT_LIST_IMAGE': $select_column_list .= 'p.products_image'; break; case 'PRODUCT_LIST_WEIGHT': $select_column_list .= 'p.products_weight'; break; } Any help ? Thank you . Quote Link to comment Share on other sites More sharing options...
defender39 Posted January 13, 2004 Author Share Posted January 13, 2004 still looking on help with this... looking at the code I dont see where it creates the button for buyitnow on advanced_search_results.php Am I missing where some functions are? Quote Link to comment Share on other sites More sharing options...
defender39 Posted January 14, 2004 Author Share Posted January 14, 2004 Ok...so I was looking in the wrong spot... Its includes/modules/product_listing.php around lines 130 here is the code case 'PRODUCT_LIST_PRICE': $lc_align = 'right'; if (tep_not_null($listing['specials_new_products_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 { $lc_text = ' ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . ' '; } break; case 'PRODUCT_LIST_QUANTITY': $lc_align = 'right'; $lc_text = ' ' . $listing['products_quantity'] . ' '; break; case 'PRODUCT_LIST_WEIGHT': $lc_align = 'right'; $lc_text = ' ' . $listing['products_weight'] . ' '; break; So far I still have no luck...I would really appreciate some assistance on this one. Quote Link to comment Share on other sites More sharing options...
defender39 Posted January 14, 2004 Author Share Posted January 14, 2004 This is what I am trying and I just get empty results... case 'PRODUCT_LIST_QUANTITY': $lc_align = 'right'; if ($listing['products_quantity']) < 1 { $lc_text = 'Out of Stock'; } else { $lc_text = ' ' . $listing['products_quantity'] . ' '; break; Quote Link to comment Share on other sites More sharing options...
defender39 Posted January 14, 2004 Author Share Posted January 14, 2004 Now I am trying this with zero luck.. case 'PRODUCT_LIST_QUANTITY': $lc_align = 'right'; switch ($listing['products_quantity']) { case 0: $lc_text = ' ' . $listing['products_quantity'] . ' '; break; default: $lc_text = ' ' . $listing['products_quantity'] . ' '; break; } Desperation is setting in. Quote Link to comment Share on other sites More sharing options...
Guest Posted January 14, 2004 Share Posted January 14, 2004 case 'PRODUCT_LIST_QUANTITY': $lc_text = TABLE_HEADING_QUANTITY; $lc_align = 'right'; $prod_quantity = $listing['products_quantity']; $minus = ($prod_quantity <= 0); $red = ($prod_quantity == NULL); $yellow = ($prod_quantity <= 2); $green = ($prod_quantity > 2); switch ($prod_quantity) { case $minu: $img = tep_image(DIR_WS_ICONS . 'icon_status_red.gif', TEXT_NOT_AVAIBLE).' '.TEXT_NOT_AVAIBLE; break; case $red: $img = tep_image(DIR_WS_ICONS . 'icon_status_red.gif', TEXT_NOT_AVAIBLE).' '.TEXT_NOT_AVAIBLE; break; case $yellow : $img = tep_image(DIR_WS_ICONS . 'icon_status_yellow.gif', TEXT_FEW_QTY).' '.TEXT_FEW_QTY; break; case $green : $img = tep_image(DIR_WS_ICONS . 'icon_status_green.gif', TEXT_BIG_QTY).' '.TEXT_BIG_QTY; break; } $lc_text = $img; break; This is your solution. It will show icon (of course, if you want it) and text beside it. But you have to put language variables and icons in respectitive folders. Quote Link to comment Share on other sites More sharing options...
defender39 Posted January 14, 2004 Author Share Posted January 14, 2004 (edited) I love you guys...it works really well... can you contrib this so other can see it? also I see something about icon_status_red.gif I dont have these? Should I make some? Guess I will see what happens anyone using this should add to your english.php define('TEXT_FEW_QTY', 'Low Stock'); define('TEXT_BIG_QTY', 'In Stock'); define('TEXT_NOT_AVAIBLE', 'Sold Out'); Edited January 14, 2004 by defender39 Quote Link to comment Share on other sites More sharing options...
Guest Posted January 14, 2004 Share Posted January 14, 2004 (edited) Just add some kind of icons in your images/icons folder. Or if you like you can use mines: Enyoj! Edited January 14, 2004 by XPfrik Quote Link to comment Share on other sites More sharing options...
Guest Posted January 15, 2004 Share Posted January 15, 2004 I added the code and nothing happened. I just want the text to show. where to i add the language variables, etc.. to make this happen?? thanks for your helps!! :lol: Quote Link to comment Share on other sites More sharing options...
Guest Posted January 15, 2004 Share Posted January 15, 2004 here is my code for the product listing page: <?php/* $Id: product_listing.php,v 1.44 2003/06/09 22:49:59 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ $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') ) ) { ?> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="smallText" align="left"> <?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?> </td> <td class="smallText" 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 } $list_box_contents = array(); 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 = 'left'; 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 = ''; $lc_text = $listing['products_model']; break; case 'PRODUCT_LIST_NAME': $lc_align = 'left'; if (isset($HTTP_GET_VARS['manufacturers_id'])) { $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 { $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 = ''; $lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a> '; break; case 'PRODUCT_LIST_PRICE': $lc_align = 'right'; if (tep_not_null($listing['specials_new_products_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 { $lc_text = ' ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . ' '; } break; case 'PRODUCT_LIST_QUANTITY': $lc_text = TABLE_HEADING_QUANTITY; $lc_align = 'right'; $prod_quantity = $listing['products_quantity']; $minus = ($prod_quantity <= 0); $red = ($prod_quantity == NULL); $yellow = ($prod_quantity <= 2); $green = ($prod_quantity > 2); switch ($prod_quantity) { case $minu: $img = tep_image(DIR_WS_ICONS . 'icon_status_red.gif', TEXT_NOT_AVAIBLE).' '.TEXT_NOT_AVAIBLE; break; case $red: $img = tep_image(DIR_WS_ICONS . 'icon_status_red.gif', TEXT_NOT_AVAIBLE).' '.TEXT_NOT_AVAIBLE; break; case $yellow : $img = tep_image(DIR_WS_ICONS . 'icon_status_yellow.gif', TEXT_FEW_QTY).' '.TEXT_FEW_QTY; break; case $green : $img = tep_image(DIR_WS_ICONS . 'icon_status_green.gif', TEXT_BIG_QTY).' '.TEXT_BIG_QTY; break; } $lc_text = $img; break; case 'PRODUCT_LIST_WEIGHT': $lc_align = 'right'; $lc_text = ' ' . $listing['products_weight'] . ' '; break; case 'PRODUCT_LIST_IMAGE': $lc_align = 'center'; if (isset($HTTP_GET_VARS['manufacturers_id'])) { $lc_text = '<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 { $lc_text = ' <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'; $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_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> '; break; } $list_box_contents[$cur_row][] = array('align' => $lc_align, 'params' => 'class="productListing-data"', 'text' => $lc_text); } } new productListingBox($list_box_contents); } else { $list_box_contents = array(); $list_box_contents[0] = array('params' => 'class="productListing-odd"'); $list_box_contents[0][] = array('params' => 'class="productListing-data"', 'text' => TEXT_NO_PRODUCTS); new productListingBox($list_box_contents); } if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) { ?> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="smallText" align="left"> <?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?> </td> <td class="smallText" 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 } ?> and i added the define('TEXT_FEW_QTY', 'Low Stock'); define('TEXT_BIG_QTY', 'In Stock'); define('TEXT_NOT_AVAIBLE', 'Sold Out'); to english.php the store can been seen here: http://www.sonicterror.net/catalog/index.php?cPath=21 the item ST002 :::: Line 47 / Rusuden :: Parcinx Mind should be showing up as sold out.. please help!! Quote Link to comment Share on other sites More sharing options...
defender39 Posted January 15, 2004 Author Share Posted January 15, 2004 Have you changed in the admin to display quantity under product listing? You need to do that first. Quote Link to comment Share on other sites More sharing options...
Guest Posted January 15, 2004 Share Posted January 15, 2004 Thanks! THAT WORKED!!! :lol: http://www.sonicterror.net/catalog/index.php?cPath=21 How can I get the "ST005 :::: Joseph Nothing / Pale :: The Empire's Last Stand" product to be aligned right instead of the "S" in the word stand jutting out to the left.. i think it look awful! Quote Link to comment Share on other sites More sharing options...
defender39 Posted January 15, 2004 Author Share Posted January 15, 2004 (edited) Shorten the name...its too long. Edited January 15, 2004 by defender39 Quote Link to comment Share on other sites More sharing options...
johnnymke Posted January 23, 2004 Share Posted January 23, 2004 Some should wrap this up as a contrib. I was looking for something like this in contribs like listing_status-1.0.0 and products_on_order1.1a. however it seems like support for those mods is non-exsistant, at least in the forums... Can this change in be applied in admin/categories.php as well? Like... <?php if ($products['products_status'] == '1') { echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=0&pID=' . $products['products_id'] . '&cPath=' . $cPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>'; } else { echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=1&pID=' . $products['products_id'] . '&cPath=' . $cPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a> ' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10); } ?> to <?php if ($products['products_quantity'] > 2) { echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=0&pID=' . $products['products_quantity'] . '&cPath=' . $cPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>'; } else { if ($products['products_quantity'] <= 2) { echo tep_image(DIR_WS_IMAGES . 'icon_status_yellow.gif', IMAGE_ICON_STATUS_YELLOW, 10, 10) . ' '; } else { echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=1&pID=' . $products['products_id'] . '&cPath=' . $cPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a> ' . tep_image(DIR_WS_IMAGES . 'icon_status_yellow.gif', IMAGE_ICON_STATUS_YELLOW, 10, 10) . '</a> ' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10); } } ?> I dunno. Im sure I have some syntax wrong there but you get the idea...Not a huge feature but could be helpful... Great teamwork none the less... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.