Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted (edited)

Hi,

 

I would like to add the option when i change the status in my batch update to shipped it sends an email to the customer. The status is updating correctly but its just not sending the email out.

 

I've tried the following code but i think i might have something wrong in the if statement. Hopefully someone might be able to help me out...? i feel like i'm just going round in circles now.

 

Cheers

Jodes

 

 

<?php
/*

batch-invoice-printing-v1.1
2004-12-18
by PandA.nl

*/

require('includes/application_top.php');
require(DIR_WS_CLASSES . 'currencies.php');
include(DIR_WS_CLASSES . 'order.php');

$target_file = $HTTP_POST_VARS['target_file'];

unset($batch_order_numbers);
if($HTTP_POST_VARS['batch_order_numbers']){
 foreach($HTTP_POST_VARS['batch_order_numbers'] as $order_number => $print_order) {
$batch_order_numbers[] = $order_number;
 }
}		   

// begin error handling
if (!(is_array($batch_order_numbers))){
 exit('Error: no orders selected!');
}

//if (!(is_file($target_file))){
 //exit('Error: target file does not exist!');
//}

// end error handling

sort($batch_order_numbers);
$number_of_orders = sizeof ($batch_order_numbers);

if($target_file == 'labels') {

 header ("Content-type: application/csv\nContent-Disposition: \"inline; filename=customers.csv\"");

 echo "Name,Company,StreetAddress,Suburb,City,State,Postcode,Country \n";

 foreach ($batch_order_numbers as $order_number) {

$oID = $order_number;

$oID = tep_db_prepare_input($oID);
$orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");

$order = new order($oID);

echo "" . $order->customer['name'] . "," . $order->customer['company'] . "," . $order->customer['street_address'] . "," . $order->customer['suburb'] . "," . $order->customer['city'] . "," . $order->customer['state'] . "," . $order->customer['postcode'] . "," . $order->customer['country'] . "\n";
 }

} else {

;?>
<!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 . $autostatus; ?></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">

<?php
$firstinvoice=1;



 foreach ($batch_order_numbers as $order_number) {
if($firstinvoice) {
  $firstinvoice = 0;
} else {
  echo '<br style="page-break-before:always;">';
}

$oID = $order_number;
include('print_batch_invoice.php');

if($autoupdatestatus=='Yes') {
  tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . (int)$oID . "', '" . tep_db_input($autostatus) . "', now(), '" . tep_db_input('0') . "', '" . tep_db_input('')  . "')");
  tep_db_query("update orders SET orders_status='" . tep_db_input($autostatus) . "' WHERE orders_id='" .$oID . "'");

		if (isset($HTTP_POST_VARS['autoupdatestatus']) && ($HTTP_POST_VARS['autoupdatestatus'] == 'Shipped')) {
		  $autoupdatestatus = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $comments) . "\n\n";
		  }
		  $email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']) . "\n" . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]);
		  tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
		  $customer_notified = '1';
		} 
}
 }
?>
</BODY></HTML>
<?php


require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

Edited by jodes

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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