Community Add-Ons
Automatic Customer Stock Update Notification
for osCommerce Online Merchant v2.2
Will automatically notify customers when items come into stock. Once they do, it will delete them from the product_notifications table, so as not to constantly tell them whenever you add stock.
I hope OSCommerce will integrate this in the future, as it's invaluable for merchants! About 1/3 of my customers are people who are just waiting to be notified when I have something in stock!
FULL PACKAGE
Since v2.3
-----------
* Added compatibility with "Quick Stock Update from the Product Listing Page" addon: http://www.oscommerce.com/community/contributions,4812
See included text file for how to merge the two addons...
Scott
* Missed a multi-lingual reference in the email subject, changed catalog/admin/includes/languages/xxxxxxxxxx/categories.php accordingly.
* Updated the addon to work properly when stock is from "out of stock" to "in stock" and not to include stock increases when stock is already greater than 0 (THANKS to ggbig)
* Updated the instructions to include the option to delete or not delete customer email notifications from the database after the email is sent (added step 2b and 3a/b/c/d)
Scott (olsonsp4c)
use this code to stop the email notification of a stokc update, "IF" the current qty is above zero. for example if the stock was at zero and it was updated to 3, customer would recieve an email, if the qty was at 3 and updated to 7 no email will be sent. Task taken from the "need help with" section. Thanks for a great addon :)
// BEGIN Automatic Stock Notification
$current_stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$_GET['pID'] . "'");
$current_stock = tep_db_fetch_array($current_stock_query);
if ($current_stock['products_quantity'] < 1) {
if ($_POST['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)$_GET['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);
reset($audience);
while (list($key, $value) = each ($audience)) {
$mimemessage = new email(array('X-Mailer: osCommerce System Mailer'));
// add the message to the object
if (EMAIL_USE_HTML == 'true') {
$mimemessage->add_html(HTML_NOTIFICATION1 . $value['firstname'] . ' ' . $value['lastname'] . HTML_NOTIFICATION2 . STORE_NAME . HTML_NOTIFICATION3 . $products_id . '">' . $product['products_name'] . HTML_NOTIFICATION4 . '">' . STORE_NAME . HTML_NOTIFICATION5 . $product['products_name'] . HTML_NOTIFICATION6 . $product['products_name'] . HTML_NOTIFICATION7 . STORE_NAME . HTML_NOTIFICATION8 . $products_id . '">' . $product['products_name'] . HTML_NOTIFICATION9 . STORE_NAME);
} else {
$mimemessage->add_text(TEXT_NOTIFICATION1 . $value['firstname'] . ' ' . $value['lastname'] . TEXT_NOTIFICATION2 . STORE_NAME . TEXT_NOTIFICATION3 . $product['products_name'] . TEXT_NOTIFICATION4 . $product['products_name'] . TEXT_NOTIFICATION5 . $product['products_name'] . TEXT_NOTIFICATION6 . STORE_NAME . TEXT_NOTIFICATION7 . $product['products_name'] . TEXT_NOTIFICATION8 . STORE_NAME);
}
$mimemessage->build_message();
$mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, 'Now In Stock: ' . $product['products_name'], $email_order);
// tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $products_id . "' ");
}
}
}
// END Automatic Stock Notification
zip is a dummy file....
Since v2.1
----------
* Bugfix: Now sends the correct name in the greeting to each customer when email notifications are sent
* Added support forum in instructions
* Added "What I could use help with" section
Scott (olsonsp4c)
Here's the support forum to improve this:
http://forums.oscommerce.com/index.php?showtopic=306105
file is dummy
Since v2.0
----------
* Added multi-lingual support
* Added support for secured admin
* Change the login link to a secure link
Scott (olsonsp4c)
Since v1.0 (and revisions)
--------------------------
* Updated the instructions
* Integrated all revisions into the code
* Significantly updated the html and text messages so it actually makes a difference in what is sent
* As stated by insomniac, you can add extra fields to the message (ie. model number) easily
All credit to the original author and revisionists...
Scott (olsonsp4c)
Or you can do it this way and it will select whether you have send HTML emails enabled.
// add the message to the object
if (EMAIL_USE_HTML == 'true') {
$mimemessage->add_html($message);
} else {
$mimemessage->add_text($message);
}
$mimemessage->build_message();
No file attached just alternative for previous post.
You update to the above had one problem I ran into.....
Change:
$mimemessage->add_text
to:
$mimemessage->add_html
and the links are now clickable in emails...
By rockadrome
VERSION SPANISH
Descripcion:
Esta contribucion envia una email, a aquellos clientes que tengan activadas las notificaciones de productos, cuando actualizas el stock del producto.
Mejoras:
He puesto en el txt las instrucciones de donde colocar el codigo que venian en la primera contribucion y en las otras 2 no venia.
Y he quitado el codigo de sobra en la query de otras contribuciones que tenian metido dichos usuarios que subieron las otras.
_______________________________
What's the new?
I have put in file txt, the instructions of where to place the code which it did be in the first contribution and the other 2 contributions not included .
Also I have cleaned the code in the query for oscommerce default.
Sorry for my english.
Great MOD by Joshua Nyberg and great updated by Insomniac
- Cleaned some specific querys for Insomniac shop
Great MOD by Joshua Nyberg ... I just took it and cleaned it up ... more presentable and more info query possibilities.
- Added clickable links to Store and the Product in the notification email.
- Added the Product Model beside the Product Name.
- Added Customers first and last name to email body.
With some minor tweaking you can pull a lot more info to put in the email notification. I think this is one of those great MODS. Simple yet usefull.
Will automatically notify customers when items come into stock. Once they do, it will delete them from the product_notifications table, so as not to constantly tell them whenever you add stock.
I hope OSCommerce will integrate this in the future, as it's invaluable for merchants! About 1/3 of my customers are people who are just waiting to be notified when I have something in stock!
