sending order confirmation emails

Do you know how I can edit this php file to send automatic order confirmation emails to customers?

[php]<?php
$strCodes = GSMFUSION_GetOrder($row->OrderIdFromServer, $row->APIKey, $row->AccountId, $row->ServerURL);
$responseArr = explode(’~’, $strCodes);
$code = ‘’;
if(isset($responseArr[1]))
$code = stripslashes($responseArr[1]);
$imeiNo = substr($row->product, -15);
$service = substr_replace($row->product, “”, -15);
if($responseArr[0] == ‘2’ || $responseArr[0] == ‘3’)
{
if($responseArr[0] == ‘2’)
{
$message = “Dear Customer, \n\nYour order has been successfully completed. \n\nWe would like to thank you for choosing us to unlock your phone.\n\nThe information needed to unlock your phone is provided below:\n\nService: $service\n\nIMEI #: $imeiNo\n\nUnlock Code: $code\n\n\nPlease click the link below to find the unlocking instructions for your specific phone”;
$headers = “From: [email protected]”. “\r\n” .‘Bcc: [email protected],[email protected]’ . “\r\n”;
mail($row->payer_email, ‘Your Unlock code is here!’, $message, $headers);
mail(‘[email protected]’, ‘Your Unlock code is here!’, $message, $headers);
$objDBCD14->execute(“UPDATE orders SET unlock_code = '”.check_input($code, $objDBCD14->dbh)."’, orderstatus = ‘completed’,
last_updated = ‘".date(‘Y-m-d H:i:s’)."’, hiddenstatus = ‘0’ WHERE order_id = ‘".$row->order_id."’");
}
else if($responseArr[0] == ‘3’)
{
$message = “Dear Customer, \n\nUnfortunately, the Unlock Code for your phone cannot be found under the service selected.\n\nThe details of your order can be found below:\n\nService: $service\n\nIMEI #: $imeiNo\n\nReason: $code\n\n\n\nA FULL REFUND WILL BE ISSUED TO YOUR ACCOUNT WITHIN 1 BUSINESS DAY. “;
$headers = “From: [email protected]”;
mail($row->payer_email, ‘Your Unlock Code cannot be found.’, $message, $headers);
mail(‘[email protected]’, ‘Your Unlock Code cannot be found.’, $message, $headers);
$objDBCD14->execute(“UPDATE orders SET unlock_code = '”.check_input($code, $objDBCD14->dbh).”’, orderstatus = ‘cancelled’,
last_updated = '”.date(‘Y-m-d H:i:s’)."’, hiddenstatus = ‘0’ WHERE order_id = ‘".$row->order_id."’");
}
}
?>[/php]

You have some redundant code in there. What exactly isn’t working?

If want to have a different message based on what the user does then just change the message…

For example:
[php]if ($responseArr[0] == ‘2’) {
$message = ‘foo’;
} else {
$message = ‘bar’;
}[/php]

it will make debugging easier and also make sure you have error reporting turned on.

I was thinking why don’t you just send the confirmation order something like this:

[php]$message = “Your confirmation is " . $confirmation . " and have a great day”;[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service