Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Notify when product is in stock - in product description


mdtaylorlrim

Recommended Posts

This is a quick and easy code drop in to add a statement telling the customer that the item is not in stock, and a link to click to notify when the item is in stock. It also prompt them to register so it may prompt more registrations, or drive them away, who knows...

 

And if the item is in stock it says how many...

 

 

Around line 175 of the product_info.php file, find this:

     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>

 

and add this BEFORE, not breaking the table tags... the code below adds a complete new table row.

<!-- 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 $product_info['products_quantity'] . " available. Ships in one day!";
}      ?>
     <BR>
             </td>
           </tr>
<!-- end add in for click to notify when in stock -->

 

If your store does NOT show product quantities in stock this may not work. Haven't tried it on one that doesn't.

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

I suppose you could add a overall IF statment checking if stock level is in use or products are marked out of stock.

 

 

if (STOCK_CHECK == 'true') {

 

if (STOCK_MARK_PRODUCT_OUT_OF_STOCK == 'true') {

 

if (STOCK_ALLOW_CHECKOUT == 'true') {

 

 

 

Just a suggestions if someone would like to modify it to their needs...

Link to comment
Share on other sites

This is a quick and easy code drop in to add a statement telling the customer that the item is not in stock, and a link to click to notify when the item is in stock. It also prompt them to register so it may prompt more registrations, or drive them away, who knows...

 

And if the item is in stock it says how many...

 

 

Around line 175 of the product_info.php file, find this:

     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>

 

and add this BEFORE, not breaking the table tags... the code below adds a complete new table row.

<!-- 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 $product_info['products_quantity'] . " available. Ships in one day!";
}      ?>
     <BR>
             </td>
           </tr>
<!-- end add in for click to notify when in stock -->

 

If your store does NOT show product quantities in stock this may not work. Haven't tried it on one that doesn't.

Thanks for the coding works very well even when you take away the stock number. Just a couple of questions The first is an easy one I think. what do you do to make the number in stock that is shown in echo $product_info['products_quantity'] . " available. Ships in one day!"; into bold i have changed one bit "<b> available. Ships in one day!</b>" which takes care of the wording, but the number before I'm not sure about. The second question is what about a language that is not English? is there a way to swop from one to another

 

Regards Mel

Link to comment
Share on other sites

This is exactly what I'm looking for.

I've tried adding the code where indicated... but when I go to the product it doesn't show up. ie. It doesn't appear that anything has changed.

 

Not sure if this is what the issue is or not.

- I have the product qty listed as 0.

- I have also disabled to show the product qty. But, have tried enabling to show qty with same result.

 

Not sure what I'm missing. Thanks for any help.

 

- MODIFIED -

Now here's something odd.

It does work on some of the products and not on some of the others.

I checked both attributes for each item and they are the same.

What other reason would it show up on some and not others?

That "Can" you're about to open... has worms!

Don't say I didn't worn ya.

n. pl. cans of worms Informal - A source of unforeseen and troublesome complexity.

Link to comment
Share on other sites

I see part of the problem...

 

It only shows up on those items that have had reviews written on them.

If there is no review on them it does not show the change.

That "Can" you're about to open... has worms!

Don't say I didn't worn ya.

n. pl. cans of worms Informal - A source of unforeseen and troublesome complexity.

Link to comment
Share on other sites

Sorry for all the posts...

 

Here's what I did to get it to work... not sure what the exact problem was.

 

find this:

<?php
   $reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
   $reviews = tep_db_fetch_array($reviews_query);
   if ($reviews['count'] > 0) {

 

add before:

<table cellpadding="0" cellspacing="4" border="0">
 <!-- 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 item is available and ready to ship within two business days!";
}      ?>
     <BR>
             </td>
           </tr>
<!-- end add in for click to notify when in stock -->
  </table>

 

All works great now thanks for the mod!

That "Can" you're about to open... has worms!

Don't say I didn't worn ya.

n. pl. cans of worms Informal - A source of unforeseen and troublesome complexity.

Link to comment
Share on other sites

I see part of the problem...

 

It only shows up on those items that have had reviews written on them.

If there is no review on them it does not show the change.

Then you likely put it in the wrong place...

 

A lot of code is repeated and it is important to get it in the right place, around line 175, but i realize that different contributions and custom changes could have changed that number considerably. Maybe I should have included a little more code...

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 you likely put it in the wrong place...

 

A lot of code is repeated and it is important to get it in the right place, around line 175, but i realize that different contributions and custom changes could have changed that number considerably. Maybe I should have included a little more code...

 

I've tested the "link to click to notify when the item is in stock" by logging in myself but no e-mail arrived where do I look to see who has been sent an e-mail?. Or do I have to download an addon?

 

Regards Mel

Link to comment
Share on other sites

I've tested the "link to click to notify when the item is in stock" by logging in myself but no e-mail arrived where do I look to see who has been sent an e-mail?. Or do I have to download an addon?

 

Regards Mel

No add on required. It uses the same code as the stock osC Notify for Updates to this product routines.

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

No add on required. It uses the same code as the stock osC Notify for Updates to this product routines.

 

Cheers one less thing to worry about but the stock notify for updates never worked I have been meaning to have a look at them , but there does seem to be an issue with them when you google.

 

Regards Mel

Link to comment
Share on other sites

Cheers one less thing to worry about but the stock notify for updates never worked I have been meaning to have a look at them , but there does seem to be an issue with them when you google.

 

Regards Mel

 

Newsletter in admin /write new newsletter/change dropdown box heading/ write what products have been restocked send

 

simple when you know where to look I have never noticed the dropdown box before.

 

Regards Mel

Link to comment
Share on other sites

  • 9 months later...

Archived

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

×
×
  • Create New...