Now you need to amend 2 php files, these are:
include/product_modify.php - Only add the files between // funkydunk added code for notify when back in stock and // end of code added by funkydunk for notify when back in stock.
Code:
# Update the default price
db_query("UPDATE $sql_tbl[pricing] SET price='$price' WHERE productid='$productid' AND quantity='1' AND membership='' AND $sql_tbl[pricing].variantid = 0");
if($fields['price'] == 'Y' && $productids)
db_query("UPDATE $sql_tbl[pricing] SET price='$price' WHERE quantity='1' AND $sql_tbl[pricing].variantid = 0 AND membership=''".$products_condition);
// funkydunk added code for notify when back in stock
if ($notify){
if ($avail > $oldavail){
// send the email to all registered product watchers
$mailproduct= func_query_first("SELECT * FROM `xcart_products` WHERE productid = '$productid'");
$watchers = db_query("SELECT email FROM `xcart_notify` WHERE productid = '$productid'");
// echo "SELECT * from `xcart_notify` WHERE productid = '$productid'";
$mail_smarty->assign ("product", $mailproduct); // put in to assign product info to smarty
$mail_smarty->assign ("userinfo", $userinfo);
while ($row = db_fetch_array($watchers)){
// echo $row['email'];
$email = $row['email'];
func_send_mail($email, "mail/".$prefix."stock_notify_subj.tpl", "mail/".$prefix."stock_notify.tpl", $config["Company"]["orders_department"], false);
// delete watchers from table
db_query("DELETE FROM `xcart_notify` WHERE email='" . $email . "' and productid = $productid");
}
}
}
// end of code added by funkydunk for notify when back in stock
# If image was posted
include/process_product.php - Only add between // funkydunk added code for notify when back in stock (shopcart/includes/process_product.php) and // end of code added by funkydunk for notify when back in stock (shopcart/includes/process_product.php)
Code:
# Include 'avail' field into the updating list
if (isset($v["avail"]) and is_numeric($v["avail"]))
$update[] = "avail='".intval($v["avail"])."'";
// funkydunk added code for notify when back in stock (shopcart/includes/process_product.php) - Modify by Maxking
$watchers = db_query("SELECT email FROM `xcart_notify` WHERE productid = '$k'");
$mailproduct = func_query_first("SELECT * FROM `xcart_notify` WHERE productid = '$k'");
$oldavail = intval($product['avail']);
if ($value > $oldavail){
$mail_smarty->assign ("product", $mailproduct); // put in to assign product info to smarty
while ($row = db_fetch_array($watchers)){
$email = $row['email'];
func_send_mail($email, "mail/".$prefix."stock_notify_subj.tpl", "mail/".$prefix."stock_notify.tpl", $config["Company"]["orders_department"], false);
db_query("DELETE FROM `xcart_notify` WHERE email='" . $email . "' AND productid= '$k'");
}
$watchers = "";
}
// end of code added by funkydunk for notify when back in stock (shopcart/includes/process_product.php) - Modify by Maxking
# Perform SQL query to update products
if (!empty($update))
db_query("UPDATE $sql_tbl[products] SET ".implode(",", $update)." WHERE productid='$k'");