在WooCommerce第三方插件电子邮件中包含客户详细信息

时间:2020-02-22 作者:labworxsa

我正在使用Woocommerce简单拍卖插件。拍卖结束后,管理员会收到一封电子邮件,上面写着:

(拍卖名称)的拍卖。中标金额为R5000。

这是该模板的代码:

<?php
/**
 * Admin auction finish  email
 *
 */

if ( ! defined( \'ABSPATH\' ) ) exit; // Exit if accessed directly 
$product_data = wc_get_product(  $product_id );

?>

<?php do_action(\'woocommerce_email_header\', $email_heading, $email); ?>

<p><?php printf( __( "The auction for <a href=\'%s\'>%s</a> finished. Winning bid is %s. ", \'wc_simple_auctions\' ),get_permalink($product_id), $product_data->get_title(), wc_price($product_data->get_curent_bid())); ?></p>

<p><?php do_action( \'woocommerce_email_customer_details\', $order, $sent_to_admin, $plain_text, $email ); ?></p>

<?php do_action(\'woocommerce_email_footer\', $email); ?>
我有没有办法在这封邮件中包含客户账单的详细信息?

1 个回复
SO网友:7uc1f3r

要么你用钩子

function include_customer_details( $order, $sent_to_admin, $plain_text, $email ) {
    // Only admin need to know.
    if ( !$sent_to_admin ) {
        return;
    }

    // test first, then delete the line below and complete the if statement
    echo \'<pre>\', print_r($email->id, 1), \'</pre>\';

    /*
    if ( $email->id == \'paste result from test mail\' ) {    
        echo \'my extra text\';
    }
    */
}
add_action(\'woocommerce_email_customer_details\', \'include_customer_details\', 10, 4 );
或者调整模板文件,因为您可以访问$订单,您可以轻松获得订单信息

更多信息:

https://businessbloomer.com/woocommerce-easily-get-order-info-total-items-etc-from-order-object/

<?php
/**
 * Admin auction finish  email
 *
 */

if ( ! defined( \'ABSPATH\' ) ) exit; // Exit if accessed directly 
$product_data = wc_get_product(  $product_id );

?>

<?php do_action(\'woocommerce_email_header\', $email_heading, $email); ?>

<p><?php printf( __( "The auction for <a href=\'%s\'>%s</a> finished. Winning bid is %s. ", \'wc_simple_auctions\' ),get_permalink($product_id), $product_data->get_title(), wc_price($product_data->get_curent_bid())); ?></p>

<p><?php echo \'<pre>\', print_r($product_data, 1), \'</pre>\'; //etc... ?></p>
<p><?php do_action( \'woocommerce_email_customer_details\', $order, $sent_to_admin, $plain_text, $email ); ?></p>

<?php do_action(\'woocommerce_email_footer\', $email); ?>

相关推荐