dessie1981
Programmer
Hi Everyone,
I have a function that outputs the the contents of a shopping basket that i have used in my online store in place to place.
I am trying to include this in the body of a mail i want to send but it keeps printing the function to the browser.
Here is my mail code, im using phpmailer
If anyone can help me here that would be great.
Regards
Dessie
I have a function that outputs the the contents of a shopping basket that i have used in my online store in place to place.
Code:
function print_cart() {
print "<center><table border=0 width='80%'>";
print '<tr><td><center><b>PartNum
</b></center></td><td><center><b>Model</b></center></td><td><b><center>
Quantity</b></center></td><td><center><b>
Price</b></center></td></tr>';
print '<tr><td> </td></tr>';
$counter1 = 0;
$counter2 = count($_SESSION['cart']);
$total = 0;
while ($counter1 < $counter2)
{
$p = $_SESSION['cart'][$counter1];
$q = $_SESSION['quantity'][$counter1];
$result = @mysql_query("Select * from products where id ='$p'");
while ($row = mysql_fetch_array($result))
{
print '<tr><td>' . $row['part_no'] . ' </td><td><center>' . $row['model'] . '</center></td><td><center>' . $q . '</center></td><td>' . '
€' . $row['price']*$q . '</td></tr>';
$total = $total + ($row['price'] * $q);
}
$counter1 ++;
}
if (!isset($_SESSION['dcc']))
{
$delivery = 15.00;
$delivery = number_format($delivery,2);
$total = $total + $delivery;
}
$vat = .21;
$totalvat = $vat * $total;
$totalincvat = $totalvat + $total;
$newtotal = round($totalincvat,2);
print '<tr><td><b>----</b><td></td></td><td></td><td>
<b>--</b></td></tr>';
if (!isset($_SESSION['dcc']))
{
print '<tr><td><b>Delivery Charge</b></td><td></td></td><td><td>
<b>€ ' . $delivery . '</b></td></tr>';
}
print '<tr><td><b>Total</b></td><td></td><td></td><td>
<b>€' . $total . '</b></td></tr>';
print '<tr><td><b>Total incVAT</b></td><td></td><td></td><td>
<b>€' . $newtotal . '</b></td></tr>';
print '</table>';
}
I am trying to include this in the body of a mail i want to send but it keeps printing the function to the browser.
Here is my mail code, im using phpmailer
Code:
$mail2 = new PHPMailer();
$mail2->From = "xxxxx@xxx.com";
$mail2->FromName = "Test Mail";
$mail2->Host = "xxxxxxxxxxxxxxxx";
$mail2->Mailer = "smtp";
$mail2->AddAddress($addressto);
$mail2->isHTML(true);
$mail2->Subject = "Order";
$print_cart = 'test';
$mail2->Body = '<p>Order Placed on ' . date("r") . '</p>
<br>
<p>Organisation: ' . $organisation . '</p>
<p>Customer: ' . $_SESSION['username'] . '</p>
<p>Sord Order Number : ' . $neworderid . '</p>
<p>Order......</p>
<p> ' . print_cart() . '</p>
';
if(!$mail2->Send())
{
echo '<p align = "center">Error sending mail</p>';
}
If anyone can help me here that would be great.
Regards
Dessie