简体   繁体   English

在woocommerce电子邮件中添加自定义信息

[英]Add custom info in woocommerce email

Before I updated all my plugins and WP I had some information displaying in the new order woo email after the total. 在更新所有插件和WP之前,总计之后有一些信息显示在新订单中。 Like: customer note, email and phone. 像:客户备注,电子邮件和电话。

But after the updates they are gone. 但是更新之后它们就消失了。 I do not know from where is this information come from. 我不知道这些信息是从哪里来的。 I tried to look in the woo settings but I did not find anything. 我尝试查看woo设置,但未找到任何内容。

Does someone know how to put them back? 有人知道如何把它们放回去吗?

For an example, 举个例子

 // Edit order items table template defaults
function sww_add_wc_order_email_images( $table, $order ) {

ob_start();

$template = $plain_text ? 'emails/plain/email-order-items.php' : 'emails/email-order-items.php';
wc_get_template( $template, array(
    'order'                 => $order,
    'items'                 => $order->get_items(),
    'show_download_links'   => $show_download_links,
    'show_sku'              => $show_sku,
    'show_purchase_note'    => $show_purchase_note,
    'show_image'            => true,
    'image_size'            => $image_size
) );

return ob_get_clean();
}
add_filter( 'woocommerce_email_order_items_table', 'sww_add_wc_order_email_images', 10, 2 );

For more details, 更多细节,

Link 1 , Link 2 , Link 3 , Link 4 链接1链接2链接3链接4

Hope this will helps you. 希望这对您有帮助。

I finally found a solution, including this code in the function.php 我终于找到了解决方案,包括在function.php中的这段代码

function wc_customer_details( $fields, $sent_to_admin, $order ) {
    if ( empty( $fields ) ) {
        if ( $order->get_customer_note() ) {
            $fields['customer_note'] = array(
                'label' => __( 'Customer Note', 'woocommerce' ),
                'value' => wptexturize( $order->get_customer_note() ),
            );
        }
        if ( $order->get_billing_email() ) {
            $fields['billing_email'] = array(
                'label' => __( 'Email address', 'woocommerce' ),
                'value' => wptexturize( $order->get_billing_email() ),
            );
        }
        if ( $order->get_billing_phone() ) {
            $fields['billing_phone'] = array(
                'label' => __( 'Phone', 'woocommerce' ),
                'value' => wptexturize( $order->get_billing_phone() ),
            );
        }
    }
    return $fields;
}
add_filter( 'woocommerce_email_customer_details_fields', 'wc_customer_details', 10, 3 );

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM