Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Ever installed the Automatic Stock Notification contrib?


Guest

Recommended Posts

It's a simple, straightforward contrib. Add a chunk of code to one file, change the store name in the e-mail part to reflect the name of your store, and that's it.

 

I had an item out of stock and clicked to receive product notifications on it. Presumably, this contrib is designed to rifle off an e-mail to me once the product is put back in stock.

 

I didn't get an e-mail AND it wiped out the notifications box, period...on every screen for every product.

 

Has anyone else used this before?

 

Andrea

Link to comment
Share on other sites

Well, I fixed my 'disappearing' Product Notifications box. In the attached code, I had put the beginning of the contrib...where it reads //Begin Automatic Customer Stock Update Notification, underneath the line of code it is now right smack next to....and my boxes came back.

 

But, will someone please look at the end of the code...where it says...// End Automatic Customer Stock Update Notification

 

The next few lines of code underneath that are part of the original catalog.php file Do I have that properly spaced or is there something there I need to fix? The end of the contrib says nothing about how far apart the remaining lines of code should begin after the Contrib ends. I have this feeling it's something nitpicky like that.

 

The e-mails must be generated somehow, as when I change the quantity of the item I selected to received notifications on...the item disappears from my list of items I want to be notified on. But, I'm not getting any e-mails...either in my inbox nor my spam folder.

 

Andrea

 

 tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$current_category_id . "')");
	  } elseif ($action == 'update_product') {// Begin Automatic Customer Stock Update Notification


 if ($HTTP_POST_VARS['products_quantity'] > 0){

	$audience = array();

	$products_query = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id and pn.products_id in ( '" . (int)$products_id . "')");
	while ($products = tep_db_fetch_array($products_query)) {
	 $audience[$products['customers_id']] = array('firstname' => $products['customers_firstname'],
												   'lastname' => $products['customers_lastname'],
												   'email_address' => $products['customers_email_address']);
	}

  $email_order = $products_name; 

  $mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
  $mimemessage->add_text('Your product is now in stock. Please visit http://mywebsite.com if you would like to purchase. Thanks!');
  $mimemessage->build_message();

  reset($audience);
  while (list($key, $value) = each ($audience)) {
$mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], 'My Website', 'pbrs', 'From My Website: Your requested item is here!', $email_order);

tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . "  where products_id = '" . $products_id . "' ");
   }
}


// End Automatic Customer Stock Update Notification
		$update_sql_data = array('products_last_modified' => 'now()');

		$sql_data_array = array_merge($sql_data_array, $update_sql_data);

		tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");
	  }

 

And, yes...I did change the 'My Website' bit to reflect the name of my store, in every place it's referenced. No e-mail, though.

Link to comment
Share on other sites

Replying to my own posts night after night is really getting old.

 

I did one last thing to try and correct it.

 

Someone else 're-wrote' the contrib and added a few things, so, I uninstalled the first mess from my categories.php file (I know I wrote catalog.php last time, sorry...I'm kind of tired from messing with it) and I installed the latest and greatest version of the contrib.

 

Then I went in to Admin and attempted to change the quantity of an item from 1 to 0 and my screen just filled with errors, one after the other.

 

Well, I give up. I don't know. Maybe this contrib just isn't compatible with OSC 2.2? So, it's history.

 

If someone uses the Product Notifications box, they'll never hear from me. This sucks.

 

I know how to do it....the HARD way, in Admin. But, that process is for the birds.

 

Andrea

Link to comment
Share on other sites

I guess I just can't let it go, and FINALLY, I found what was wrong with this contrib.

 

Too many fields. Finally found something about it on the contribs forum. It WORKS now! But, the e-mail it generates when the stock quantity is changed from zero to 1 is...pretty ugly. Looks like this:

 

Dear Customer,

According to your MY STORE NAME Product Notifications request ... We wish to inform you that <a href="http://mysite.com/product_info.php?products_id=215">6-1-93 Soap Opera Magazine COLLEEN ZENK-BENJAMIN HENDRICKSON</a> is now in stock.

Please visit <a href="http://mysite.com/">MY STORE NAME</a> if you would like to make a purchase. Thank you for your continued support!

 

I changed all of the names, including my store, but all of these tags...the <a href> tag and the </a> tag and whatnot actually appear in the e-mail notification. How do I clean that up? Here's the contrib addition:

 

// Begin Automatic Customer Stock Update Notification

	  if ($HTTP_POST_VARS['products_quantity'] > 0){			

		$audience = array();

		$products_query = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id and pn.products_id in ( '" . (int)$products_id . "')");			

	  while ($products = tep_db_fetch_array($products_query)) {
		$audience[$products['customers_id']] = array('firstname' => $products['customers_firstname'],
													 'lastname' => $products['customers_lastname'],
													 'email_address' => $products['customers_email_address']);
	  }		  

		$product_query_raw = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'"); 
		$product = tep_db_fetch_array($product_query_raw);

		$customers_query_raw = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id and pn.products_id in ( '" . (int)$products_id . "')");
		$customer = tep_db_fetch_array($customers_query_raw);			

		$mimemessage = new email(array('X-Mailer: YoutStore Systems Mailer'));
		$mimemessage->add_text('Stock Update: ' . $product['products_name'] . ' - Model [ '. $product['products_model'] . ' ]' . "\n\n" . 'Dear ' . $customer['customers_firstname'] . ' ' . $customer['customers_lastname'] . ',' . "\n" . 'According to your ' . STORE_NAME . ' Product Notifications request ... We wish to inform you that ' . '' . '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . 'product_info.php' . '?products_id=' . $products_id . '">' . $product['products_name'] . '</a>' . ' is now in stock.'  . "\n" . 'Please visit' . ' ' . '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">' . STORE_NAME . '</a>' . ' if you would like to make a purchase. Thank you for your continued support!');
		$mimemessage->build_message();

	  reset($audience);
	  while (list($key, $value) = each ($audience)) {
		$mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, 'Now In Stock - Your requested product notification for ' . $product['products_name'], $email_order);

		tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . "  where products_id = '" . $products_id . "' ");
		}
	  }
// End Automatic Customer Stock Update Notification

 

Can someone PLEASE advise me on how to clean it up so the e-mail looks clean and crisp, no html tags showing? Thanks!

 

Andrea

Link to comment
Share on other sites

  • 1 month later...

Hi Andrea,

 

can you tell me how you managed to get this one working, I'm similar to you - would love to use it - it's driving me nuts! and when I install the original contrib - it works fine - but the email is pretty average and there is no reference to the product - I like the updated contribution and it's ability to include the product in the email, but I can't get this one to work - I get errors when I update the products in admin and can't really get past that.

 

Any suggestions would be appreciated.

 

Then I'll love to know the answer to tidying up the code in the email - when I manage to get that far!

 

cheers!

Maria

Link to comment
Share on other sites

Hi,

 

I'm using this contrib and it doesn't work 100%... :(

 

When I have more than 1 user on the notification list of a product, every user on that list receive the same first name and last name of the first user. The first user name is ok, but all the rest users have also that name...

 

Does this happend to anyone else??

Link to comment
Share on other sites

Hi - just tested it and yep - I get the same - I'll disable the customer name in the notification email until anyone else can shine some more light on it as I don't know enough about it to fix it.

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...
Hi,

 

I'm using this contrib and it doesn't work 100%... :(

 

When I have more than 1 user on the notification list of a product, every user on that list receive the same first name and last name of the first user. The first user name is ok, but all the rest users have also that name...

 

Does this happend to anyone else??

 

 

In this section:

$mimemessage->add_html('In-Stock Update: <a href="' . HTTP_SERVER . DIR_WS_CATALOG . 'product_info.php' . '?products_id=' . $products_id . '">' . $product['products_name'] . '</a> is now back in stock!' . "\n\n" . 'Dear ' . $customer['customers_firstname'] . ' ' . $customer['customers_lastname'] .  "\n\n" . 'You asked us to notify you when we received ' . $product['products_name'] . ' back in stock again, and we\'ve just restocked!  We just got in ' . $HTTP_POST_VARS['products_quantity'] . ' of these, but we can\'t guarantee how long they will last.  If you are still looking for some, get some fast before they\'re gone!'  . "\n\n" . 'Have a great day!' . "\n\n" . '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">' . STORE_NAME . '</a>');

 

change this:

'Dear ' . $customer['customers_firstname'] . ' ' . $customer['customers_lastname'] .  "\n\n" . 'You asked us to notify you when we received ' .

 

to this:

'Hello!' . "\n\n" . 'You asked us to notify you when we received ' .

 

My text may be a little different, but you get the idea.

 

This will take out the customer name from the email body.

 

-jared

Link to comment
Share on other sites

  • 2 months later...

Hello,

 

i've installed the "contribution "quick_stock_update_v2-5_1" which allows a much easier handling of the stock.

 

I would like to implement the Automatic Stock notification feature into this contribution.

 

So here is what i had to do to get the Automatic Stock notification running on the original store:

 

In catalog/admin/categories.php find:

 

 

tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$current_category_id . "')");

} elseif ($action == 'update_product') {

 

Insert this directly after it (be sure to make changes to store name, etc. I have left them as mine so you can see how it works):

 

// Begin Automatic Customer Stock Update Notification

 

if ($HTTP_POST_VARS['products_quantity'] > 0){

 

$audience = array();

 

$products_query = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id and pn.products_id in ( '" . (int)$products_id . "')");

 

while ($products = tep_db_fetch_array($products_query)) {

$audience[$products['customers_id']] = array('firstname' => $products['customers_firstname'],

'lastname' => $products['customers_lastname'],

'email_address' => $products['customers_email_address']);

}

 

$product_query_raw = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_spec, pd.products_url, p.products_quantity, p.products_model, p.products_upc, p.products_image, p.products_pdfupload, p.products_image_pop, p.products_inventory_cost, p.products_retail_price, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_date_expire, p.products_status, p.manufacturers_id, p.minorder from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'");

$product = tep_db_fetch_array($product_query_raw);

 

$customers_query_raw = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id and pn.products_id in ( '" . (int)$products_id . "')");

$customer = tep_db_fetch_array($customers_query_raw);

 

$mimemessage = new email(array('X-Mailer: YoutStore Systems Mailer'));

$mimemessage->add_text('Stock Update: ' . $product['products_name'] . ' - Model [ '. $product['products_model'] . ' ]' . "\n\n" . 'Dear ' . $customer['customers_firstname'] . ' ' . $customer['customers_lastname'] . ',' . "\n" . 'According to your ' . STORE_NAME . ' Product Notifications request ... We wish to inform you that ' . '' . '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . 'product_info.php' . '?products_id=' . $products_id . '">' . $product['products_name'] . '</a>' . ' is now in stock.' . "\n" . 'Please visit' . ' ' . '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">' . STORE_NAME . '</a>' . ' if you would like to make a purchase. Thank you for your continued support!');

$mimemessage->build_message();

 

reset($audience);

while (list($key, $value) = each ($audience)) {

$mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, 'Now In Stock - Your requested product notification for ' . $product['products_name'], $email_order);

 

tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $products_id . "' ");

}

}

// End Automatic Customer Stock Update Notification

 

The contribution "quick_stock_update_v2-5_1" uses this php scrip, where an who would i implement the above mod?

 

<?php

/*

quick_stockupdate.php v1.1 by Tomorn Kaewtong / http://www.phpthailand.com

MODIFIED quick_stockupdate.php v2.5 by G?nter Geisler / http://www.highlight-pc.de

 

Stand-alone Admin tool for osCommerce v2.2-CVS

 

A spin-off of my Quick DeActivate script so you can set a lot of quantities

in a single process. Also allows you to change the STATUS of the products

based upon quantities provided.

 

Released under the GPL licence.

*/

 

include('includes/application_top.php');

 

 

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="2" cellpadding="2">

<tr>

<?php

if ($menu_dhtml == false ) { // add for dhtml_menu

echo '<td width="' . BOX_WIDTH . '" valign="top">';

echo '<table border="0" width="' . BOX_WIDTH . '" cellspacing="1" cellpadding="1" class="columnLeft">';

echo '<!-- left_navigation //-->';

require(DIR_WS_INCLUDES . 'column_left.php');

echo '<!-- left_navigation_eof //-->';

echo '</table>';

echo '</td>';

} else {

 

}

?>

<!-- body_text //-->

<td width="100%" valign="top">

<table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td>

<table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td class="pageHeading"><?php echo QUICK_HEAD1 ?><br><?php echo tep_draw_separator('pixel_trans.gif', '100%', '4'); ?></td>

<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</tr>

</table>

</td>

</tr>

<tr>

<td>

<table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td valign="top">

<table border="0" width="100%" cellspacing="0" cellpadding="1">

<tr class="dataTableHeadingRow">

<td class="dataTableHeadingContent"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '1'); ?></td>

</tr>

<tr>

<td class="main"><?php echo QUICK_HEAD2 ?></td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

<tr>

<td>

<table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td>

<?php

if ($HTTP_POST_VARS['stock_update']) {

 

 

while (list($key, $items) = each($stock_update)) {

// update the quantity in stock

$sql = "UPDATE products SET products_quantity = '".$items['stock']."', products_model = '".$items['model']."', products_price = '".$items['price']."', products_weight = '".$items['weight']."' WHERE products_id = $key";

$update = tep_db_query($sql);

$stock_i++;

 

// we're de-re-activating the selected products

if ($HTTP_POST_VARS['update_status']) {

if ($items['stock'] >= 1 ) {

$dereac = tep_db_query("UPDATE products SET products_status = 1 WHERE products_id = $key");

$status_a++;

}else{

$dereac = tep_db_query("UPDATE products SET products_status = 0 WHERE products_id = $key");

$status_d++;

}

}

}

}

?>

<br><form method="post" action="quick_stockupdate.php">

<?php

// first select all categories that have 0 as parent:

$sql = tep_db_query("SELECT c.categories_id, cd.categories_name from categories c, categories_description cd WHERE c.parent_id = 0 AND c.categories_id = cd.categories_id AND cd.language_id = 1");

 

echo ' <table border="0">';

echo ' <tr>';

while ($parents = tep_db_fetch_array($sql)) {

// check if the parent has products

$check = tep_db_query("SELECT products_id FROM products_to_categories WHERE categories_id = '" . $parents['categories_id'] . "'");

 

$tree = tep_get_category_tree();

$dropdown= tep_draw_pull_down_menu('cat_id', $tree, '', 'onChange="this.form.submit();"'); //single

$all_list = ' <form method="post" action="quick_stockupdate.php"><th class="smallText" align="left" valign="top">Categories:<br>' . $dropdown . '</form></th>';

}

echo $all_list;

echo ' </tr>';

echo ' </table>';

echo ' </form>';

echo ' </td>';

echo ' </tr>';

echo ' </table>';

 

// see if there is a category ID:

if ($HTTP_POST_VARS['cat_id']) {

// start the table

echo ' <br><form method="post" action="quick_stockupdate.php">';

echo ' <table width="100%" border="0" cellspacing=2 cellpadding=2>';

 

// get all active prods in that specific category

 

$sql2 = tep_db_query("SELECT p.products_model, p.products_id, p. products_quantity, p.products_status, p.products_weight, p.products_price, pd.products_name from products p, products_to_categories ptc, products_description pd where p.products_id = ptc.products_id and p.products_id = pd.products_id and language_id = $languages_id and ptc.categories_id = '" . $HTTP_POST_VARS['cat_id'] . "' order by pd.products_name");

echo '<tr class="dataTableHeadingRow"><td class="dataTableContent" align="left"><b>' . QUICK_MODEL . '</b></td><td class="dataTableContent" align="left"><b>' . QUICK_ID . '</b></td><td class="dataTableContent" align="left"><b>' . QUICK_NAME . '</b></td><td class="dataTableContent" align="left"><b>' . QUICK_WEIGHT . '</b></td><td class="dataTableContent" align="left"><b>' . QUICK_PRICE . '</b></td><td class="dataTableContent" align="left"><b>' . QUICK_STOCK . '</b></td></tr>';

// added changes thowden 10/2004 stock_update becomes a multi-dim array

while ($results = tep_db_fetch_array($sql2)) {

echo '<tr class="dataTableRow"><td class="dataTableContent" align="left"><input type="text" size="16" name="stock_update[' . $results['products_id'] . '][model]" value="' . $results['products_model'] . '"><i>';

echo '</td><td class="dataTableContent" align="left">' . $results['products_id'] . '</td><td class="dataTableContent" align="left">' . $results['products_name'];

echo '</td><td class="dataTableContent" align="left"><input type="text" size="4" name="stock_update[' . $results['products_id'] . '][weight]" value="' . $results['products_weight'] . '"><i>';

echo '</td><td class="dataTableContent" align="left"><input type="text" size="6" name="stock_update[' . $results['products_id'] . '][price]" value="' . $results['products_price'] . '"><i>';

echo '</td><td class="dataTableContent" align="left"><input type="text" size="4" name="stock_update[' . $results['products_id'] . '][stock]" value="' . $results['products_quantity'] . '"><i>';

echo (($results['products_status'] == 0) ? '<font color="ff0000"><b>' . QUICK_INACTIVE . '</b></font>' : '<font color="009933"><b>' . QUICK_ACTIVE . '</b></font>');

echo '</i></td></tr>';

}

echo '</table><table border="0" width="100%" cellspacing=2 cellpadding=2><tr>';

echo '<input type="hidden" name="cat_id" value="' . $HTTP_POST_VARS['cat_id'] . '">';

echo '</tr><br><td align="center" colspan="10" class="smallText">';

echo '<input type="checkbox" name="update_status">' . QUICK_TEXT . '';

echo '<input type="submit" value="Update"></td></tr></form>';

} //if

?>

</tr></table>

</td>

</tr></table><center>

<a style="font-family:Verdana,Arial,Helvetica,sans-serif;font-size:xx-small;text-decoration:none;text-decoration:none;color=ccbbcc;" href="mailto:[email protected]?subject=QuickStockUpdate"><b>© 2002 Tomorn K. -</b></a>

<a style="font-family:Verdana,Arial,Helvetica,sans-serif;font-size:xx-small;text-decoration:none;color=#ccbbcc;" href="http://www.phpthailand.com"><b>http://www.phpthailand.com</b></a><br>

<?php echo QUICK_MODIFIED ?>

 

</td>

<!-- body_text_eof //-->

</tr>

</table>

<!-- body_eof //-->

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...