I’ve setup a quote system on a website using php jcart. Found a modified version that emailed form and cart contents into an email.
To make the email look a bit nicer in formatting I decided to try to get it to html format. I can get the form fields that the customer enters to email in a table. Name, Email, Phone, Details etc BUT cannot get the cart contents included in the html email.
I’ve done a lot of reading and so far have had no luck getting anything to work from what information I have found.
Here’s the current code that I have it emails me in a table the information customer enters such as name, phone, email:
[php]
$to = ‘[email protected]’;
$subject = ‘New Online Quote’;
$message = ’
test html online quote
<body>
<table cellspacing=\"4\" cellpadding=\"4\" border=\"1\" align=\"center\">
<tr><td><strong>Name:</strong></td><td>' . $_POST['name'] . '</td></tr>
<tr><td><strong>Email:</strong></td><td>' . $_POST['email'] . '</td></tr>
<tr><td><strong>Phone:</strong></td><td>' . $_POST['phone'] . '</td></tr>
<tr><td><strong>Address/Event Details:</strong></td><td>' . $_POST['address'] . '</td></tr>
</table>
<BR><BR>
<table border=\"1\">
<tr><td>Item Number</td><td>Product</td><td>Price</td><td>Qty</td></tr>
</table>
';
// To send HTML mail, the Content-type header must be set
$headers = ‘MIME-Version: 1.0’ . “\r\n”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “\r\n”;
// Additional headers
$headers .= ‘To: My Name <[email protected]>’ . “\r\n”;
$headers .= ‘From: My Name’ . “\r\n”;
// Mail it
mail($to, $subject, $message, $headers);
[/php]
==========================================
Heres what I’m having trouble with. How do I get the cart contents sent to me in a html email? The following code worked well to email me contents in plain text. I have no idea how to modify it to send me cart as html email
[php]
$i=1;
foreach ($cart->get_contents() as $item)
{
$message .= $i.’ .Item: '. $item[‘name’];
$message .= " Price: " . $item[‘price’];
$message .= " Quantity: " . $item[‘qty’];
$message .= “\n\n”;
$i++;
}
[/php]