<?php
$enabled = $site->shop_settings('abandoned_cart_email');
if($enabled['abandoned_cart_email'] == 'y')
{
$admin = $site->shop_settings('admin_email');
$from = mktime(0, 0, 0, date("m"), date("d")-1, date("Y"));
$to = mktime(23, 59, 59, date("m"), date("d")-1, date("Y"));
$query = $mysql->query("ID,owner,first_name,email_address,stamp", "fs_shop_orderdata", "stamp BETWEEN $from AND $to AND temp = 'y' AND shipped = 'n' AND abandoned_cart_email_sent = 'n' AND email_address != '' ORDER BY ID ASC");
while($order = $mysql->get_array($query))
{
$mysql->update("abandoned_cart_email_sent", "y", "fs_shop_orderdata", "ID = {$order['ID']} LIMIT 1");
$msg = "Hello {$order['first_name']},

Firstly thank you for trying to place an order with us! On ".date("d/m/Y", $order['stamp'])." you tried to place an order and did not
complete the transaction.

Did you have any issues while placing the order? please contact us via our web site to tell us how we can make your
shopping experience at our website better.

Want to complete your order? visit:
http://".str_replace("www.", "", $_SERVER['SERVER_NAME'])."/orderStartOver/".$order['owner']."

Thankyou
http://".str_replace("www.", "", $_SERVER['SERVER_NAME']);
//check to see if there is a database email template for this email, use it if so
$hasTemplate = $mysql->query("body", "fs_email_templates",  "token = 'shop-abandonned-cart' LIMIT 1");
if($mysql->num_rows($hasTemplate) == 1)
{
$hasTemplate = $mysql->get_array($hasTemplate);
$msg = $hasTemplate['body'];
$msg = str_replace('{first_name}', $order['first_name'], $msg);
$msg = str_replace('{owner}', $order['owner'], $msg);
$msg = str_replace('{startoverURL}', "http://".str_replace("www.", "", $_SERVER['SERVER_NAME'])."/orderStartOver/".$order['owner'], $msg);
}
//send email
emailWithPhpMailer($order['email_address'], 'Your Order @ '.$_SERVER['SERVER_NAME'], $msg, $admin['admin_email'], false);
}
//
}
?>