Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Notification to customer when changes are made in store automatic


El_Heso

Recommended Posts

Posted

Hi!

I have a automatic product notification so whe i press a button in admin all of my customer gets a notification email with the information they have signed for example: customer X sign up for stock changes so when i press my button it controlls if there has been some stock changes and if so are there any customer signed up for that notification and sends a email with the info and deletes the sign up info from the database. so far so good but i have a really big problem everything works except there is no email going out this is my code:

 

<?php

require('includes/application_top.php');

 

$notification_info_query = tep_db_query("select * from " . TABLE_PRODUCTS_NOTIFICATIONS . " order by products_id, email_adress, notification_type");

 

$notifications_exist = false;

$message = '';

if (tep_db_num_rows($notification_info_query)){

$notifications_exist = true;

$bv0 = 0;

$bv1 = 0;

$bv2 = 0;

while ($notification_info = tep_db_fetch_array($notification_info_query)){

$notify = false;

//check for stock changes

if ($notification_info['notification_type']=='0'){

$product_info_query = tep_db_query("select products_name, products_quantity from " . TABLE_PRODUCTS . " JOIN " . TABLE_PRODUCTS_DESCRIPTION . " using (products_id) where products.products_id='".$notification_info['products_id']."'");

if (tep_db_num_rows($product_info_query)){

$product_info = tep_db_fetch_array($product_info_query);

if ($product_info['products_quantity']>$notification_info['old_lager']) $notify = true;

else $notify = false;

}

if ($notify==true){ //If stock has changed tell customer

$message .= 'Kund ('.$notification_info['email_adress'].') meddelad om lagerändring<br>';

$bv0 = $bv0+1;

//Build email

$email_adress = $notification_info['email_adress'];

$subject = 'Meddelande om produktbevakning';

$email_text = EMAIL_WELCOME . $product_info['products_name'] . "\n\n";

$email_text .= EMAIL_TEXT_LEV . "\n" . 'http://www.xxx.com/product_info.php?products_id=' . $notification_info['products_id'] . "\n\n";

$email_text .= EMAIL_CONTACT;

tep_mail(' ', $email_address, $subject, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

//delete notification sign up

tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id='".$notification_info['products_id']."' and email_adress='".$email_adress."' and notification_type='".$notification_info['notification_type']."'");

}

 

//check price changes

} else if ($notification_info['notification_type']=='1'){

$product_info_query = tep_db_query("select products_name, products_price, products_tax_class_id from " . TABLE_PRODUCTS . " JOIN " . TABLE_PRODUCTS_DESCRIPTION . " using (products_id) where products.products_id='".$notification_info['products_id']."'");

if (tep_db_num_rows($product_info_query)){

$product_info = tep_db_fetch_array($product_info_query);

if ($product_info['products_price']<$notification_info['old_price']) $notify = true;

else $notify = false;

}

if ($notify==true){ //if changes tell customer

$message .= 'Kund ('.$notification_info['email_adress'].') meddelad om prisförändring<br>';

$bv1 = $bv1+1;

//Build email $email_adress = $notification_info['email_adress'];

$subject = 'Meddelande om produktbevakning';

$email_text = EMAIL_WELCOME . $product_info['products_name'] . "\n\n";

$newprice = number_format($product_info['products_price']*(1+0.01*tep_get_tax_rate($product_info['products_tax_class_id'])),0,'',' ') . ':-';

$email_text .= EMAIL_TEXT_PRICE . $newprice . "\n" . 'Du hittar produkten på nedanstående länk:' . "\n" . 'http://www.xxx.com/product_info.php?products_id=' . $notification_info['products_id'] . "\n\n";

$email_text .= EMAIL_CONTACT;

tep_mail('aa', $email_address, $subject, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

//Update new price

tep_db_query("update " . TABLE_PRODUCTS_NOTIFICATIONS . " set old_price='".$product_info['products_price']."' where products_id='".$notification_info['products_id']."' and email_adress='".$email_adress."' and notification_type='".$notification_info['notification_type']."'");

}

 

//Notification price

} else if ($notification_info['notification_type']=='2'){

$product_info_query = tep_db_query("select products_name, products_price, products_tax_class_id from " . TABLE_PRODUCTS . " JOIN " . TABLE_PRODUCTS_DESCRIPTION . " using (products_id) where products.products_id='".$notification_info['products_id']."'");

if (tep_db_num_rows($product_info_query)){

$product_info = tep_db_fetch_array($product_info_query);

if ($product_info['products_price']<$notification_info['notification_value']) $notify = true;

else $notify = false;

}

if ($notify==true){ //If changes tell customer

$message .= 'Kund ('.$notification_info['email_adress'].') meddelad om pris under önskad nivå<br>';

$bv2 = $bv2+1;

//Build email

$email_adress = $notification_info['email_adress'];

$subject = 'Meddelande om produktbevakning';

$email_text = EMAIL_WELCOME . $product_info['products_name'] . "\n\n";

$newprice = number_format($product_info['products_price']*(1+0.01*tep_get_tax_rate($product_info['products_tax_class_id'])),0,'',' ') . ':-';

$email_text .= EMAIL_TEXT_PRICE2 . $newprice . "\n" . 'Du hittar produkten på nedanstående länk:' . "\n" . 'http://www.xxx.com/product_info.php?products_id=' . $notification_info['products_id'] . "\n\n";

$email_text .= EMAIL_CONTACT;

tep_mail('aa', $email_address, $subject, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

//Delete notification

tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id='".$notification_info['products_id']."' and email_adress='".$email_adress."' and notification_type='".$notification_info['notification_type']."'");

}

}

}

}

?>

<!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">

</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" cellpadding="0" cellspacing="10">

<?php

echo '<tr><td class="smallText">'.$message.'</td></tr>';

if (!$notifications_exist){

echo '<tr><td>Det finns inga bevakningar just nu.</td></tr>';

} else {

echo '<tr><td>Uppdateringen av bevakning är slutförd.</td></tr>';

echo '<tr><td>Lagerförändring: ' . $bv0 . ' st kunder meddelade och borttagna från bevakningslistan.</td></tr>';

echo '<tr><td>Prisförändring: ' . $bv1 . ' st kunder meddelade och uppdaterade.</td></tr>';

echo '<tr><td>Önskat pris nått: ' . $bv2 . ' st kunder meddelade och borttagna från bevakningslistan.</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'); ?>

 

 

Anyone have a qlue how to fix so it should send email?

I dont see it so i need help

 

Regards Tony

Posted

My guess is spelling mistakes, such as $email_adress instead of $email_address

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...