Emailing cart contents to customer
Moderator: General Moderators
-
squatchimo
- Forum Commoner
- Posts: 28
- Joined: Thu Feb 03, 2005 3:36 pm
Re: Emailing cart contents to customer
I tried that also but still no query results. Here is my modified code:
Again, everything in $message comes through EXCEPT for what is in the query. But the query IS good and DOES return results if I simply echo it. I've also tried substituting the $userses value with a hard number just to be sure it wouldn't interfere.
Code: Select all
} else {
$get_cart = "select tr.id, inv.name, inv.price, tr.qty from tracking
as tr left join inventory as inv on inv.id = tr.item_id where session_id = '$userses'";
$get_cart_res = mysql_query($get_cart) or die(mysql_error());
$subject = "blah blah blah...";
$message = "Dear $firstname $lastname,
Thank you for ordering at blah.com!
Order Summary:\n";
while ($cart = mysql_fetch_array($get_cart_res)) {
$name = stripslashes($cart['name']);
$price = $cart['price'];
$qty = $cart['qty'];
$message .= "$qty";
}
$message .= "Subtotal: $subtotal
Tax: $tax
Shipping: $shipping
Total: $total
Blah blah blah...";
mail($email, $subject, $message, "From: blah@blah..com\r\n");
header("Location: https://-URL-");
}- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
-
squatchimo
- Forum Commoner
- Posts: 28
- Joined: Thu Feb 03, 2005 3:36 pm
Here is the entire submit page:
When I receive the email, it reads as follows:
The email headers are:
After the page is submitted, the data inserted from the form goes into the orders table successfully and the email is sent.
feyd | :grumble-grumble:
Code: Select all
<?php
session_start();
header("Cache-control: private");/* IE6 fix */
include('../phpcode/include.php');
$cc_type = $_POST['cc_type'];
$cc_number = $_POST['cc_number'];
$cc_month = $_POST['cc_month'];
$cc_year = $_POST['cc_year'];
$cc_holder = $_POST['cc_holder'];
$cc_type = stripslashes($cc_type);
$cc_number = stripslashes($cc_number);
$cc_month = stripslashes($cc_month);
$cc_year = stripslashes($cc_year);
$cc_holder = stripslashes($cc_holder);
if((!$cc_type) || (!$cc_number) || (!$cc_month) || (!$cc_year) || (!$cc_holder)) {
echo 'You did not submit the following information: <br />';
if(!$cc_type){
echo "Credit card type is a required field. Please enter it below.<br />";
}
if(!$cc_number){
echo "Credit card number is a required field. Please enter it below.<br />";
}
if(!$cc_month){
echo "Card expiration month is a required field. Please enter it below.<br />";
}
if(!$cc_year){
echo "Card expiration year is a required field. Please enter it below.<br />";
}
if(!$cc_holder){
echo "Cardholder name is a required field. Please enter it below.<br />";
}
include 'payment_info.php';
exit();
}
// Assign variables from sessions:
$sesid = $_SESSION["usersession"];
$firstname = $_SESSION["firstnamex"];
$lastname = $_SESSION["lastnamex"];
$email = $_SESSION["emailx"];
$address1 = $_SESSION["address1x"];
$address2 = $_SESSION["address2x"];
$city = $_SESSION["cityx"];
$state = $_SESSION["statex"];
$zip = $_SESSION["zipx"];
$phone = $_SESSION["phonex"];
$subtotal = $_SESSION["subtotalx"];
$tax = $_SESSION["taxx"];
$shipping = $_SESSION["shippingx"];
$total = $_SESSION["totalx"];
// Enter info into the Database.
$query = "INSERT INTO orders (order_date,order_firstname,order_lastname,order_address1,
order_address2,order_city,order_state,order_zip,order_tel,order_email,item_total,
shipping_total,status,tax,total,session_id,cc_type,cc_number,cc_month,cc_year,cc_holder)
VALUES (localtime(),'$firstname','$lastname','$address1','$address2','$city','$state',
'$zip','$phone','$email','$subtotal','$shipping','','$tax','$total','$sesid','$cc_type',
'$cc_number','$cc_month','$cc_year','$cc_holder')";
$result = mysql_query($query);
echo mysql_error();
if(!$result){
echo 'Query error!';
} else {
// Get cart contents:
$get_cart = "select tr.id, inv.name, inv.price, tr.qty from tracker
as tr left join inventory as inv on inv.id = tr.item_id where session_id = '$userses'";
$get_cart_res = mysql_query($get_cart) or die(mysql_error());
$subject = "Your Order at blah.com!";
$message = "Dear $firstname $lastname,
Thank you for ordering at http://www.blah.com!
Order Summary:\n";
while ($cart = mysql_fetch_array($get_cart_res)) {
$name = stripslashes($cart['name']);
$price = $cart['price'];
$qty = $cart['qty'];
$message .= "$qty";
}
$message .= "Subtotal: $subtotal
Tax (Florida Residents Only): $tax
Shipping: $shipping
Total: $total
Thanks for the order...blahblahblah...";
mail($email, $subject, $message, "From: orders@blah.com\r\n");
header("Location: https://URL/logoff.php");
}
?>Code: Select all
"e;Dear John Doe,
Thank you for ordering at http://www.blah.com!
Order Summary:
Subtotal: 1000
Tax (Florida Residents Only): 70.00
Shipping: 10.00
Total: 1080.00
Thanks for the order...blahblahblah..."e;Code: Select all
Return-Path: <orders@blah.com>
Received: from blah.com (blah.com їxxx.xxx.xxx.xxx])
by routing.blah.com (8.11.6/8.11.6) with ESMTP id j2BFL5cxxxxx
for <johndoe@customer.com>; Fri, 11 Mar 2005 09:21:08 -0600
Received: (from blah@localhost)
by blah.com (8.11.6/8.11.6) id j2BFKvcxxxxx;
Fri, 11 Mar 2005 09:20:57 -0600
Date: Fri, 11 Mar 2005 09:20:57 -0600
Message-Id: <200503111520.j2BFKvcxxxxx@blah.com>
To: johndoe@customer.com
Subject: Your Order at blah.com!
From: orders@blah.com
X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on
blah.com
X-Spam-Status: No, hits=0.3 required=99.0 tests=NO_REAL_NAME autolearn=no
version=2.63
X-Spam-Level:
Status:feyd | :grumble-grumble:
Last edited by squatchimo on Fri Mar 11, 2005 11:35 am, edited 1 time in total.
-
squatchimo
- Forum Commoner
- Posts: 28
- Joined: Thu Feb 03, 2005 3:36 pm
squatchimo wrote:OK, to test that thought, I modified the code to echo one of the results:
And the proper name is displayed. So the query does work and does return results. $cart is not empty.Code: Select all
$num = 160; $get_cart = "select tr.id, inv.name, inv.price, tr.qty from tracker as tr left join inventory as inv on inv.id = tr.item_id where tr.id = '$num'"; $get_cart_res = mysql_query($get_cart) or die(mysql_error()); while ($cart = mysql_fetch_array($get_cart_res)) { $name = stripslashes($cart['name']); $price = $cart['price']; $qty = $cart['qty']; $message .= "$qty. x .$name. - £.$price. each\n"; } echo $name;
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
yes, I'm aware you said that.. it doesn't change the fact that it still appears to never enter the loop.
I'd like to see a live version of this... preferably where I can get it to email me the details and what-not. If you don't want to give out the link publicly, that's fine. PM me the details. If possible, I'd like to get a copy of the code throughout along with database exports so I can play around with it on my server, if need be..
I'd like to see a live version of this... preferably where I can get it to email me the details and what-not. If you don't want to give out the link publicly, that's fine. PM me the details. If possible, I'd like to get a copy of the code throughout along with database exports so I can play around with it on my server, if need be..
-
squatchimo
- Forum Commoner
- Posts: 28
- Joined: Thu Feb 03, 2005 3:36 pm
-
squatchimo
- Forum Commoner
- Posts: 28
- Joined: Thu Feb 03, 2005 3:36 pm
I've been searching for a solution to this problem for a few weeks now and still no luck. Since nobody here can think of a solution either, I've decided to disable this feature for the customer. Order totals will still email to the customer, but not item detail. It's the best I can do.
Thanks to Feyd and everyone who spent time looking at this.
Thanks to Feyd and everyone who spent time looking at this.