2017-11-11 11 views
0

새 계정 등록 전자 메일에서 전화 번호를 표시하려면 어떻게합니까?WooCommerce 새 계정 전자 메일 알림에 고객 전화 표시

나는 추가가 전화 번호 필드와 같은 :

<p class="form-row form-row-wide"> <label for="reg_billing_phone">Phone <span class="required">*</span></label> <input type="text" class="input-text" name="billing_phone" id="reg_billing_phone" value=""></p> 

고객의 새로운 계정 이메일 템플릿 코드는 (나는 숫자 전화를 표시 할) 입니다 : 당신이 필요로

<?php 
/** 
* Customer new account email 
* 
* This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-new-account.php. 
* 
* HOWEVER, on occasion WooCommerce will need to update template files and you 
* (the theme developer) will need to copy the new files to your theme to 
* maintain compatibility. We try to do this as little as possible, but it does 
* happen. When this occurs the version of the template file will be bumped and 
* the readme will list any important changes. 
* 
* @see   https://docs.woocommerce.com/document/template-structure/ 
* @author  WooThemes 
* @package  WooCommerce/Templates/Emails 
* @version  1.6.4 
*/ 

if (! defined('ABSPATH')) { 
    exit; // Exit if accessed directly 
} 

?> 

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

    <p><?php printf(__('Thanks for creating an account on %1$s. Your username is %2$s', 'woocommerce'), esc_html($blogname), '<strong>' . esc_html($user_login) . '</strong>'); ?></p> 

<?php if ('yes' === get_option('woocommerce_registration_generate_password') && $password_generated) : ?> 

    <p><?php printf(__('Your password has been automatically generated: %s', 'woocommerce'), '<strong>' . esc_html($user_pass) . '</strong>'); ?></p> 
<p>Phone No:<?php echo get_user_meta($customer_id, 'billing_phone', true) ?></p> 

<?php endif; ?> 

    <p><?php printf(__('You can access your account area to view your orders and change your password here: %s.', 'woocommerce'), make_clickable(esc_url(wc_get_page_permalink('myaccount')))); ?></p> 

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

답변

0

다음 $ 사용자 ID와 당신이 사용할 수있는 $의 USER_LOGIN (사용자 로그인 이름)을 가지고 템플릿에 get_user_by() 워드 프레스는이 방식으로 작동
<?php 


if (! defined('ABSPATH')) { 
    exit; // Exit if accessed directly 
} 
?> 

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

$user = get_user_by('login', $user_login); // Get the user object (from the user login) 
$user_id = $user->ID; // Get the user ID 
$user_phone = get_user_meta($user_id, 'billing_phone', true); // User phone 
?> 

    <p><?php printf(__('Thanks for creating an account on %1$s. Your username is %2$s', 'woocommerce'), esc_html($blogname), '<strong>' . esc_html($user_login) . '</strong>'); ?></p> 

<?php 
    // Display the user phone 
    echo '<p>'.__("Your registered user phone is: ", "woocommerce").$user_phone.'</p>'; 

if ('yes' === get_option('woocommerce_registration_generate_password') && $password_generated) : ?> 

    <p><?php printf(__('Your password has been automatically generated: %s', 'woocommerce'), '<strong>' . esc_html($user_pass) . '</strong>'); ?></p> 
<p>Phone No:<?php echo get_user_meta($customer_id, 'billing_phone', true) ?></p> 

<?php endif; ?> 

    <p><?php printf(__('You can access your account area to view your orders and change your password here: %s.', 'woocommerce'), make_clickable(esc_url(wc_get_page_permalink('myaccount')))); ?></p> 
+0

가 대단히 @LoicTheAztec 감사합니다

// Get the user billing phone: $user_phone = get_user_meta($user_id, 'billing_phone', true); 

지금 당신은 당신의 템플릿에이 코드를 사용할 수 있습니다 :

이제 사용자 과금 전화를위한이 방법을 워드 프레스 기능 [get_user_meta()][2]을 사용할 수 있습니다 귀하의 코드 나를 위해 일하고 –

+0

안녕하세요, 인스턴트 메신저 메일 템플릿에서 사용자 정의 필드를 얻을 수 있지만 메일에 빈 값을 받고 동일한 코드를 사용하려고. –

+0

@NishaSharma 이메일 템플릿에서 사용자 ID를 얻으려면 주로 다음과 같이 정의 된'$ order' 객체 변수를 사용하십시오 : '$ user_id = $ order-> get_customer_id();'또는' – LoicTheAztec