Full service web hosting, great prices and support. Starts at $1.99/month!
Results 1 to 3 of 3

Thread: Automatic_Email_of_Restock

  1. #1
    bkpie
    Guest


    Default Automatic_Email_of_Restock

    A new project_project entry has been added:

    [drupal=181]Automatic_Email_of_Restock[/drupal]

    This contribution will automatically email your customers that selected product notifications when a products stock is updated. Used in combination with a couple others which are mentioned in the instructions it is truly as my 6 year old would say awesome. Updated for OSCMAX

  2. #2
    JohnW
    Guest


    Default Re: Automatic_Email_of_Restock

    Your 6 year old is correct, this is awesome. I had already implemented the out of stock buttons and only showing the product notification link when the item is out of stock, but this really completes the process. The really cool part is that it deletes the notification. Actually, the really cool part is it is fully automated. Over time I might try and make a nicer html email but I'm probably over thinking this. The bottom line is the customer gets the email and clicks to buy.

    Thanks a lot for posting this. It's a great help.

  3. #3
    4g3nt0r4ng3
    Guest


    Default Re: Automatic_Email_of_Restock

    I modified /admin/stock.php to do the same when restock is made through "Reports -> Stock Report"

    find:
    Code:
    tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity=" . (int)$VARS['quantity'] . " where products_id=" . (int)$VARS['product_id']);
    add into next line:
    Code:
    // Begin Automatic Customer Stock Update Notification
    
              if ($VARS['quantity'] > 1){            
    
                $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)$VARS['product_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)$VARS['product_id'] . "'");      
                $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)$VARS['product_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'] . ' ]' . "nn" . 'Dear ' . $customer['customers_firstname'] . ' ' . $customer['customers_lastname'] . ',' . "n" . 'According to your ' . STORE_NAME . ' Product Notifications request ... We wish to inform you that ' . '' . '' . HTTP_SERVER . DIR_WS_CATALOG . 'product_info.php' . '?products_id=' . (int)$VARS['product_id'] . ' ' . '' . $product['products_name'] . '' . ' is now in stock.'  . "n" . 'Please visit' . ' ' . '' . HTTP_SERVER . DIR_WS_CATALOG .' 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 = '" . $VARS['product_id'] . "' ");
                }
              }
    // End Automatic Customer Stock Update Notification
    maybe the author could include it in the next release if its error free

    ~40~
    Last edited by 4g3nt0r4ng3; 07-15-2010 at 08:35 AM. Reason: fixed notification item not getting deleted upon email sent

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •