即使未注册,也会在 WooCommerce 的谢谢页面上显示客户详细信息 [英] Show customer details on WooCommerce Thankyou page even if not registered

查看:76
本文介绍了即使未注册,也会在 WooCommerce 的谢谢页面上显示客户详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 WooCommerce 中,对于登录用户,Thankyou(已收到订单)页面确实会显示客户详细信息,例如姓名、地址和电子邮件,但如果客户未注册,则不会显示任何信息.>

如何确保非注册用户在支付成功完成后,可以在Thankyou(已收到订单)页面上看到他们的详细信息,就像注册用户一样?

为什么非注册用户的Thankyou(已收到订单)页面上没有显示客户详细信息?

解决方案

您可以使用以下代码更改未登录用户的此行为:

add_action( 'woocommerce_thankyou', 'adding_customers_details_to_thankyou', 10, 1 );函数添加_customers_details_to_thankyou( $order_id ) {//仅适用于未登录的用户如果(!$order_id || is_user_logged_in())返回;$order = wc_get_order($order_id);//获取 WC_Order 对象的实例wc_get_template('order/order-details-customer.php', array('order' => $order ));}

代码位于活动子主题(或主题)的 function.php 文件或任何插件文件中.

经过测试并有效.

<块引用>

客户信息不显示可能是出于安全原因,因为此信息没有真正受到保护,与登录用户的方式相同(注册用户).

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.

How can I ensure that non registered users can see their details on the Thankyou (order-received) page when the payment is successfully finished, just like registered users?

Why the customer details doesn't show up on the Thankyou (order-received) page for non registered users?

解决方案

You can change this behavior for non logged users with the following code:

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 || is_user_logged_in() ) 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 ));
}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

Tested and works.

May be the fact that customer info doesn't show up is for security reasons, as this info is not really protected the same way than for logged in users (registered users).

这篇关于即使未注册,也会在 WooCommerce 的谢谢页面上显示客户详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆