Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Automatic Stock Notification


olsonsp4c

Recommended Posts

me again..

 

With the help of Ronaldo I found my error and notification now works fine.

 

What I cannot get sorted is for the customer to get the mail in "his" language.

The mail is sent out in the language that is used in admin section no matter

which language the customer is using when visiting the product page with the

notification option.

 

I tried various options to force the language file in admin/categories.php but

none did the job.

 

How can I change that ?

 

warm greetings

Nala

Link to comment
Share on other sites

  • 1 month later...
me again..

 

With the help of Ronaldo I found my error and notification now works fine.

 

warm greetings

Nala

 

Can you tell the rest of us how the notification problem was fixed?...or is it a secret?

I too get no notifications sent out.

Edited by Jon53
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

I've installed this great mod, and it works fine, but only if the productstock is manually added in de admin. I update products and the stocklevel directly in de mysql database with an automaticly import of 30000 products.

And then this mod doesn't work.

 

Is there any way to send al productsubscribers an notification about the new stocklevel after import the data?

 

I hope someone can help me with this problem, So i can use this great mod in future.

 

Greetings Senator

Link to comment
Share on other sites

  • 3 months later...

I've installed this great mod, and it works fine, but only if the productstock is manually added in de admin. I update products and the stocklevel directly in de mysql database with an automaticly import of 30000 products.

And then this mod doesn't work.

 

Is there any way to send al productsubscribers an notification about the new stocklevel after import the data?

 

I hope someone can help me with this problem, So i can use this great mod in future.

 

Greetings Senator

Hello,

 

I have a same problem. Did you found a solution?

 

Cheers.

Edited by WorkingHard
Link to comment
Share on other sites

  • 2 months later...

Hello,

 

OK cron job, but what shall I execute exactly with it? :blink:

 

Cheers.

 

Did anyone find any solution to this? I import quantities directly to mysql and the contributions doesn't work. Anyone?

Link to comment
Share on other sites

technically you need a cron job to execute at a regular interval, but more importantly, the logic of the contribution needs to be changed to look for all outstanding notifications for which there now is stock (>0), and delete the customer notification record after the email has been successfully sent.

 

basically it is a rewrite of the contribution, so not a one liner to add somewhere

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

technically you need a cron job to execute at a regular interval, but more importantly, the logic of the contribution needs to be changed to look for all outstanding notifications for which there now is stock (>0), and delete the customer notification record after the email has been successfully sent.

 

basically it is a rewrite of the contribution, so not a one liner to add somewhere

 

Thanks for your reply, that's what i tought but i'm not as good in php to write myself. Hopefully someone will improve the contribution, sooner or later.

Link to comment
Share on other sites

UNTESTED PIECE OF CODE, if you put this in your categories.php where you have it currently, it will try to generate notifications with each product update, independent of which product you are updating, it will check for all products and all customers each and every time ...

Depending on the number of notifications this might be fast or slow ...

Secondly, I've kept the overall layout / coding style, it could be improved by

1) using joins

2) getting rid of the audience array, and just use the original array

3) only retrieve one particular language

 

 

Taking the section that automatically removes records that are processed and commenting out unneeded lines, tweaking a few, I get this

 

// BEGIN Automatic Stock Notification
//CB not needed
//			$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();
//CB added logic to check if there are any outstanding notifications for products that now have stock
// and inserted customers_id, products_id and products_name in audience array
// NOTE, if you have multiple languages, this will still generate email for each language used.
//				$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 . "')");
			$products_query = tep_db_query("select distinct pd.products_name, p.products_id, pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn , " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where c.customers_id = pn.customers_id and pn.products_id = p.products_id and p.products_quantity > 0 and p.products_id = pd.products_id )");

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

		   }
//CB Not used
//				$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);

//CB Not used
//				$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') {
//CB Changed $product to $value
//					$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);
				$mimemessage->add_html(HTML_NOTIFICATION1 . $value['firstname'] . ' ' . $value['lastname'] . HTML_NOTIFICATION2 . STORE_NAME . HTML_NOTIFICATION3 . $value['products_id'] . '">' . $value['products_name'] . HTML_NOTIFICATION4 . '">' . STORE_NAME . HTML_NOTIFICATION5 . $value['products_name'] . HTML_NOTIFICATION6 . $value['products_name'] . HTML_NOTIFICATION7 . STORE_NAME . HTML_NOTIFICATION8 . $value['products_id'] . '">' . $value['products_name'] . HTML_NOTIFICATION9 . STORE_NAME);
			  } else {
//CB Changed $product to $value
//					$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->add_text(TEXT_NOTIFICATION1 . $value['firstname'] . ' ' . $value['lastname'] . TEXT_NOTIFICATION2 . STORE_NAME . TEXT_NOTIFICATION3 . $value['products_name'] . TEXT_NOTIFICATION4 . $value['products_name'] . TEXT_NOTIFICATION5 . $value['products_name'] . TEXT_NOTIFICATION6 . STORE_NAME . TEXT_NOTIFICATION7 . $value['products_name'] . TEXT_NOTIFICATION8 . STORE_NAME);
			  }
			  $mimemessage->build_message();
			  $mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT . $value['products_name'], $email_order);

			  // the following line deletes the customer notification so that that after the email is sent, the customer will have to visit the product page and select the notification button in order to receive future email stock notifications
//CB Tweaked to only remove current record just emailed
//				  tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $products_id . "' ");
			  tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $value['products_id'] . "' and customers_id = '" . $value['customers_id'] . "' ");
			}
//			  }
//			}
// END Automatic Stock Notification

 

Now just keeping what I think is needed, and still preserving the overall logic a bit gives

// BEGIN Automatic Stock Notification
			$audience = array();
//CB added logic to check if there are any outstanding notifications for products that now have stock
// and inserted customers_id, products_id and products_name in audience array
// NOTE, if you have multiple languages, this will still generate email for each language used.
			$products_query = tep_db_query("select distinct pd.products_name, p.products_id, pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn , " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where c.customers_id = pn.customers_id and pn.products_id = p.products_id and p.products_quantity > 0 and p.products_id = pd.products_id )");

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

		   }

			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 . $value['products_id'] . '">' . $value['products_name'] . HTML_NOTIFICATION4 . '">' . STORE_NAME . HTML_NOTIFICATION5 . $value['products_name'] . HTML_NOTIFICATION6 . $value['products_name'] . HTML_NOTIFICATION7 . STORE_NAME . HTML_NOTIFICATION8 . $value['products_id'] . '">' . $value['products_name'] . HTML_NOTIFICATION9 . STORE_NAME);
			  } else {
				$mimemessage->add_text(TEXT_NOTIFICATION1 . $value['firstname'] . ' ' . $value['lastname'] . TEXT_NOTIFICATION2 . STORE_NAME . TEXT_NOTIFICATION3 . $value['products_name'] . TEXT_NOTIFICATION4 . $value['products_name'] . TEXT_NOTIFICATION5 . $value['products_name'] . TEXT_NOTIFICATION6 . STORE_NAME . TEXT_NOTIFICATION7 . $value['products_name'] . TEXT_NOTIFICATION8 . STORE_NAME);
			  }
			  $mimemessage->build_message();
			  $mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT . $value['products_name'], $email_order);

			  // the following line deletes the customer notification so that that after the email is sent, the customer will have to visit the product page and select the notification button in order to receive future email stock notifications
			  tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $value['products_id'] . "' and customers_id = '" . $value['customers_id'] . "' ");
			}
// END Automatic Stock Notification

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

UNTESTED PIECE OF CODE, if you put this in your categories.php where you have it currently, it will try to generate notifications with each product update, independent of which product you are updating, it will check for all products and all customers each and every time ...

....

 

Thanks for your effort! I tried the code but still doesn't work on mysql quantities' update, any clue?

Link to comment
Share on other sites

Working from the assumption that I nor you made any syntax errors and it all compiled in php

 

1) did you replace the original code in admin/categories.php ?

2) did you update any product through the admin / categories interface (so that the code is triggered) ?

 

if you only update through mysql, you will need to create a skeleton admin page to hold this code, and call this particular page to fire-off the emails.

Also you will have to call the categories languages file to get the email text definitions or create your own new file.

 

This is just a proof of concept, if it works, you can put the code anywhere you like, in a separate page, or even in application top, if you'd want it to fire off whenever you use the admin interface, or a crontab for scheduled updates etc

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

1) did you replace the original code in admin/categories.php ?

 

Yes i did

 

2) did you update any product through the admin / categories interface (so that the code is triggered) ?

 

This way it works

 

 

if you only update through mysql, you will need to create a skeleton admin page to hold this code, and call this particular page to fire-off the emails.

Also you will have to call the categories languages file to get the email text definitions or create your own new file.

 

This is just a proof of concept, if it works, you can put the code anywhere you like, in a separate page, or even in application top, if you'd want it to fire off whenever you use the admin interface, or a crontab for scheduled updates etc

 

How to create this admin page to let it check by pressing a button and send mails if needed?

Link to comment
Share on other sites

Create a new page in your admin directory, I've called mine product_customer_notifications.php

 

I've been lazy and included the necessary defines at the top of the page, as generating the email in the admin language is also not always appropriate, perhaps a multi-language email is more appropriate ...

(Note there is a contribution that adds a language field to the customer record, could look at integrating logic based on that contribution if needed)

 

I've added a max_mails limit as not to overload the system, set at 10 per run, the output shows which mails are sent, and which are outstanding. Merely refreshing will generate the next set of mails.

If you have lots of updates at the same time, you could prioritize which ones go first by adding an order by clause to the original query, e.g. you could order by products_price desc for instance to have the most expensive products updates go out first.

 

I think this page could be called by a cron tab too, if someone could try this ?

 

Carine

<?php
/*
 $Id: product_customer_notifications.php

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2010 osCommerce

 Released under the GNU General Public License
*/

 $max_mails = 10;

 require('includes/application_top.php');

// Automatic Stock Notification
define('HTML_NOTIFICATION1', 'Dear ');
define('HTML_NOTIFICATION2', ',' . "\n\n" . 'According to your ');
define('HTML_NOTIFICATION3', ' Product Notifications request, we wish to inform you that ' . '<a href="' . NOTIFICATION_HTTP_SERVER . DIR_WS_CATALOG . 'product_info.php' . '?products_id=');
define('HTML_NOTIFICATION4', '</a>' . ' is now in stock.  Please visit ' . '<a href="' . NOTIFICATION_HTTP_SERVER . DIR_WS_CATALOG);
define('HTML_NOTIFICATION5', '</a>' . ' if you would like to make a purchase.' . "\n\n" . 'Your product notification for ');
define('HTML_NOTIFICATION6', ' has been removed.  If you would like to receive future stock notifications for ');
define('HTML_NOTIFICATION7', ', you must ' . '<a href="' . HTTPS_SERVER . DIR_WS_CATALOG . 'login.php' . '">' . 'login' . '</a>' . ' to your ');
define('HTML_NOTIFICATION8', ' account, navigate to the ' . '<a href="' . NOTIFICATION_HTTP_SERVER . DIR_WS_CATALOG . 'product_info.php' . '?products_id=');
define('HTML_NOTIFICATION9', '</a>' . ' page, and click the ' . '<i>' . 'notifications' . '</i>' . ' button.' . "\n\n" . 'Warm greetings from your friends at ');
define('TEXT_NOTIFICATION1', 'Dear ');
define('TEXT_NOTIFICATION2', ',' . "\n\n" . 'According to your ');
define('TEXT_NOTIFICATION3', ' Product Notifications request, we wish to inform you that ');
define('TEXT_NOTIFICATION4', ' is now in stock.  Please visit ' . NOTIFICATION_HTTP_SERVER . DIR_WS_CATALOG . ' if you would like to make a purchase.' . "\n\n" . 'Your product notification for ');
define('TEXT_NOTIFICATION5', ' has been removed.  If you would like to receive future stock notifications for ');
define('TEXT_NOTIFICATION6', ', you must login to your ');
define('TEXT_NOTIFICATION7', ' account, navigate to the ');
define('TEXT_NOTIFICATION8', ' page, and click the notifications button.' . "\n\n" . 'Warm greetings from your friends at ');
define('EMAIL_SUBJECT', 'Now In Stock: ');

define('HEADING_TITLE','Generating customer emails for products back in stock');
define('TABLE_HEADING_STATUS','Status');
define('TABLE_HEADING_FIRSTNAME','First Name');
define('TABLE_HEADING_LASTNAME','Last Name');
define('TABLE_HEADING_CUSTOMERS_ID','Customer Id');
define('TABLE_HEADING_PRODUCTS_NAME','Products Name');
define('TABLE_HEADING_PRODUCTS_ID','Products Id');
define('TABLE_HEADING_EMAIL_ADDRESS','Email Address');
define('TEXT_NUMBER_OF_EMAILS',' %s out of %s emails sent');

?>
<!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">
<script language="javascript" src="includes/general.js"></script>
</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>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></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="2">
             <tr class="dataTableHeadingRow">
               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_STATUS; ?></td>
               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_FIRSTNAME; ?></td>
               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LASTNAME; ?></td>
               <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_CUSTOMERS_ID; ?></td>
               <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_PRODUCTS_NAME; ?></td>
               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_ID; ?></td>
               <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_EMAIL_ADDRESS; ?></td>
             </tr>
<?php
// BEGIN Automatic Stock Notification
			$audience = array();
			$products_query = tep_db_query("select distinct pd.products_name, p.products_id, pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn , " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where c.customers_id = pn.customers_id and pn.products_id = p.products_id and p.products_quantity > 0 and p.products_id = pd.products_id ");

			while ($products = tep_db_fetch_array($products_query)) {
			  $audience[$products['customers_id']] = array('firstname' => $products['customers_firstname'],
														   'lastname' => $products['customers_lastname'],
														   'customers_id' => $products['customers_id'],
														   'products_name' => $products['products_name'],
														   'products_id' => $products['products_id'],
														   'email_address' => $products['customers_email_address']);
			}
			reset($audience);
			$mailed = 0;
			while (list($key, $value) = each ($audience)) {
			  if ($mailed < $max_mails) {
				$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 . $value['products_id'] . '">' . $value['products_name'] . HTML_NOTIFICATION4 . '">' . STORE_NAME . HTML_NOTIFICATION5 . $value['products_name'] . HTML_NOTIFICATION6 . $value['products_name'] . HTML_NOTIFICATION7 . STORE_NAME . HTML_NOTIFICATION8 . $value['products_id'] . '">' . $value['products_name'] . HTML_NOTIFICATION9 . STORE_NAME);
				} else {
				  $mimemessage->add_text(TEXT_NOTIFICATION1 . $value['firstname'] . ' ' . $value['lastname'] . TEXT_NOTIFICATION2 . STORE_NAME . TEXT_NOTIFICATION3 . $value['products_name'] . TEXT_NOTIFICATION4 . $value['products_name'] . TEXT_NOTIFICATION5 . $value['products_name'] . TEXT_NOTIFICATION6 . STORE_NAME . TEXT_NOTIFICATION7 . $value['products_name'] . TEXT_NOTIFICATION8 . STORE_NAME);
				}
				$mimemessage->build_message();
//To test use something like below
//					$mimemessage->send($value['firstname'] . ' ' . $value['lastname'], '[email protected]', STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT . $value['products_name'], $email_order);
				$mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT . $value['products_name'], $email_order);

				$mailed++;

//To test comment out the delete query so you can re-test with the same data till everything is fine
// the following line deletes the customer notification so that that after the email is sent, the customer will have to visit the product page and select the notification button in order to receive future email stock notifications
				tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $value['products_id'] . "' and customers_id = '" . $value['customers_id'] . "' ");
?>
                   <td class="dataTableContent">DONE: </td>
<?php
			  } else {
?>
                   <td class="dataTableContent">TODO: </td>
<?php
			  }
?>
               <td class="dataTableContent"><?php echo $value['firstname']; ?></td>
               <td class="dataTableContent"><?php echo $value['lastname']; ?></td>
               <td class="dataTableContent"><?php echo $value['customers_id']; ?></td>
               <td class="dataTableContent"><?php echo $value['products_name']; ?></td>
               <td class="dataTableContent"><?php echo $value['products_id']; ?></td>
               <td class="dataTableContent"><?php echo $value['email_address']; ?></td>
             </tr>
<?php
			}
// END Automatic Stock Notification
?>
		  <tr>
               <td class="smallText" colspan="7"><?php echo sprintf(TEXT_NUMBER_OF_EMAILS, $mailed, tep_db_num_rows($products_query)); ?></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>
   </table></td>
<!-- body_text_eof //-->
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Create a new page in your admin directory, I've called mine product_customer_notifications.php

....

 

Very good, we are done. It works like a charm. Wonderfull job. Still i can't get cron job works since my server doesn't allow me to make any cronjob i have to make by external site but it seems it doesn't work (maybe because the admin folder is protected by password).

 

Any clue about that?

Link to comment
Share on other sites

One more thing:

 

As far as i understood from code the new page created should show requests.

 

If they are done they won't be shown next refresh

 

If they are not done they stay in queue.

 

Actually it only shown request once when they are done but it doesn't show any result when there are request not done yet. Any fix for this?

Link to comment
Share on other sites

Very good, we are done. It works like a charm. Wonderfull job. Still i can't get cron job works since my server doesn't allow me to make any cronjob i have to make by external site but it seems it doesn't work (maybe because the admin folder is protected by password).

 

Any clue about that?

That would be my conclusion too

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

One more thing:

 

As far as i understood from code the new page created should show requests.

 

If they are done they won't be shown next refresh

 

If they are not done they stay in queue.

 

Actually it only shown request once when they are done but it doesn't show any result when there are request not done yet. Any fix for this?

the outstanding should be listed as TODO: iso DONE:

 

if you have set a limit in your sql query, which is smaller then the $max_mails, then you will never see any TODO: listed, but I did not put a LIMIT x in the sql, perhaps you did ?

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

It seems there is a problem. It always sends emails when i refresh the new admin page, also if i don't change any quantity

TRUE, it will send notifications for all products that have quantity > 0, that is why it only works properly if you delete notifications after they have been sent.

 

That is the drawback of not triggering this upon a change to an individual product but after a big products update, if your script that updates the products_quantities is more intelligent and flags products that you just have re-activated, you should be able to tweak the products_query to take that into account.

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

TRUE, it will send notifications for all products that have quantity > 0, that is why it only works properly if you delete notifications after they have been sent.

 

That is the drawback of not triggering this upon a change to an individual product but after a big products update, if your script that updates the products_quantities is more intelligent and flags products that you just have re-activated, you should be able to tweak the products_query to take that into account.

 

Can't do that, i just export quantities from our database soft in excel and put in mysql compiling those lines (very bad stuff i know, but it works):

 

UPDATE products SET products_quantity = "		 " WHERE products_id = "		";
UPDATE products SET products_quantity = "		 " WHERE products_id = "		";
UPDATE products SET products_quantity = "		 " WHERE products_id = "		";
UPDATE products SET products_quantity = "		 " WHERE products_id = "		";
UPDATE products SET products_quantity = "		 " WHERE products_id = "		";
UPDATE products SET products_quantity = "		 " WHERE products_id = "		";
UPDATE products SET products_quantity = "		 " WHERE products_id = "		";
UPDATE products SET products_quantity = "		 " WHERE products_id = "		";
UPDATE products SET products_quantity = "		 " WHERE products_id = "		";
..

I just put quantities and products_id (wich is actually same on osc and my database soft) taking colums from a csv of product export (they are around 1k).

 

if you have set a limit in your sql query, which is smaller then the $max_mails, then you will never see any TODO: listed, but I did not put a LIMIT x in the sql, perhaps you did ?

 

I didn't really undestand where to look for this

Edited by fozzo
Link to comment
Share on other sites

  • 4 weeks later...

Hey there,

 

thanks for this great contirb. It´s working fine. But how can I get it to use german Product Names ? Whenever it sends an Mail it uses the english product names. Even German is Standardlanguage. How can I change the Code to work with german Product Names ?

 

Greetings,

Moelle78

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.

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