简体   繁体   English

Woocommerce管理员订单页面详细信息-电子邮件不起作用

[英]Woocommerce admin order page details - Email is not working

在此处输入图片说明 This is my form when admin submit it mail has too be shoot but when i click on submit getting order updated but i am not reciving mail 这是我的表格,当管理员提交它的邮件也被射击时,但是当我单击提交以更新订单但我没有收到邮件时

my code is this as im not pro in developing its might be mistake please review and solve this i want to echo all field on woocomerce admin detailpage only and also submit on that page 我的代码是这个,因为我在开发过程中不赞成,可能是错误的,请检查并解决这个问题,我只想在woocomerce admin detailpage上回显所有字段,然后在该页面上提交

function html_form_code() {
    echo '<form action="' . esc_url( $_SERVER['REQUEST_URI'] ) . '" method="post">';
    echo '<p>';
    echo 'Your Name (required) <br/>';
    echo '<input type="text" name="cf-name" pattern="[a-zA-Z0-9 ]+" value="' . ( isset( $_POST["cf-name"] ) ? esc_attr( $_POST["cf-name"] ) : '' ) . '" size="40" />';
    echo '</p>';
    echo '<p>';
    echo 'Your Email (required) <br/>';
    echo '<input type="email" name="cf-email" value="' . ( isset( $_POST["cf-email"] ) ? esc_attr( $_POST["cf-email"] ) : '' ) . '" size="40" />';
    echo '</p>';
    echo '<p>';
    echo 'Subject (required) <br/>';
    echo '<input type="text" name="cf-subject" pattern="[a-zA-Z ]+" value="' . ( isset( $_POST["cf-subject"] ) ? esc_attr( $_POST["cf-subject"] ) : '' ) . '" size="40" />';
    echo '</p>';
    echo '<p>';
    echo 'Your Message (required) <br/>';
    echo '<textarea rows="10" cols="35" name="cf-message">' . ( isset( $_POST["cf-message"] ) ? esc_attr( $_POST["cf-message"] ) : '' ) . '</textarea>';
    echo '</p>';
    echo '<p><input type="submit" name="cf-submitted" value="Send"></p>';
    echo '</form>';
}

function deliver_mail() {

    // if the submit button is clicked, send the email
    if ( isset( $_POST['cf-submitted'] ) ) {

        // sanitize form values
        $name    = sanitize_text_field( $_POST["cf-name"] );
        $email   = sanitize_email( $_POST["cf-email"] );
        $subject = sanitize_text_field( $_POST["cf-subject"] );
        $message = esc_textarea( $_POST["cf-message"] );

        // get the blog administrator's email address
        $to = get_option( 'admin_email' );

        $headers = "From: $name <$email>" . "\r\n";

        // If email has been process for sending, display a success message
        if ( wp_mail( $to, $subject, $message, $headers ) ) {
            echo '<div>';
            echo '<p>Thanks for contacting me, expect a response soon.</p>';
            echo '</div>';
        } else {
            echo 'An unexpected error occurred';
        }
    }
}
add_action( 'dbx_post_sidebar', 'html_form_code', 10, 1); 

请在代码中添加以下行,让我知道会发生什么。

add_action('init','deliver_mail');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Woocommerce管理订单详细信息 - 在订单详细信息页面上显示自定义数据 - Woocommerce Admin Order Details - Show custom data on order details page WooCommerce 管理订单页面 - 删除电子邮件和电话上的超链接 - WooCommerce admin order page - remove hyperlink on email and phone 添加自定义列以订购商品并使其在 WooCommerce 管理订单详细信息页面中可排序 - Add a custom column to order items and make it sortable in WooCommerce admin order details page 在 WooCommerce 管理订单详细信息页面的订单项目表中显示产品元数据 - Show product meta in order items table on WooCommerce admin order details page 在 Wordpress/Woocommerce 管理员订单详细信息中提交表单 - Submitting a Form in Wordpress/Woocommerce admin order details 在 Woocommerce 电子邮件模板中获取订单详细信息 - Get order details in Woocommerce email templates 隐藏WooCommerce感谢您的页面订单详情 - Hide WooCommerce thank you page order details 自定义订单详细信息页面上的Woocommerce自定义字段 - Woocommerce Custom Field on Custom Order Details Page 从 WooCommerce 处理订单 email 通知中删除订单详细信息 - Remove order details from WooCommerce processing order email notification 从Woocommerce中已完成的订单电子邮件通知中删除订单明细表 - Remove order details table from completed order email notification in Woocommerce
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM