1 回答
TA贡献1799条经验 获得超9个赞
我找到了一个解决方案:
phpmailer.php
...
$mail->Body = nl2br("Hi {$_POST['name']} \r\n");
/// List Cart Item(s) Start
$total = 0;
if(!empty($_SESSION['cart'])){
include 'config.php';
$index = 0;
if(!isset($_SESSION['cart'])){
$_SESSION['cart'] = array_fill(0, count($_SESSION['cart']), 1);
}
$sql = "SELECT * FROM products WHERE id IN (".implode(',',$_SESSION['cart']).")";
$query = $conn->query($sql);
while($row = $query->fetch_assoc()){
$index;
$service = $row['name'];
$qty = $_SESSION['cart'][$index];
$qtyPrice = $row['price'];
$qtyTotalprice = number_format($_SESSION['cart'][$index]*$row['price'], 2);
$total += $_SESSION['cart'][$index]*$row['price'];
$mail->Body .= nl2br("$service: ($qty) x ($$qtyPrice) = $$qtyTotalprice \r\n");
$index ++;
}
}
$mail->Body .= nl2br(" \r\nTOTAL: $ <u>$total</u>");
/// Cart Item(s) End
$mail->Body .= nl2br("Kind regards \r\n");
...
- 1 回答
- 0 关注
- 90 浏览
添加回答
举报