我正在使用simplecart,我希望将订单发送到我的电子邮箱。我现在没有收到电子邮件,我不知道如何解决这个问题。任何帮助,将不胜感激!
这是我的simpleCart.js
me.emailCheckout = function() {
itemsString = "";
for( var current in me.items ){
var item = me.items[current];
itemsString += item.quantity + " st\n" + item.name + "\n Pris: " + item.price + " kr/st \n\n";
}
var namn=document.getElementById('namn').value; var filter = /^[A-Za-z0-9 ]{3,35}$/;
if (!filter.test(namn))
{
//window.location = "popup.html";
window.alert("Du måste ange namn!");
namn.focus; return true;
}
var telefon=document.getElementById('telefon').value; var filter = /^\d{10}$/;
if (!filter.test(telefon))
{
//window.location = "popup_tel.html";
window.alert("Du måste ange ett korrekt telefonnummer!");
telefon.focus; return true;
}
var namn = document.form.namn.value;
var telefon = document.form.telefon.value;
for (var i=0; i < document.form.betalning.length; i++)
{
if (document.form.betalning[i].checked)
{
var betalning = document.form.betalning[i].value;
}
}
var adress = document.getElementById("adress").value;
var ovrigt = document.getElementById("ovrigt").value;
leverans = "";
for (var i=0; i < document.form.leverans.length; i++)
{
if (document.form.leverans[i].checked)
{
var leverans = document.form.leverans[i].value;
}
}
me.total += "" + " KR"
var form = document.createElement("form");
form.style.display = "none";
form.method = "POST";
form.action = "ordered.php";
form.acceptCharset = "UTF-8";
form.appendChild(me.createHiddenElement("jcitems", itemsString));
form.appendChild(me.createHiddenElement("jctotal", me.total));
form.appendChild(me.createHiddenElement("namn", namn));
form.appendChild(me.createHiddenElement("telefon", telefon));
form.appendChild(me.createHiddenElement("adress", adress));
form.appendChild(me.createHiddenElement("leverans", leverans));
form.appendChild(me.createHiddenElement("betalning", betalning));
form.appendChild(me.createHiddenElement("ovrigt", ovrigt));
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
};
这会将表单发送到ordered.php
<?php
$to = 'mymail@mail.com';
$subject = 'ORDER';
$jcitems = $_POST['jcitems'] .
" \n\n SUMMA: " . $_POST['jctotal'] .
" \n\n-------------------------------\n " .
" \n KUNDINFORMATION:\n " .
" \n Namn:\n " . $_POST['namn'] .
" \n\n Telefon:\n " . $_POST['telefon'] .
" \n\n Hemkörning:\n " . $_POST['leverans'] .
" \n\n Betalar med:\n " . $_POST['betalning'] .
" \n\n Adress:\n " . $_POST['adress'] .
" \n\n Övrigt:\n " . $_POST['ovrigt'] .
" \n\n\n IP: " . $_SERVER['REMOTE_ADDR'] .
" \n\n" . date("Y-m-d") .
" \n" . date("H:i:s") .
" \n\n -" ;
$headers = 'From: Bestallning@Pizzeria' . "\r\n" .
'Reply-To: Mobil@Pizzeria' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $jcitems, $headers);
/*Clearing the cart info after succesfull order is made*/
setcookie ("simpleCart", "", time() - 3600);
//header('Location: ordered.php');
?>