Awesome contribution, but there's 2 bugs:
1.) No way to REMOVE tracking information from an order. (The code does not check to see if the tracking info has changed, and therefore does not update the database.)
2.) In the instructions, look at like 330. That entire block of code does this:
If no tracking data, send an standard email.
If there is USPS data, but no FEDEX or UPS, send an email (with tracking note).
If there is UPS data, but no FEDEX or USPS, send an email.
If there is FEDEX data, but no USPS or UPS, send an email.
Here's the logic flaw: What if there is more than one type of tracking number? An email never gets sent!!
I modified the entire block of code into a simple "OR" statement.
Note that I also have the "order number in subject email" contribution installed.
I am VERY new at PHP, so if I broke something, I'd like to know. If not, at least others can build on this.
Code:
---------------/*Tracking contribution begin*/
$customer_notified = '0';
if ($HTTP_POST_VARS['notify'] == 'on' & $ups_track_num == '' & $fedex_track_num == '' & $usps_track_num == '' ) {
$notify_comments = '';
if ($HTTP_POST_VARS['notify_comments'] == 'on') {
$notify_comments = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $comments) . "nn";
}
$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']) . "nnn" . $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_1. $oID . EMAIL_TEXT_SUBJECT_2 . $orders_status_array[$status], $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
$customer_notified = '1';
}elseif ($HTTP_POST_VARS['notify'] == 'on' & ($ups_track_num == '' or $fedex_track_num == '' or $usps_track_num == '') ) {
$notify_comments = '';
if ($HTTP_POST_VARS['notify_comments'] == 'on') {
$notify_comments = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $comments) . "nn";
}
// begin replacement section for Email Subject contribution
$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']) . "nn" . EMAIL_TEXT_TRACKING_NUMBER . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "nn" . $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_1. $oID . EMAIL_TEXT_SUBJECT_2 . $orders_status_array[$status], $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
$customer_notified = '1';
// end replacement section for Email Subject contribution
}
/*Tracking contribution end*/
-------------
End Code
Basically what my code does is this:
If no tracking data, send a standard email
If UPS or USPS or FEDEX data, then send an email with the tracking message.
Basically, no matter what combination, if any of the shipping methods have tracking data, then it's going to send the right email.