首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将用户的电子邮件地址添加到Woocommerce电子邮件模板#php?

如何将用户的电子邮件地址添加到Woocommerce电子邮件模板#php?
EN

Stack Overflow用户
提问于 2014-07-22 19:14:57
回答 1查看 394关注 0票数 2

我想在模板中添加用户的电子邮件地址,当他们进行预订时?

我知道要在代码中添加类似这样的内容:

代码语言:javascript
复制
<?php if ($order->billing_email) : ?>
    <p><strong><?php _e('Email:', 'woothemes'); ?></strong> <?php echo $order->billing_email; ?></p>
<?php endif; ?>

以下是电子邮件的模板代码-如此简单的答案,但无法解决!

代码语言:javascript
复制
<?php
/**
 * Admin new booking email
 */
if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}
?>

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

<?php if ( $booking->get_order() ) : ?>
    <p><?php printf( __( 'A new booking has been made by %s. The details of this booking are as follows:', 'woocommerce-bookings' ), $booking->get_order()->billing_first_name . ' ' . $booking->get_order()->billing_last_name ); ?></p>
<?php endif; ?>

<table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">
    <tbody>
        <tr>
            <th scope="row" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Booked Product', 'woocommerce-bookings' ); ?></th>
            <td style="text-align:left; border: 1px solid #eee;"><?php echo $booking->get_product()->get_title(); ?></td>
        </tr>
        <tr>
            <th style="text-align:left; border: 1px solid #eee;" scope="row"><?php _e( 'Booking ID', 'woocommerce-bookings' ); ?></th>
            <td style="text-align:left; border: 1px solid #eee;"><?php echo $booking->get_id(); ?></td>
        </tr>
        <?php if ( $booking->has_resources() && ( $resource = $booking->get_resource() ) ) : ?>
            <tr>
                <th style="text-align:left; border: 1px solid #eee;" scope="row"><?php _e( 'Booking Type', 'woocommerce-bookings' ); ?></th>
                <td style="text-align:left; border: 1px solid #eee;"><?php echo $resource->post_title; ?></td>
            </tr>
        <?php endif; ?>
        <tr>
            <th style="text-align:left; border: 1px solid #eee;" scope="row"><?php _e( 'Booking Start Date', 'woocommerce-bookings' ); ?></th>
            <td style="text-align:left; border: 1px solid #eee;"><?php echo $booking->get_start_date(); ?></td>
        </tr>
        <tr>
            <th style="text-align:left; border: 1px solid #eee;" scope="row"><?php _e( 'Booking End Date', 'woocommerce-bookings' ); ?></th>
            <td style="text-align:left; border: 1px solid #eee;"><?php echo $booking->get_end_date(); ?></td>
        </tr>
        <?php if ( $booking->has_persons() ) : ?>
            <?php
                foreach ( $booking->get_persons() as $id => $qty ) :
                    if ( 0 === $qty ) {
                        continue;
                    }

                    $person_type = ( 0 < $id ) ? get_the_title( $id ) : __( 'Person(s)', 'woocommerce-bookings' );
            ?>
                <tr>
                    <th style="text-align:left; border: 1px solid #eee;" scope="row"><?php echo $person_type; ?></th>
                    <td style="text-align:left; border: 1px solid #eee;"><?php echo $qty; ?></td>
                </tr>
            <?php endforeach; ?>
        <?php endif; ?>
    </tbody>
</table>

<?php if ( wc_booking_order_requires_confirmation( $booking->get_order() ) ) : ?>
<p><?php _e( 'This booking has awaiting for your approval. Please check it and inform the customer if the date is available or not.', 'woocommerce-bookings' ); ?></p>
<?php endif; ?>

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

回答 1

Stack Overflow用户

发布于 2014-10-12 01:19:47

试试这个--它会从你的名字所在的预订地址中提取电子邮件地址。

您可能希望使用printf,但这是我用来将此信息发送到Google Calendars的方法

代码语言:javascript
复制
$description .= sprintf( __( 'NAME: %s', 'woocommerce-bookings' ), $booking->get_order()->billing_first_name ) . PHP_EOL;
$description .= sprintf( __('EMAIL: %s', 'woocommerce-bookings'), $booking->get_order()->billing_email ) . PHP_EOL;
$description .= sprintf( __('PHONE: %s', 'woocommerce-bookings'), $booking->get_order()->billing_phone ) . PHP_EOL;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24885869

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档