Advertisement
Guest User

bodnant_email_functions

a guest
Sep 16th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.19 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. //define Roots
  5. $root = '../';
  6. $shop_root = '../';
  7.  
  8. //Include Top Files
  9. include($root.'includes/config.php');
  10. include($root.'includes/functions.php');
  11.  
  12. //Get Order ID
  13. $order_id = $_GET['order_id'];
  14.  
  15. /*************************
  16. GET AND ASSIGN MAIN VARIABLES
  17. *************************/
  18.  
  19. //Get main fields from order column Details
  20. $variable_query = mysqli_query($link, "SELECT DISTINCT `customer_id`, `collection_date`, `order_for_delivery`, `order_date`, `delivery_local` FROM `orders` WHERE `order_id`='$order_id'");
  21.  
  22. //Assign main variables
  23. while($variable = mysqli_fetch_array($variable_query)) {
  24.     $customer_id = $variable['customer_id'];
  25.     $collection_date = $variable['collection_date'];
  26.     $order_for_delivery = $variable['order_for_delivery'];
  27.     $order_date = $varible['order_date'];
  28.     $delivery_local = $variable['delivery_local'];
  29. }
  30.  
  31. /*************************
  32. MARK ORDER AS PAID
  33. *************************/
  34.  
  35. /*************************
  36. MARK EVENT AS PAID
  37. *************************/
  38.  
  39. /*************************
  40. CUSTOMER DETAILS
  41. *************************/
  42. //Process Customer Details
  43. $customer_query = mysqli_query($link, "SELECT * FROM `customer` WHERE `customer_id`='$customer_id'");
  44.  
  45. //Loop through customer details
  46. while($customer = mysqli_fetch_array($customer_query)){
  47.     $name = $customer['customer_name'];
  48.     $address = $customer['customer_address'];
  49.     $city = $customer['customer_city'];
  50.     $postcode = $customer['customer_postcode'];
  51.     $tel_number = $customer['customer_number'];
  52.     $customer_email = $customer['customer_email'];
  53.     $customer_loyalty = $customer['customer_loyalty'];
  54. }
  55.    
  56. /*************************
  57. BUILD ORDER ROWS
  58. *************************/
  59. //order query
  60. $order_query = mysqli_query($link, "SELECT * FROM `orders` WHERE `order_id`='$order_id'");
  61.  
  62. //Total assign
  63. $total = '';
  64. //Event Check assign
  65. $event_order = '';
  66. //Order Row Assign
  67. $order_row = '';
  68.  
  69. while($order = mysqli_fetch_array($order_query)) {
  70.    
  71.     //Get general product info
  72.     $product_id = $order['product_id'];
  73.     $product_name = product_title($product_id, $link);
  74.     $quantity = $order['order_quanity'];
  75.     $price = money($order['order_price'], '');
  76.    
  77.     //Query if the product has an event id
  78.     $event_check = mysqli_query($link, "SELECT `event_id` FROM `products` WHERE `product_id`='$product_id'");  
  79.    
  80.     //order row
  81.     $order_row .= '<tr><td>'.$product_name.'</td><td>'.$quantity.'</td><td>'.money($price,'&pound').'</td></tr>';
  82.    
  83.     $total += $price;
  84.    
  85.     $event_order = mysqli_num_rows($event_check);
  86. }
  87.  
  88. /*************************
  89. VOUCHER CHECK AND ROW
  90. *************************/
  91.  
  92. //query voucher use
  93. $voucher_use = mysqli_query($link, "SELECT * FROM `voucher_use` WHERE `order_id`='$order_id'");
  94.  
  95. //if there is a voucher with the order id
  96. if(mysqli_num_rows($voucher_use) != 0) {
  97.  
  98.     //Get Voucher use variables
  99.     $result = mysqli_fetch_object($voucher_use);
  100.     $old_total = $result->old_total;
  101.     $total = $result->order_total;
  102.     $voucher_code = $result->voucher_code;
  103.    
  104.     //query voucher details
  105.     $voucher_details = mysqli_query($link, "SELECT * FROM `vouchers` WHERE `voucher_code`='$voucher_code'");
  106.     $query_result = mysqli_fetch_object($voucher_details);
  107.    
  108.     $voucher_cust_text = $query_result->voucher_cust_text;
  109.    
  110.     if(!empty($old_total)) {
  111.         $old_total = '<strike style="color: red;">'.$old_total.'</strike>';
  112.     }
  113.    
  114.     $voucher_email = '<tr style="background: #dff0d8;"><td colspan="4" style="padding:5px;"><strong>'.$voucher_code.' - </strong> '.$voucher_cust_text.'</td></tr>';
  115.  
  116. }
  117.  
  118.  
  119. /*************************
  120. EVENT E-TICKET
  121. *************************/
  122. //Check if there is an event
  123. if($event_order > 0) {
  124.    
  125.     //Query for event with customer_id
  126.     $event_order_query = mysqli_query($link, "SELECT * FROM `event_booking` WHERE `customer_id`='$customer_id'");
  127.    
  128.     //Assign event details
  129.     $event = mysqli_fetch_array($event_order_query);
  130.     $event_id = $event['event_id'];
  131.    
  132.     //Get Event Details
  133.     $event_query = mysqli_query($link, "SELECT * FROM `events` WHERE `event_id`='$event_id'");
  134.    
  135.     //Assign Details
  136.     $event_details = mysqli_fetch_array($event_query);
  137.     $event_name = $event_details['event_name'];
  138.     $event_date = $event_details['event_date'];
  139.     $event_start_time = $event_details['event_start_time'];
  140.     $event_end_time = $event_details['event_end_time'];
  141.     $event_type = event_type($link, $event_details['event_type_id']);
  142.     $event_location = event_location($link, $event_details['event_loaction_id']);
  143.     $event_description = $event_details['event_desc'];
  144.    
  145.     $event_email = '';
  146.    
  147.    
  148. }
  149.  
  150. /*************************
  151. EVENT GIFT EMAIL
  152. *************************/
  153. //check if there is gift details
  154. $gift_check = mysqli_query($link, "SELECT * FROM `event_gift` WHERE `customer_id`='$customer_id'");
  155.    
  156.     //If there is a gift then create gift email
  157.     if(mysqli_num_rows($gift_check) != 0) {
  158.        
  159.         //Loop to get gift details
  160.         while($gift = mysqli_fetch_array($gift_check)) {
  161.             $gift_name = $gift['gift_name'];
  162.             $gift_email = $gift['gift_email'];
  163.             $gift_message = $gift['gift_message'];
  164.         }
  165.        
  166.         $gift_email = '';
  167.            
  168.     }
  169.  
  170. /*************************
  171. ORDER CONFIRMATION EMAIL
  172. *************************/
  173.  
  174. /*************************
  175. SEND EMAILS
  176. *************************/
  177.  
  178.  
  179. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement