Exemplo n.º 1
0
 echo "Last Name = " . $_POST['lastNameOrder'] . "\n";
 echo "Email = " . $_POST['emailOrder'] . "\n";
 echo "Phone = " . $_POST['phoneNumberOrder'] . "\n";
 echo "Order Notes = " . $_POST['orderNotes'] . "\n";
 echo "Items: \n";
 $numArray = array_count_values($_SESSION['cart']);
 //Get the carts contents
 getUserData::convertIdToItem($numArray, false);
 //Echo the total of the order
 echo "Total = \$" . $_SESSION['cartTotal'];
 //Get all the contents from the output buffer
 $output = ob_get_clean();
 //Sanitize the string just in case
 $output = filter_var($output, FILTER_SANITIZE_STRING);
 //Email the customer
 sendEmail::EmailCustomer($_POST['emailOrder'], "Order Confirmation", $output);
 /**
  * This next segment of code creates the order in the database.  The order in
  * the database will be handled through an Admin console which I will eventually
  * build.  Orders are for record keeping and such.  Save inventory decrementing to 
  * the admin console just in case an order is not picked up.
  */
 //get connection
 $dbh = Database::getDB();
 //prepare statement
 $order = $dbh->prepare("INSERT INTO orders(firstName, lastName, email, notes, phoneNumber, status, customerID, orderTotal)\r\n\t\t\t\t\t\tVALUES (:firstName, :lastName, :email, :notes, :phoneNumber, :status, :customerID, :orderTotal)");
 //create customerID if they are logged in and it exists
 $customerID = null;
 if (isset($_SESSION['user_id'])) {
     $customerID = $_SESSION['user_id'];
 }