Jump to content
olsonsp4c

Automatic Stock Notification

Recommended Posts

This is the support forum for the addon "Automatic Stock Notification"

 

http://addons.oscommerce.com/info/3152

 

This needs to be a community effort, please work together to improve this addon.

 

Scott

Share this post


Link to post
Share on other sites

OK, I need some help here. Here are the bugs I've found so far and I'm unsure how to fix them.

 

1. It is supposed to only send emails when stock goes from 0 to MORE than 0 in stock; however, it will send emails whenever the stock is increased. There needs to be a way to query the current (old) stock quantity and store it in a variable (like $prior_products_quantity) and then write an if statement so that the code would look something like this:

 

// BEGIN Automatic Stock Notification
	  if ($prior_products_quantity == 0) {
		 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 . "')");

 

2. If there is more than 1 customer subscribed to product, it sends the name of the 1st customer to ALL customers!!!

 

That's all I've found so far.

 

I need help making this work like it was designed to work.

 

Scott

Edited by olsonsp4c

Share this post


Link to post
Share on other sites

Version 2.2 is out. Bug 2 from above is fixed.

 

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

 

http://addons.oscommerce.com/info/3152

 

Scott

Share this post


Link to post
Share on other sites
So is it safe to say that this MOD only works when the item stock level is manually updated via the Admin Console?

 

Yes - it could be integrated into other addons possibly though.

 

Scott

Edited by olsonsp4c

Share this post


Link to post
Share on other sites

Hi, thanks for the easy and convenient add-on.

 

I have installed another add-on called "Quick Price Updates v2.5" (http://www.oscommerce.com/community/contributions,122)

 

and was wondering that maybe combine them to make the add-on powerful. :rolleyes:

 

In fact, I have no idea how to do it and hope to give me a hand.

 

Sorry for my poor English ^^

Share this post


Link to post
Share on other sites

use this code in admin/categories.php 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

Edited by ggbig

-------------------------------------------------

Best Regards,

 

ggbig (maestro)

Share this post


Link to post
Share on other sites

Everybody,

 

I've updated the addon to version 2.3 and integrated the above fix.

 

* 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)

 

http://addons.oscommerce.com/info/3152

Share this post


Link to post
Share on other sites

Maybe I'm missing something but I installed this. Step 1 and 2a in admin / categories and did the changes in languages but I don't see instruction on putting anything in product_info.php??

 

How does the customer get notified?

Share this post


Link to post
Share on other sites
Maybe I'm missing something but I installed this. Step 1 and 2a in admin / categories and did the changes in languages but I don't see instruction on putting anything in product_info.php??

 

How does the customer get notified?

 

Hi

 

I, too, installed but don't see anything. My question is as above, how does the customer get notified

 

Cheers

 

Ian

Share this post


Link to post
Share on other sites

Hi,

 

The contribution is working really fine. Really a great tool for the customers.

 

Everywhere you see sold out items online with a notification, so i want to see a report (in the admin section) what is the most wanted product thats sold out at the moment.

 

Is there somebody who this in his shop working and how did you do that?

 

regards,

Jan

Edited by jan64

Dreams can come true, if you help them a littlebit

Share this post


Link to post
Share on other sites

Hello,

 

I'm sorry but mine doesn't work. My client don't receive the emails.

 

I installed the contribution "Automatic Stock Notification 2_3" from olsonsp4C, step 1, 2a and 3a.

 

So I modified these files:

 

- admin/categories.php

- admin/includes/configure.php

- admin/includes/languages/french/categories.php

 

Thank you for this one who could help me.

 

Guillaume.

Share this post


Link to post
Share on other sites

I have the same problem is something missing? Anyone?

 

 

 

Hello,

 

I'm sorry but mine doesn't work. My client don't receive the emails.

 

I installed the contribution "Automatic Stock Notification 2_3" from olsonsp4C, step 1, 2a and 3a.

 

So I modified these files:

 

- admin/categories.php

- admin/includes/configure.php

- admin/includes/languages/french/categories.php

 

Thank you for this one who could help me.

 

Guillaume.

Share this post


Link to post
Share on other sites
Maybe I'm missing something but I installed this. Step 1 and 2a in admin / categories and did the changes in languages but I don't see instruction on putting anything in product_info.php??

 

How does the customer get notified?

 

The customer is notified over EMAIL

 

Scott

Share this post


Link to post
Share on other sites
Hello,

 

I'm sorry but mine doesn't work. My client don't receive the emails.

 

I installed the contribution "Automatic Stock Notification 2_3" from olsonsp4C, step 1, 2a and 3a.

 

So I modified these files:

 

- admin/categories.php

- admin/includes/configure.php

- admin/includes/languages/french/categories.php

 

Thank you for this one who could help me.

 

Guillaume.

 

Could you get me a little more info? have you made sure that your admin email configures has "send mail" and other options turned on? Also, are html emails turned on?

 

Scott

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites
The customer is notified over EMAIL

 

Scott

 

 

Could you please post the solution to this, I am looking for the same question to be answered. I do not see any change to the product on the catalog side when i 0 the stock. Thanks


What would you do if you knew you could not fail?

Share this post


Link to post
Share on other sites
Could you please post the solution to this, I am looking for the same question to be answered. I do not see any change to the product on the catalog side when i 0 the stock. Thanks

 

Hello, there is not supposed to be any visible change in the catalog when stock is 0.

 

When the stock is 0, this addon waits for you to change the stock to MORE than 0, then it notifies the customer that the product is in stock by email. It is all transparent. If you installed the mod that deletes the customer from the notification table, if you are that customer and you are logged in, the button on the product page will change from "Remove Notification" to a normal "Notification" button.

 

Scott

Edited by olsonsp4c

Share this post


Link to post
Share on other sites
Hello, there is not supposed to be any visible change in the catalog when stock is 0.

 

When the stock is 0, this addon waits for you to change the stock to MORE than 0, then it notifies the customer that the product is in stock by email. It is all transparent. If you installed the mod that deletes the customer from the notification table, if you are that customer and you are logged in, the button on the product page will change from "Remove Notification" to a normal "Notification" button.

 

Scott

 

I'd really appreciate if someone could explain exactly how this contribution works.

 

How exactly does the customer indicate that they want to be emailed when a product is back in stock?

Share this post


Link to post
Share on other sites
I'd really appreciate if someone could explain exactly how this contribution works.

 

How exactly does the customer indicate that they want to be emailed when a product is back in stock?

 

Very simple :)

In a 'normal' shop configuration the customer can click the product notifications button (in the right column).

The database contains now a set of information for this specific customer/article (see db=> products_notifications)

 

Cheers Uwe

Share this post


Link to post
Share on other sites

Hi! I love this feature, however, I am posting in the hopes that someone else has the same problem I do and knows how to fix it.

 

If I go to my website and view an item that is out of stock (I do use the Stock Status in Product Listing contrib, another goodie) and I click on a product to be notified about...BEFORE logging in first...I get redirected to the login page which is fine.

 

But, after I login, rather than being taken back to the item I selected to be notified about...I end up on a page that says 'product not found'.

 

However, if I login first and then start selecting items to be notified about, all is fine.

 

And all is fine after that initial 'product not found' page. That doesn't happen again, once I've logged in and clicked on another item to be notified about. The problem disappears for the remainder of my session.

 

I suspect (which really means I have no idea, lol) the presence of Purchase Without Account in my login.php file may be creating some drama here. It's hard to say. I have a test site (where PWA is not installed) and this does not happen there at all. But, it does happen in my live, working site. Any ideas?

 

Andrea

Share this post


Link to post
Share on other sites

I have implemented this mod and had no problems. However, the mod does not notify customers when the Admin restocks itens (that were asked for notification) by deleting orders. The delete order procedure allows the admin to restock ordered itens before deleting.

 

I have made changes to admin/order.php to circunvent that and intend to append them to the contribuition.

 

However, in the codes of both steps 2a and 2b of this contribuition, there is a variable ($email_order) passed as the last parameter to $mimemessage->send:

 

$mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT . $product['products_name'], $email_order);

 

that is not referenced anywhere as far as I know. The last parameter of send message method is optional and a non initialized parameter should cause no harm. Am'I missing something here? Is the variable $email_order initialized somewhere?

 

I need to clarify this point before proposing additions to the contribuition.

 

Ronaldo Persiano

Share this post


Link to post
Share on other sites

Hello everybody,

 

I have installed this great contribution without problems - I thought.

 

Everything went fine, no errors on any files were found and the stock level is recognized and shown correctly.

It would be perfect if only the notification would be sent out...

 

I had these problems with a similar contribution before which is why I fear that there is something in my installation that stops this function from working.

 

Mails on orders and contact us are working fine with either sendmail or SMTP, either HTML-mails or not.

 

Any hint on where to look for the problem would be appreciated.

 

Thanks in advance

Nala


Leben und leben lassen - live and let live - vivrer et laisser vivre

Share this post


Link to post
Share on other sites

Good evening,

 

it does not look as if there many people out there who have got an idea what could be causing my problem.

Though I am beginning to halfway understand how the basic functions in oscommerce are working I haven't got a clue how the mail system works.

 

How come that orders and contact us work fine but the nofications don't?

Where shall I start looking ? What can I test that I haven't tested up to now to narrow down the problem ?

 

Please try to help me.

I am helping my husband besides my 11 hrs a day main job and this add-on would save us a great deal of work.

 

We are selling Hifi classics and often our customers are eagerly waiting for a certain product.

This would save us having to maintain a waiting list and then notifying the customers.

 

Thanks a lot

Nala


Leben und leben lassen - live and let live - vivrer et laisser vivre

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×