我創建了一個php電子郵件發送訂單後發出。我不確定我在做什麼錯,因爲如果我有多種不同類型的產品,電子郵件只會發送第一個添加的產品。從Authorize.net發送的交易收據包括訂單中的所有產品,但不包括我的電子郵件。我沒有收到任何錯誤,並且電子郵件發送正常。即使有多個產品訂購,只有一種產品在php電子郵件中列出
$to = $email;
$subject = 'Your Example order';
$message = '<img src="'.$logoImage.'">';
$message = '
<html>
<head>
<title>Example Order</title>
</head>
<body>
<p>Thank you for ordering with us!</p>
<p>Your order was successfully sent to us and we will start processing it immediately.</p><br><br>
<p>A charge of $'.$total_price.' was taken from '.$billToName.'\'s account that was sent with the order.
<p>Your order contained:</p>
<p> '.$prdqty.' - '.$prdsize.' - '.$prdname.'</p><br><br>
<p>'. $AuthorrizeResponseText.';</p><br><br>
<p>We really appreciate your business!</p>
</body>
</html>
';
$from = "[email protected]";
$cc = "[email protected]";
// 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: ' .$to. "\r\n";
$headers .= 'From: ' .$from. "\r\n";
$headers .= 'Cc: '.$cc. "\r\n";
// Send the email
mail($to,$subject,$message,$headers);
我有問題,該生產線是這個...
<p> '.$prdqty.' - '.$prdsize.' - '.$prdname. $post_values.'</p>
我需要它包括所有都是在訂單,而不僅僅是一個產品的不同。我以同樣的方式在我的網站上抓取產品。從我的數據庫輸出它們,然後通過整個站點的會話進行傳輸。我還會發送攜帶同一會話的電子郵件。這是如何變量的結構...
foreach($_SESSION['shopping_cart'] as $id => $product) {
$product_id = $product['product_id'];
$prdname = $products[$product_id]['product_name'];
有沒有辦法,我可以做到這一點,或者我失蹤了嗎?
更新: 我寫了這個代碼,但它僅包括
<p>'. $AuthorrizeResponseText.';</p><br><br>
<p>We really appreciate your business!</p>
$to = $email;
$subject = 'Your Example order';
$message = '<img src="'.$logoImage.'">';
$message = '
<html>
<head>
<title>Example Order</title>
</head>
<body>
<p>Thank you for ordering with us!</p>
<p>Your order was successfully sent to us and we will start processing it immediately.</p><br><br>
<p>A charge of $'.$total_price.' was taken from '.$billToName.'\'s account that was sent with the order.
<p>Your order contained:</p><br><ul>';
foreach($_SESSION['shopping_cart'] as $id => $product) {
$product_id = $product['product_id'];
$prdname = $products[$product_id]['product_name'];
$prdprice = $products[$product_id]['price'];
$prdqty = $product['quantity'];
$prdsize = $product['size'];
$message .= '<li>' .$prdqty.' - '.$prdsize.' - '.$prdname.'</li><br>';
}
$message .= '</ul>';
$message ='
<p>'. $AuthorrizeResponseText.';</p><br><br>
<p>We really appreciate your business!</p>
</body>
</html>
';
$from = "[email protected]";
$cc = "[email protected]";
任何想法,對什麼是錯後的部分?
您訂購的產品在哪裏?你可以使用一個foreach,但你需要創建一個有序的項目數組,然後你可以做foreach。 –
答案是你提供的foreach循環 - 所以試試吧 – 2015-06-20 03:34:39
我剛剛更新了我試過的問題。它悲慘地失敗了。請原諒我對此的無知。 – Becky