簡體   English   中英

如何在Woocommerce電子郵件中插入帳單明細?

[英]How to insert billing details into Woocommerce email?

我想知道如何在Woocommerce電子郵件中插入帳單明細(姓名,電子郵件和電話號碼)?

這是我用來發送電子郵件的Woocommerce-appointment插件的代碼:

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

<?php if ( $appointment->get_order() && $appointment->get_order()->billing_first_name && $appointment->get_order()->billing_last_name ) : ?>
<p><?php printf( $opening_paragraph, $appointment->get_order()->billing_first_name . ' ' . $appointment->get_order()->billing_last_name ); ?></p>
<?php endif; ?>

<table>
<tbody>
    <?php if ( $appointment->has_staff() && ( $staff = $appointment->get_staff_member() ) ) : ?>
        <tr>
            <th scope="row"><?php _e( 'Appointment Provider', 'woocommerce-appointments' ); ?></th>
            <td><?php echo $staff->display_name; ?></td>
        </tr>
    <?php endif; ?>
    <tr>
        <th scope="row"><?php _e( 'Appointment Date', 'woocommerce-appointments' ); ?></th>
        <td><?php echo $appointment->get_start_date( wc_date_format(), '' ); ?></td>
    </tr>
    <tr>
        <th scope="row"><?php _e( 'Appointment Time', 'woocommerce-appointments' ); ?></th>
        <td><?php echo $appointment->get_start_date( '', get_option( 'time_format' ) ) . ' &mdash; ' . $appointment->get_end_date( '', get_option( 'time_format' ) ); ?></td>
    </tr>
    <tr>
        <th scope="row"><?php _e( 'Appointment Time', 'woocommerce-appointments' ); ?></th>
        <td><?php echo $appointment->get_start_date( '', get_option( 'time_format' ) ) . ' &mdash; ' . $appointment->get_end_date( '', get_option( 'time_format' ) ); ?></td>
    </tr>
</tbody>
</table>

<?php do_action( 'woocommerce_email_footer' ); ?>

我要在其中插入姓名,電子郵件和電話(“客戶姓名”示例):

<tr>
<th scope="row"><?php _e( 'Customer Email', 'woocommerce-appointments' ); ?></th>
<td>**HERE**</td>
</tr>

如果有人可以提供幫助,我將不勝感激。

謝謝。

您可以通過掛鈎並指定自定義字段的名稱,將任何自定義字段添加到您的訂單電子郵件中。

將以下代碼復制到主題函數中。然后轉到WooCommerce>結帳字段以添加新創建的自定義字段。

/**
 * Add the field to order emails
 **/
add_filter('woocommerce_email_order_meta_keys', 'my_woocommerce_email_order_meta_keys');


function my_woocommerce_email_order_meta_keys( $keys ) {
    $keys['How did you hear about us?'] = 'hear_about_us';
    return $keys;
}

這是一個示例,該示例使用WooCommerce>結帳字段設置的“結帳字段編輯器”擴展程序創建的標有“ hear_about_us”的自定義字段: 在此處輸入圖片說明 使用此示例,代碼將是:

$keys['How did you hear about us?'] = 'hear_about_us';

感謝您的回答。 不幸的是,這兩個都不起作用。 但是我設法以非常簡單的方式輸出姓名,電子郵件和電話:

echo $appointment->get_order()->billing_first_name . ' ' . $appointment->get_order()->billing_last_name;
echo $appointment->get_order()->billing_email;
echo $appointment->get_order()->billing_phone;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM