PHP - problem sending mail to customers upon cart checkout

Asked By Olusegun A. on 22-Nov-12 05:17 AM
Hello there,
I have an online foods store where members can pick what they want to buy and submit the cart content when done. below is the script

[syntax=php]

$cartOutput =="";
$cartTotal =="";

if(!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"])<1){
$cartOutput = "<p>&nbsp;</p><p><h2 align='center'>Your Shopping Cart is empty.</p>&nbsp;<p></p></h2>";
}else{

$i = 0;
foreach($_SESSION["cart_array"] as $each_item){
$number++;
$item_id = $each_item["item_id"];
$sql = mysql_query("SELECT * FROM products WHERE hydee='$item_id' LIMIT 1");
$listing = 1;
while($roll=mysql_fetch_array($sql)){
$id=stripslashes($roll[hydee]);
$pid=stripslashes($roll[phydee]);
$product=stripslashes($roll[product]);
$type=stripslashes($roll[type]);
$name=stripslashes($roll[name]);
$facts=stripslashes($roll[facts]);
$detail=stripslashes($roll[detail]);
$ingredients=stripslashes($roll[ingredients]);
$how=stripslashes($roll[how]);
$price=stripslashes($roll[price]);
$qty=stripslashes($roll[qty]);
}
$totalPrice2 = $price * $each_item['quantity']; //price times quantity.

$cartTotal = $totalPrice2 + $cartTotal; //sum up all the prices in the cart to give grand amount.

//putting all prices into naira format.
$price = "#".number_format($price, '00','.',',').".00";
$totalPrice = "#".number_format($totalPrice2, '00','.',',').".00";

$get_imgs = mysql_query("SELECT * FROM product_imgs WHERE phydee='$pid' ORDER BY hydee asc LIMIT 1");
$rows = mysql_fetch_array($get_imgs);{
$spix = $rows[spix];
$bpix = $rows[bpix];

if($bpix!=""){
$pix = "adminpanel/imgs/products/$spix";
list($width, $height, $type, $attr) = getimagesize($pix);

if($width > $height) $size='100px';
else{
$new = 100 * $width;
$size = $new / $height;
$size = $size."px";}}}

if($type == 'Equipment') $img = "<img src='adminpanel/imgs/products/$facts' width='90' class='img_border' />";
elseif($spix!="") $img = "<img src='adminpanel/imgs/products/$spix' width='$size' class='img_border' />";
else $img = "<img src='images/product.png' width='80' class='img_border' />";

//location of product/equipment detail by segun
if($type == 'Equipment') $location = "equipment_detail.php?id=$id";
else $location = "product_detail.php?id=$id";

//dynamic rows assembly
$cartOutput.="<tr>";
$cartOutput.="<td align='center' valign='top' style='border-bottom:1px solid #ccc'>".$number."</td>";
$cartOutput.="<td align='center' valign='top' style='border-bottom:1px solid #ccc'><a href='$location'>$img<br/>".$name."</a></td>";
$cartOutput.="<td align='centre' valign='middle' style='border-bottom:1px solid #ccc'>".$price."</td>";
$cartOutput.="<td align='center' valign='middle' style='border-bottom:1px solid #ccc'>
<form action='cart.php' method='post'>
<input name='quantity' type='text' size='1' maxlength='2' value='".$each_item['quantity']."' />
<input name='adjustBtn".$item_id."' type='submit' value='Adjust' />
<input name='item_to_adjust' type='hidden' value='".$item_id."' />
</form></td>";
//$cartOutput.="<td align='center' valign='middle' style='border-bottom:1px solid #ccc'>".$each_item['quantity']."</td>";
$cartOutput.="<td align='centre' valign='middle' style='border-bottom:1px solid #ccc'>".$totalPrice."</td>";
$cartOutput.="<td align='right' valign='middle' style='border-bottom:1px solid #ccc'><form action='cart.php' method='post'><input name='deleteBtn".$item_id."' type='submit' value='Remove' /><input name='index_to_remove' type='hidden' value='".$i."' /></form></td>";
$cartOutput.="</tr>";
$i++;

//submit order into the database if the member click on SUBMIT MY ORDER in the Cart Page
$order = $_GET[order];
if($order!=""){
$order_id = $mid.$newunix;
$quantity = $each_item['quantity'];
$submit_order = mysql_query("INSERT INTO purchases (member_id, order_id, product, qty, price, totalamount, date, time, ip) VALUES ('$mid', '$order_id', '$id', '$quantity', '$totalPrice2', '$cartTotal', '$date', '$time', '$ip')");
}

//MAIL POSITION 1 (FOR SENDING MAIL TO THE MEMBER ON SUBMITTING THE CART)
}

//MAIL POSITION 2 (FOR SENDING MAIL TO THE MEMBER ON SUBMITTING THE CART)

}
[/syntax]
mail to be sent upon submitting the cart.
[syntax=php]
// To send HTML mail, the Content-type header must be set
if($order!=""){

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Food & Beverages Ltd <info@foods.com>' . "\r\n";

$to = $memail;
$subject = "Your Order is received (Orider ID: $order_id)";

//message to be sent begins
$message = "Hello ".$firstname."<br/><br/>Thank you for the interest in our Products. Your Order ID is $order_id and your order is as below<br/><br/>".$mailCart."<br/><br/>Thank you";

//message to be sent ends

mail($to, $subject, $message, $headers);

header("location:submit_order.php");
}

[/syntax]

The problem is that, assuming the customer purchased 3 items, if the mail code is at MAIL POSITION 1, it will send the mail 3 times to the customer's email. the 1st mail with 1 item, the 2nd mail with 2 items and the 3rd with 3 item and so on. But if the mail code is placed at MAIL POSITION 2, it will send 1 email to the customers but with only 1 item and not all items submitted.

Please what is the right thing for me to do.
help
I am writing a shopping cart app in asp.net. So far I created 2 classes, 1 for customer_info (name, address, email), 1 for product_info (prodname, price, description). As the shopper adds things to the cart and navigates throught the site to shop more, should I store this info in a session var? What is the typical way? Should I create another class for cart and store an array of product_info to keep track of what's in the cart, etc. . .? What do you recommend? Thanks ASP.NET Discussions Outlook (1) ASP.NET (1) VB
By using Expression Web, will I be able to create an interactive web store (ecommerce) including shopping cart, check-out and purchasing capabilities? I'd probably want to purchase an ecommerce template online to learn a whole lot of programming. it's a monumental task to create a shopping cart from scratch. a cart I use and really like is www.candypress.com it's very easy to deploy Have you seen ContentSeed (www.contentseed.com)? NOTE: This message was posted from an unmonitored email account. This is an unfortunate necessity due to high volumes of spam sent to email
I have a shopping cart project in which we process the payment process through credit card or debit card and CartRow { public string id; public string name; public string price; public string items; }; public class Cart { public System.Collections.ArrayList list = new ArrayList( 20 ); }; follow http: / / www.codeproject.com / KB / applications as follows: • Customer fills out an order form at my site with their name, address, email. • Customer is being redirected to Paypal • Upon successful payment via Paypal, Paypal calls my IPN CC.Country = Cust.Countryid.TrimEnd(); / / 2 Character Country ID CC.Phone = Cust.Phone.TrimEnd(); CC.Email = Cust.Email.TrimEnd(); CC.OrderAmount = Inv.Invtotal; CC.TaxAmount = Inv.Tax; / / Optional CC.CreditCardNumber = Inv.Cc.TrimEnd
been dealing with many issues. We have an inventory of over 2000 items in the shopping cart. Problems: 1. Shopping cart times out and customers lose order 2. Randomly drops orders 3. foreign customers must put name to register 5. new issues: completed registrations and orders are not coming through our email address 6. shipping charges are determined off-line based on weight and destination but site markup that goes into the pages. All your problems result from bad design of the shopping cart application and a slow or overloaded server. - - Ron Symonds Microsoft MVP (Expression Web) http: / / www been dealing with many issues. We have an inventory of over 2000 items in the shopping cart. P
Hi all Looking for programmer for ASP2.0 based website mod. Located preferably in Australia. Cheers George IIS ASP Discussions Anonymity (1) Guys (1) So what is you real email address, "George"? Your anonymity does not foster trust. . . I have used these guys to do http: / / www.aspkey.net / Thanks for that:-) keywords: ASP, Programmer, for, modification, to, web, site, shopping, cart description: Hi all Looking for programmer for ASP2.0 based website mod. Located preferably in
I have a shopping cart that can have anything from one to hundreds of different items ordered. I can generate show the order to the customer but I then want to send a similarly formatted email to the site owner. How can I put this dynamic order table into an email message body? IIS ASP Discussions ASP.NET (1) VBScript (1) Dreamweaver (1) Bernie (1) Javascript simplified content, limit graphics, no javascript etc for the express purpose of being used for email. You should do this using a VBScript file run as a scheduled task it should every day. Bernie This is where I would use Dreamweaver and an extension called Universal Email from www.webassist.com. It allows you to copy and paste your asp code into to the page. - - Mike Brind MVP - ASP / ASP.NET keywords: how, to, create, dynamic, html, email description: I have a shopping cart that can have anything from one to hundreds of
Hello all, I am trying to design an online catalogue. It will need to subit an order form to an email and have part #'s etc. . and would be great if it had a sub-total too bad the CandyPress web site demos do not work. . Check out something like Zen Cart (php): http: / / www.zen-cart.com / or ASp.Net Strorefront (asp.net): http: / / www.aspdotnetstorefront.com / Run through the demos explained on the demo start page). keywords: How, to, make, a, catalogue, using, Expression, Web, (shopping, cart, etc) description: Hello all, I am trying to design an online catalogue. It will need to subit an order form to an email and have part #'s etc. . and would be great if it
i want to sell product online using paypal.i am not good in coding . will i have to create my own shopping cart or paypal provide this. . bcoz i dont know how to create custom shopping cart. . . Yes, you have required to create a Shopping cart. you have to create a custom shopping cart. with the paypal you can able to
asp.net and c#?? C# .NET 28-Oct-12 07:55 PM I have a shopping cart that shows the list of items purchased like 2 pencil @ $2.00 total $4.00 I want the total to be shown in a seperate text box below the listbox(shopping cart) as $7.00 how to do it? help needed. . . What control you are using to show your cart items? Datagrid, Datalist, any table etc. . . .Based on the control you used we need to through the items. Or you can also loop through the datatable or array where the cart items exist. Thanks I am creating a shopping cart project with the data source to be a XML file and when i click show
Has anybody used this cart on a site that is hosted by GoDaddy? Some of CP's stated server requirements in the specs provided by GoDaddy, such as which VB script GD uses, MDAC, and email protocols, etc. Expression Web Designer Discussions MDAC (1) VB (1) CandyPress (1) Leeds (1) Addin Volumes (1) Yes! While GoDaddy bites (the professional term) I've deployed CandyPress (my favorite cart by the way) to their servers a couple of times. I've even got a Have you seen ContentSeed (www.contentseed.com)? NOTE: This message was posted from an unmonitored email account. This is an unfortunate necessity due to high volumes of spam sent to email addresses in public newsgroups. Sorry for any inconvenience. That would be awesome to have some help in that area. I am sending you an email at the address below. We have a few customers with GoDaddy hosted CP 4.1