これにより、電子メールの注文、補足フィールドがユーザー「電話と住所」に追加されます。
チェックアウト中にユーザーが登録されているかどうかを確認します。そうでない場合は、登録にリダイレクトされます。
メールの注文が成功した場合にのみ、ショッピングカートがクリアされます。
ショップのオーナー「shop@domain.com」とユーザーのメールに2通のメールを送信して注文を確認します
注文が成功した後、ありがとうパートの新しいページを作成する必要があります
simplecartjs:288行目あたりが私の中にあります
me.emailCheckout = function() {
itemsString = "";
for( var current in me.items ){
var item = me.items[current];
itemsString += item.name + " " + item.quantity + " " + item.price + "\n";
}
var form = document.createElement("form");
form.style.display = "none";
form.method = "POST";
form.action = "sendjs.php";
form.acceptCharset = "utf-8";
form.appendChild(me.createHiddenElement("jcitems", itemsString));
form.appendChild(me.createHiddenElement("jctotal", me.total));
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
}
sendjs.php
<?php require( dirname(__FILE__) . '/wp-load.php' );
/* cheking is user is logged in*/
if ( is_user_logged_in() ) {
get_currentuserinfo(); /* getting user details*/
/* sending e-mail to the shop email */
$to = 'shop@domain.com';
$subject = 'New Order';
$jcitems = " Name: " . $current_user->user_lastname .
" \n First Name: " . $current_user->user_firstname .
" \n Email: " . $current_user->user_email .
" \n Phone: " . $current_user->phone .
" \n Adress: " . $current_user->adress ;
$headers = 'From: shop@domain.com' . "\r\n" .
'Reply-To: shop@domain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $jcitems, $headers);
/* sending e-mail with the order to the users email*/
$to = $current_user->user_email;
$subject = 'Order copy from Domain';
$jcitems = "Thank you for you order. Below you have your ordered products".
" \n ORDER: \n\n " . $_POST['jcitems'] . "Total: " . $_POST['jctotal'] . " USD" .
"\n\n http://www.domain.com \nshop@domain.com";
$headers = 'From: shop@domain.com' . "\r\n" .
'Reply-To: shop@domain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $jcitems, $headers);
/*Clearing the cart info after succesfull order is made*/
setcookie ("simpleCart", "", time() - 3600);
/*redirecting user to Thank you page from Wordpress*/
Header('Location: http://www.domain.com/thank_you/'); }
else { /*sending user to register*/
header( 'Location: http://www.domain.com/wp-login.php?action=register' ) ; exit; } ?>
ユーザーの「電話と住所」に2つのフィールドを追加するには、ワードプレス用のRegisterPlusプラグインが必要です。
必ず[
登録フィールドの
追加][プロファイルフィールドの追加]をオンにして
ください 。