I would like to display email address of customer in myaccount Woocommerce panel.
I try copy/paste this part code from thankyou
file template:
<?php _e( 'Email:', 'woocommerce' ); ?>
<strong><?php echo $order->get_billing_email(); ?></strong>
But it doesn't work.
How i can do it?
As the thankyou.php
template code is related the $order
object, it's normal that it doesn't work in myaccount/dashboard.php
template.
If you look to the existing code you will see $current_user
variable that you can use. It's an instance of the WP_User
object.
So instead insert the code below to the myaccount/dashboard.php
template:
<p><?php _e( 'Email:', 'woocommerce' ); ?>
<strong><?php echo $current_user->user_email; ?></strong></p>
OR (the billing email) :
<p><?php _e( 'Email:', 'woocommerce' ); ?>
<strong><?php echo $current_user->billing_email; ?></strong></p>
Tested and works
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.