[WordPress] 追加する方法 woocommerce 製品ページのお問い合わせフォームでフィールド電話なし

スポンサーリンク

Question

woocommerce 製品ページにクイックお問い合わせフォームを追加したが、唯一の名前、電子メール、件名 & お問い合わせのオプションが含まれます

見てここ http://demo.hashkart.com

いいえ電話と呼ばれる exta フィールドを追加しますこのフォームで

このまたは任意の余分のプラグインのためのソリューションを提案してください

事前のおかげで.

答え

注: これを実装する前にバックアップを取る

wp-content > plugins > product-enquiry-for-woocommerce > data >contact.php

に行く

と次のコードで

contact.php

のコンテンツを 置き換える:

     true,
        "your_number" =>true,
        "form_cc"   => (isset($form_data['enable_send_mail_copy']) ? true : false),
        "ip"        => false,
        "user_agent"    => false
    );

    // Process
    $action = isset($_POST["action"]) ? $_POST["action"] : "";
    if (empty($action)) {
        // Send back the contact form HTML
        $output = "

Product Enquiry:

"; if ($extra["form_subject"] && $extra["your_number"]) { $output .= " "; $output .= " "; } $output .= ""; $output .= ""; $output .= ""; $output .= ""; $output .= "
"; if ($extra["form_cc"]) { $output .= " Send me a copy
"; } $output .= "
"; echo $output; $to = base64_encode($to); $subject = base64_encode($subject); $site_name = base64_encode($site_name); echo ''; } else if ($action == "wdm_send") { // Send the email //echo "
";print_r($_REQUEST);echo "

";exit;
$name = isset($_POST["name"]) ? $_POST["name"] : "";
$email = isset($_POST["email"]) ? $_POST["email"] : "";
$urphone = isset($_POST["phone"]) ? $_POST["phone"] : "";
$subject = isset($_POST["wdm_form_def_sub"]) ? $_POST["wdm_form_def_sub"] : "";
$subject = base64_decode($subject);
$subject = !empty($_POST["subject"]) ? $_POST["subject"] : $subject;
$product_url = isset($_POST["wdm_product_url"]) ? $_POST["wdm_product_url"] : "";
$product_name = isset($_POST["wdm_product_name"]) ? $_POST["wdm_product_name"] : "";
$message = isset($_POST["message"]) ? $_POST["message"] : "";
$cc = isset($_POST["cc"]) ? $_POST["cc"] : "";
$token = isset($_POST["token"]) ? $_POST["token"] : "";
$to = isset($_POST["wdm_form_mail_to"]) ? $_POST["wdm_form_mail_to"] : "";
$to = base64_decode($to);
//echo $to;exit;
$site_name = isset($_POST["wdm_website_name"]) ? $_POST["wdm_website_name"] : "";
$site_name = base64_decode($site_name);

// make sure the token matches
if ($token === smcf_token($to)) {
smcf_send($name, $email, $subject, $urphone, $product_url, $product_name, $site_name, $message, $cc);
echo "Your enquiry sent successfully. We will get back to you soon.";
}
else {
echo "Unfortunately, your enquiry could not be verified.";
}
}

function smcf_token($s) {
return md5("smcf-" . $s . date("WY"));
}

// Validate and send email
function smcf_send($name, $email, $subject, $urphone, $product_url, $product_name, $site_name, $message, $cc) {
global $to, $extra;

// Filter and validate fields
$name = smcf_filter($name);
$subject = smcf_filter($subject);
$email = smcf_filter($email);

if (!smcf_validate_email($email)) {
$subject .= " - invalid email";
$message .= "\n\nBad email: $email";
$email = $to;
$cc = 0; // do not CC "sender"
}

// Add additional info to the message
if ($extra["ip"]) {
$message .= "\n\nIP: " . $_SERVER["REMOTE_ADDR"];
}
if ($extra["user_agent"]) {
$message .= "\n\nUSER AGENT: " . $_SERVER["HTTP_USER_AGENT"];
}

// Set and wordwrap message body
$body = "Product Enquiry from ". $site_name . "

";
$body .= "Product Name: '". $product_name ."'

";
$body .= "Product URL: ". $product_url ."

";
$body .= "Customer Name: ". $name ."

";
$body .= "Customer Email: ". $email ."

";
$body .= "Customer Phone Number: ". $urphone ."

";
$body .= "Message:
". $message;
$body = wordwrap($body, 100);

// Build header
$headers = "From: $email\n";
$headers .= "Reply-To: $email \n";
if ($cc == 1) {
$headers .= "Cc: $email\n";
}
// $headers .= "X-Mailer: PHP/SimpleModalContactForm";

// UTF-8
if (function_exists('mb_encode_mimeheader')) {
$subject = mb_encode_mimeheader($subject, "UTF-8", "B", "\n");
}
else {
// you need to enable mb_encode_mimeheader or risk
// getting emails that are not UTF-8 encoded
}
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
$headers .= "Content-Transfer-Encoding: quoted-printable\n";
//echo "to ".$to."
";
//echo "subject ".$subject."
";
//echo "body ".$body."
";
//echo "headers ".$headers."
";exit;
wp_mail($to, $subject, $body, $headers) or die("Unfortunately, a server issue prevented delivery of your message.");

//wp_mail($to, $subject, $body, $headers) or
// die("Unfortunately, a server issue prevented delivery of your message.");
}

// Remove any un-safe values to prevent email injection
function smcf_filter($value) {
$pattern = array("/\n/","/\r/","/content-type:/i","/to:/i", "/from:/i", "/cc:/i");
$value = preg_replace($pattern, "", $value);
return $value;
}

// Validate email address format in case client-side validation "fails"
function smcf_validate_email($email) {
$at = strrpos($email, "@");

// Make sure the at (@) sybmol exists and
// it is not the first or last character
if ($at && ($at < 1 || ($at + 1) == strlen($email))) return false; // Make sure there aren't multiple periods together if (preg_match("/(\.{2,})/", $email)) return false; // Break up the local and domain portions $local = substr($email, 0, $at); $domain = substr($email, $at + 1); // Check lengths $locLen = strlen($local); $domLen = strlen($domain); if ($locLen < 1 || $locLen > 64 || $domLen < 4 || $domLen > 255)
return false;

// Make sure local and domain don't start with or end with a period
if (preg_match("/(^\.|\.$)/", $local) || preg_match("/(^\.|\.$)/", $domain))
return false;

// Check for quoted-string addresses
// Since almost anything is allowed in a quoted-string address,
// we're just going to let them go through
if (!preg_match('/^"(.+)"$/', $local)) {
// It's a dot-string address...check for valid characters
if (!preg_match('/^[-a-zA-Z0-9!#$%*\/?|^{}`~&\'+=_\.]*$/', $local))
return false;
}

// Make sure domain contains only valid characters and at least one period
if (!preg_match("/^[-a-zA-Z0-9\.]*$/", $domain) || !strpos($domain, "."))
return false;

return true;
}
//exit;
?>

アラーム:

PRO

バージョンでその機能を提供するプラグイン。だからそれを使ってください。一時使用のためにだけそれを転記午前し、その使用のライセンスに会っていません

私に知らせてくださいどちらか動作しているかそのためその 未テスト

http://stackoverflow.com/questions/27730334/how-to-add-phone-no-field-in-enquiry-form-of-woocommerce-product-page

スポンサーリンク

Leave a Reply