Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

changing search results to say sold out


defender39

Recommended Posts

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 .

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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;

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by defender39
Link to comment
Share on other sites

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:

Link to comment
Share on other sites

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!!

Link to comment
Share on other sites

  • 2 weeks later...

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...

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...