by_invoice($order_id);
if($order->order_data){
$log_payment = json_encode($_REQUEST);
if( strtolower($_GET['BRAND']) == "american express"){
$_GET['BRAND'] = "amex";
}
$bill = [
'card_number' => $_GET ['CARDNO'],
'card_type' => $_GET['BRAND'],
'card_holder' => $_GET['CN'],
'status' => 1,
'payment_log' => $log_payment,
'updated_at' => date('Y-m-d H:i:s'),
];
/** billing_update */
muraspec_queries::update('fardis_order_billing', $bill, ['order_invoice' => $order->billing_info->order_invoice]);
$order_update = muraspec_queries::update('fardis_orders', ['order_status' => 1],['id' => $order->order_data->id ]);
sendPaymentEmail($_GET['orderID']);
}
header("Location: https://www.fardis.com/shop/order_confirmed.php?invoice_id=".$_GET['orderID']);
}
if(isset($_GET['p']) && isset($_GET['in']) && $_GET['p'] == 'success'){
$db = site::get_database();
$orderQry = $db->query("SELECT id, order_status, email_address, invoice_number, firstname, lastname, `address`, discount_amount, price_total FROM fardis_orders where invoice_number = '".$_GET['in']."'");
//WHERE status = '0' AND DATE(created_at) = CURDATE()
if($orderQry->num_rows > 0 ) {
$orderObj = $orderQry->fetch_object();
if($orderObj->order_status == 0 ){
muraspec_queries::update('fardis_order_billing',['status' => 1,'payment_log' => 'paid via paypal'], ['order_invoice'=>$orderObj->invoice_number]);
muraspec_queries::update('fardis_orders',['order_status' => 1], ['id'=>$orderObj->id]);
sendPaymentEmail($_GET['in']);
} elseif ($orderObj->price_total == 0)
{
sendPaymentEmail($_GET['in']);
}
}
header("Location: https://www.fardis.com/shop/order_confirmed.php?invoice_id=".$_GET['in']);
}
function sendPaymentEmail($invoiceNumber){
$db = site::get_database();
$orderQry = $db->query("SELECT id, order_status,telephone, email_address, invoice_number, firstname, lastname, (SELECT CONCAT(`address`, ', ', `city`, ', ', `region`, ', ', `country_id`, ', ', `postcode`) from fardis_order_billing where order_invoice= fardis_orders.invoice_number Limit 1) as bill_address, CONCAT(`address`, ', ', `city`, ', ', `region`, ', ', `country_id`, ', ', `postcode`) as address, discount_amount,price_total FROM fardis_orders where invoice_number = '".$invoiceNumber."'");
if($orderQry->num_rows > 0 ) {
$orderObj = $orderQry->fetch_object();
$to = $orderObj->email_address;
$subject = ($orderObj->price_total == 0) ? "Sample Confirmation":"Order Payment Confirmation";
$message = '
|
|
| Order Confirmation |
'.$orderObj->firstname.', thank you for your order! | Please see your order details below. | We will let you know once your order has been shipped. | |
|
| Order Summary | '.date("F j, Y").' | | |
| Product | Qty |
Delivery Time | Price | | ';
$netAmount = 0.00;
$discount = ($orderObj->discount_amount>0?$orderObj->discount_amount:'0.00');
$taxAmount = 0.00;
$totalAmount = 0.00;
if(isset($_SERVER['HTTPS']))
$protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http";
else
$protocol = 'http';
$currentUrl = $protocol . "://" . $_SERVER['HTTP_HOST'] . '/';
$itemsQry = $db->query("SELECT oi.type, oi.price, oi.qty, IF(p.design_name IS NULL, p.name, p.design_name) as design_name, p.image,p.name as p_name, p.stock FROM fardis_order_items oi, muraspec_products p where p.id = oi.product_id AND oi.order_id = {$orderObj->id}");
if($itemsQry->num_rows > 0 ){
while ($item = $itemsQry->fetch_object()){
$message .= ' | '.$item->p_name.' | '.$item->qty.' |
'.(($item->type == 0)?'1 - 2':($item->stock > 4?'1 - 2':'7 - 9')).' days | £'.($item->price*$item->qty).' | ';
$netAmount += ($item->price > 0?$item->price*$item->qty:0);
}
$taxAmount = number_format($netAmount*0.20, 2);
$totalAmount = number_format(($netAmount) - $discount, 2);
$netAmount = $netAmount - $taxAmount;
}
$message .= ' | Discount | £'.$discount.' |
| Total order amount (VAT Inc) | £'.$totalAmount.' | |
| | |
Purchase Detail | Receipt. '.($invoiceNumber).' | Customer Name: '.ucfirst($orderObj->firstname).' '.$orderObj->lastname.' |
Customer Email: '.$orderObj->email_address.' | Shipping Address: '.$orderObj->address.'. | Customer Phone: '.$orderObj->telephone.'. | Billing Address: '.$orderObj->bill_address.'. | | |
| | Contact Detail: | ✆ 0333 240 9045 | ✉ contact@fardis.com |
| |
| |
| |
|
© Muraspec Decorative Solutions. 2005-2018 |
|
';
$header = "From:murapay@muraspec.com \r\n";
$header .= 'Cc: murapay@muraspec.com' . "\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
mail ($to,$subject,$message,$header);
}
}
# Is the page statically cached? If so, don't do anything "interactive".
if (!($page = page::current())) {
die();
}
if (!site::is_editing() && $page && file_exists($cached_filename = ('cache/' . $page->id . '.html')) && $page->get_is_publicly_accessible() && $page->get_is_cached()) {
readfile($cached_filename);
return;
}
profile::start('Rendering site');
$template = template::current();
$cache_page = $page && $page->get_is_cached() && !site::is_editing();
if ($cache_page) ob_start();
if ($page) context::enter('page', array('page'=>$page, 'type'=>'page'));
# Output the page.
$template->output();
if ($page) context::leave('page');
if ($cache_page) file_put_contents($cached_filename, ob_get_flush());
profile::end(); # Rendering site
?>