Woocommerce add if Customer is Guest to New Order Emails

huangapple go评论82阅读模式
英文:

Woocommerce add if Customer is Guest to New Order Emails

问题

使用WooCommerce,我已启用了访客结账选项。如果客户在结账时是访客,我想在新订单确认电子邮件中,在客户详细信息上方快速添加词语“访客”,以便迅速标识这位客户是访客而不是已注册用户。

/*
 * @hooked WC_Emails::customer_details() 显示客户详细信息
 * @hooked WC_Emails::email_address() 显示电子邮件地址
 */
do_action('woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email);

请注意,上述代码是用于实现此功能的代码示例,并且只是将“访客”添加到电子邮件中的一部分。如果您需要更多详细信息或实际实现此功能的代码,请提供更多上下文或要求。

英文:

Using Woocommerce I have guest checkout enabled. If a customer is a guest upon checkout, I'd like to then add the word "Guest" to the new order confirmation email right above customer details to quickly reference this customer was a guest and not a registered user already.

/*
 * @hooked WC_Emails::customer_details() Shows customer details
 * @hooked WC_Emails::email_address() Shows email address
 */
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );

答案1

得分: 1

add_action( 'woocommerce_email_customer_details', 'add_guest_label_to_email', 5, 4 );
function add_guest_label_to_email( $order, $sent_to_admin, $plain_text, $email ) {
// Check if customer is a guest
if ( ! $order->get_user_id() ) {
$guest_label = '

访客

';
echo $guest_label;
}
}

英文:

This should do it

add_action( 'woocommerce_email_customer_details', 'add_guest_label_to_email', 5, 4 );
function add_guest_label_to_email( $order, $sent_to_admin, $plain_text, $email ) {   
    // Check if customer is a guest
    if ( ! $order->get_user_id() ) {
        $guest_label = '<p><strong>Guest</strong></p>';
        echo $guest_label;
    }
}

huangapple
  • 本文由 发表于 2023年7月11日 08:27:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76658045.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定