简体   繁体   English

Woocommerce - 如何在感谢页面上为未登录用户显示帐单详细信息 email?

[英]Woocommerce - How to show Billing details email for non logged-in users on Thank You Page?

In WooCommerce, for logged in users the Thankyou (order-received) page does show the customer details like the name, address and e-mail, but nothing when customers are not registered.在 WooCommerce 中,对于已登录的用户,Thankyou(已收到订单)页面确实显示了客户详细信息,例如姓名、地址和电子邮件,但当客户未注册时则不显示。

I found a workround for showing Billing details section, but Email is still hidden in the first overview section (Section above Order details) How to show email too, for non logged in user?我找到了一个显示帐单详细信息部分的工作区,但是 Email 仍然隐藏在第一个概述部分(订单详细信息上面的部分)如何显示 email,对于未登录的用户?

add_action( 'woocommerce_thankyou', 'adding_customers_details_to_thankyou', 10, 1 );
function adding_customers_details_to_thankyou( $order_id ) {
    // Only for non logged in users
    if ( ! $order_id ) return;

    $order = wc_get_order($order_id); // Get an instance of the WC_Order object

    wc_get_template( 'order/order-details-customer.php', array('order' => $order ));
}

You can check this code it will show up all details available for guest user on thank you page add this code in function.php file of your active child theme (or theme) or also in any plugin file.您可以检查此代码,它将在感谢页面上显示所有可供访客用户使用的详细信息,将此代码添加到您的活动子主题(或主题)的 function.php 文件或任何插件文件中。

在此处输入图像描述

So in woocommerce plugin download the current thankyou.php file and remove is_user_logged_in() from the line for getting email to be displayed for guest users因此,在 woocommerce 插件中下载当前的thankyou.php 文件并从获取 email 的行中删除 is_user_logged_in() 以显示给来宾用户在此处输入图像描述

Tested and Worked经过测试和工作

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

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