Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help with "out of stock" display option


isfapol

Recommended Posts

Hello, I have been looking for this for hours with no luck.

 

1- I am trying to show that an item is out of stock in the catalog area (categories, new products, etc), not just in the shopping cart. Maybe under the price or replacing the price.

 

2- Inside the shopping cart and in the product description, how can I show the quantity available in stock for an item.

 

3- In the new products box on the main page, I would like to have more vertical separation between objects. I think the price of the product above is too close to the picture of the product below.

 

Thank you, thank you

Link to comment
Share on other sites

Hello, I have been looking for this for hours with no luck.

 

1- I am trying to show that an item is out of stock in the catalog area (categories, new products, etc), not just in the shopping cart. Maybe under the price or replacing the price.

 

2- Inside the shopping cart and in the product description, how can I show the quantity available in stock for an item.

 

3- In the new products box on the main page, I would like to have more vertical separation between objects. I think the price of the product above is too close to the picture of the product below.

 

Thank you, thank you

 

even i was looking for this solution.

Link to comment
Share on other sites

Around line 146 of the product_info.php (your line number will vary based on installed add-ons) I modified to this...

 

 

<?php     // This is about line 146
     $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='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
     while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
       $products_options_array = array();
       $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 = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$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'])) .') ';
         }
       }

       if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
         $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
       } else {
         $selected_attribute = false;
       }
?>
           <tr>
             <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
             <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td>
           </tr>
<?php
     }
?>
         </table>
<?php
   }
?>
       </td>
     </tr>
<!-- add in for click to notify when in stock -->
           <tr>
             <td align=center>
                 <?php
                 if ($product_info['products_quantity'] == 0) {
                    if (tep_session_is_registered('customer_id')) {
     $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and customers_id = '" . (int)$customer_id . "'");
     $check = tep_db_fetch_array($check_query);

     $notification_exists = (($check['count'] > 0) ? true : false);
   } else {
     $notification_exists = false;
   }
echo "<font color=red><B>*** Temporarily out of stock. ***</b></font><BR>";
   if ($notification_exists == true) {
     echo '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify_remove', $request_type) . '">Notify me when this item is in stock.</a>';
   } else {
     echo '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">Notify me when this item is in stock.</a>';
   }
}  else {
     echo "This product is available from our warehouse and usually ships in one day!<br>Local customers can call 555-555-5555 to check in-store availability.";
}      ?>
     <BR>
             </td>
           </tr>
<!-- end add in for click to notify when in stock -->
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php

Community Bootstrap Edition, Edge

 

Avoid the most asked question. See How to Secure My Site and How do I...?

Link to comment
Share on other sites

Then, just after that where you see the Reviews button routine, I modified my shop to show an out of stock button or in stock button as applicable, and changed by add to cart button to a non clickable out of stock button when applicable with this edit...

 

?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
               <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
<-- add in for out of stock/in stock button, and replaced add to cart button with out of stock button when stock qty was 0  -->
                 <td align=center>
               <?php if ($product_info['products_quantity'] == 0) {
               echo tep_image_button('button_out_of_stock.gif', IMAGE_BUTTON_OUT_OF_STOCK);
               } else {
               echo tep_image_button('button_in_stock.gif', IMAGE_BUTTON_IN_STOCK);
               }
               ?>
               </td>
               <td class="main" align="right">
               <?php if ($product_info['products_quantity'] == 0) {
               echo tep_image_button('button_out_of_stock.gif', IMAGE_BUTTON_OUT_OF_STOCK);
               } else {
               echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART);
               }
               ?>
               </td>
<-- end edit for out of stock buttons -->
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>

Community Bootstrap Edition, Edge

 

Avoid the most asked question. See How to Secure My Site and How do I...?

Link to comment
Share on other sites

Thanks for the reply. I will try this.

 

Any help with these?

 

2- Inside the shopping cart, can I show the quantity available in stock for an item. (Ej: Only 4 left in stock)

 

3- In the new products box on the main page, I would like to have more vertical separation between objects. I think the price of the product above is too close to the picture of the product below.

 

Thanks

Link to comment
Share on other sites

Then, just after that where you see the Reviews button routine, I modified my shop to show an out of stock button or in stock button as applicable, and changed by add to cart button to a non clickable out of stock button when applicable with this edit...

 

?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
               <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
<-- add in for out of stock/in stock button, and replaced add to cart button with out of stock button when stock qty was 0  -->
                 <td align=center>
               <?php if ($product_info['products_quantity'] == 0) {
               echo tep_image_button('button_out_of_stock.gif', IMAGE_BUTTON_OUT_OF_STOCK);
               } else {
               echo tep_image_button('button_in_stock.gif', IMAGE_BUTTON_IN_STOCK);
               }
               ?>
               </td>
               <td class="main" align="right">
               <?php if ($product_info['products_quantity'] == 0) {
               echo tep_image_button('button_out_of_stock.gif', IMAGE_BUTTON_OUT_OF_STOCK);
               } else {
               echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART);
               }
               ?>
               </td>
<-- end edit for out of stock buttons -->
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>

Works well except you forgot the ! at the beginning and at the end. ;)

Also just one small thing I have got two "add to carts" and one "in stock" in the product info page when there is stock and two out of stocks and one "add to cart" when there is no stock. otherwise a great bit of coding.

 

Regards Mel

Link to comment
Share on other sites

Works well except you forgot the ! at the beginning and at the end. ;)

Also just one small thing I have got two "add to carts" and one "in stock" in the product info page when there is stock and two out of stocks and one "add to cart" when there is no stock. otherwise a great bit of coding.

 

Regards Mel

Oops...you're right, those html comments should start with <!-- and end with -->

 

 

To add the quantity in stock it can be done on this line.

 

echo "We have " . $product_info['products_quantity'] . " of these available from our warehouse and usually ships in one day!<br>Local customers can call 555-555-5555 to check in-store availability.";

Community Bootstrap Edition, Edge

 

Avoid the most asked question. See How to Secure My Site and How do I...?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...