Shopping cart e-mail help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Shopping cart e-mail help

Post by Joe »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I am having a small problem with a shopping cart that I need help with. When the customer places and order and goes through the paypal process an e-mail is sent to them in html format which works great but the products and prices aren't being displayed in the e-mail as they should. The html for the e-mail goes like this:

Code: Select all

$html_a = "<html>
<head>
<style>
body{
	FONT-SIZE: 11px;
	FONT-FAMILY: Verdana, Arial, sans-serif;
	COLOR: #808080;
}
.ch10{
	FONT-SIZE: 11px;
	FONT-FAMILY: Verdana, Arial, sans-serif;
	COLOR: #808080;
}
</style>
</head>
<body>
Dear ".$_SESSION['customer']['username'] .",<br>
<br>
Thank you for your purchase.<br>
You can reach your download(s) by logging in and clicking the \"My Items\" in your customer menu.<br>
In case you ordered non-downloadable items they will be sent to the following address:<br>
<br>
<i>".$_SESSION['customer']['name']."<br>
".$_SESSION['customer']['address']."<br>
".$_SESSION['customer']['zip']."<br>
".$_SESSION['customer']['city']."<br>
".$_SESSION['customer']['country']."<br>
<br>
Username: ".$_SESSION['customer']['username']."<br>
<br>
</i>

<table cellpadding='3' cellspacing='0' border='0' width='100%'>
		<tr bgcolor='#CCCCCC'>
			<td class='ch10'><b>Article</b></td>
			<td class='ch10' align='right'><b>Price</b></td>
			<td class='ch10' colspan='3' align='right'>Order code: <b>".$ordernr."</b></td>
		</tr>";

		foreach ($_SESSION['mycart'] as $cartitem1) {

			$items_cart[] =  "<tr>
						<td class='ch10'><b>".addslashes($cartitem1['name'])."</b></td>
						<td class='ch10' align='right'>&pound; ".$cartitem1['price']."</td>
						<td class='ch10'>&nbsp;</td>
						</tr>";
		}

		$html_a .= $items_cart . "

		<tr>
			<td class='ch10'><b>Shipping costs (".$_SESSION['shipping_zone'].")</b></td>
			<td align='right' class='ch10'><b>&pound; ".$_SESSION['shipping_costs']."</b></td>
			<td align='center' class='ch10'>&nbsp;</td>
		</tr>


</table>

<br>
Kind regards,<br>
<a href='http://www.site.com'>site.com</a>
</body>
</html>";
As you can see I am using foreach ($_SESSION['mycart'] as $cartitem1) and then I'm trying to make an array $items_cart with the products and prices but it's not working right?. Any help appreciated here.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

you need to print the items in the array

try doing:

Code: Select all

foreach ($_SESSION['mycart'] as $cartitem1) {

                        $html_a .=  "<tr> ...$cartitem1['name']...etc
Post Reply