ok i reworked it so you can see what im trying to do....this auto email gets sent out when the customer placed an order and after payment is returned to the store. This file updates the status of the order and also sends out the email so the customer can download their purchases immediately. The email uses a "search and replace" array feature becuase the html of the email contains tags {NAME}, {TOTAL} etc. in addition to what the email contains already....again..imtrying to add in a freebie file using that same search and replace array feture. My html of the email has {ONEPROMO}{TWOPROMO}{THREEPROMO} in it. I am hoping the php code is going to replace those tags with the links $onepromo, $twopromo, $threepromo IF the customer spent the amount required to get them. Revised the code as you see below BUT, still getting unexpected T_IF expecting ')'
$email_template = $db->select("SELECT * FROM ".$glob['dbprefix']."CubeCart_eMail WHERE enabled = 1 AND type = 'digital'");
if ($email_template == TRUE) {
$search = array(
"{NAME}",
"{EXPIRE}",
"{ATTEMPTS}",
"{SHOP_OWNER}",
"{LINKS}"
);
$replace = array(
$order[0]['name'],
formatTime($digitalProducts[0]['expire']),
$config['dnLoadTimes'],
$config['masterName'],
$lnks,
///////////////////////The $5 order Freebie
$onepromo = '<a href="'.$glob['storeURL'].'/files/uploads/test5.zip">Test5</a><br />';
if ($prod_total > '4.90') {
$search = array(
"{ONEPROMO}"
);
$replace = array(
$onepromo,
);
};
///////////////////////The $10 order Freebie
$twopromo = '<a href="'.$glob['storeURL'].'/files/uploads/test10.zip">Test10</a><br />';
if ($prod_total > '9.90') {
$search = array(
"{TWOPROMO}"
);
$replace = array(
$twopromo,
);
};
///////////////////////The $15 order Freebie
$threepromo = '<a href="'.$glob['storeURL'].'/files/uploads/test15.zip">Test15</a><br />';
if ($prod_total > '14.90') {
$search = array(
"{THREEPROMO}"
);
$replace = array(
$threepromo,
);
};
);
$ebody = $email_template[0]['body'];
$subject = str_replace("{ORDER_ID}", $cart_order_id, $email_template[0]['subject']);
$ebody = str_replace($search, $replace, $ebody);
include($glob['rootDir']."/includes/email_config.inc.php");
$mail->ClearAddresses();
$mail->From = $config['masterEmail'];
$mail->FromName = $config['masterName'];
$mail->AddAddress($order[0]['email'], $order[0]['name']);
$mail->AddReplyTo($config['masterEmail'], $config['masterName']);
$mail->WordWrap = 50;
$mail->Subject = $subject;
$mail->Body = $ebody;
$mail->Send();
}