dynamic email message sending on an IF condition of order status
Hello, ok I wanted to see if the following method would work before I start adjusting my code and testing.
I have a page where the Admin can update a customers order (this will then update the database and send out an email to that customer, letting them know the current status of their order (the different statuses are: Kit Dispatched, Kit Received, Order in Progress, Order Dispatched and Order Complete) - Side note I need to put in an IF statement so that any customer that has an order status of 'Order Complete' does NOT received an email).
currently in my code I am using Create Email Message server behaviour and in the server behaviour I have ticked the checkbox to use my own php file with HTML layout file (Manage email body from file option).
each of the statuses in the admin has its own page as this displays all those statuses separately but they all use the same email file and the corresponding WAUE_file-name.php thats stored in the webassist/email folder.
What I was wondering is in this WAUE_ file there is a section that is:
//Start Mail Body
$MailBody = $MailBody . "";
$MailBody = $MailBody . (GetFromPage("templates/order-progress.php"));
$MailBody = $MailBody . "";
//End Mail Body
my question is could I wrap a series of IF...IF ELSE statements around the part that reads:
$MailBody = $MailBody . (GetFromPage("templates/order-progress.php"));
so that it checks for the form POST and then loads up a different template?
for example:
if ("".((isset($_POST["order-update"]))?$_POST["order-update"]:"") ."" == "Kit Dispatched") {
$MailBody = $MailBody . (GetFromPage("templates/order-kit-dispatched.php"));
}
ELSE
if ("".((isset($_POST["order-update"]))?$_POST["order-update"]:"") ."" == "Kit Received") {
$MailBody = $MailBody . (GetFromPage("templates/order-kit-received.php"));
}
ELSE
if ("".((isset($_POST["order-update"]))?$_POST["order-update"]:"") ."" == "Order in Progress") {
$MailBody = $MailBody . (GetFromPage("templates/order-progress.php"));
}
ELSE
if ("".((isset($_POST["order-update"]))?$_POST["order-update"]:"") ."" == "Order Dispatched") {
$MailBody = $MailBody . (GetFromPage("templates/order-dispatched.php"));
}
Would my code example be feasible for what I want to do? or is it totally the wrong approach?
Regards
Chris