将产品描述(内容)添加到WooCommerce客户处理订单电子邮件

时间:2015-12-17 作者:Dexi

我正在寻找一种将产品描述(内容)添加到WooCommerce客户处理订单电子邮件中的方法,因为它包含了客户记录所需的重要信息。

我想我需要在WooCommerce>Settings>Emails>Processing Order编辑模板,但是哪一行和哪一行?

有人有剪切粘贴代码吗?

<?php
/**
 * Customer processing order email
 *
 * @author      WooThemes
 * @package     WooCommerce/Templates/Emails
 * @version     2.4.0
 */

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

?>

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

<p><?php _e( "Your order has been received and is now being processed. Your order details are shown below for your reference:", \'woocommerce\' ); ?></p>

<?php do_action( \'woocommerce_email_before_order_table\', $order, $sent_to_admin, $plain_text ); ?>

<h2><?php printf( __( \'Order #%s\', \'woocommerce\' ), $order->get_order_number() ); ?></h2>

<table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: \'Helvetica Neue\', Helvetica, Roboto, Arial, sans-serif;" border="1">
    <thead>
        <tr>
            <th class="td" scope="col" style="text-align:left;"><?php _e( \'Product\', \'woocommerce\' ); ?></th>
            <th class="td" scope="col" style="text-align:left;"><?php _e( \'Quantity\', \'woocommerce\' ); ?></th>
            <th class="td" scope="col" style="text-align:left;"><?php _e( \'Price\', \'woocommerce\' ); ?></th>
        </tr>
    </thead>
    <tbody>
        <?php echo $order->email_order_items_table( $order->is_download_permitted(), true, $order->has_status( \'processing\' ) ); ?>
    </tbody>
    <tfoot>
        <?php
            if ( $totals = $order->get_order_item_totals() ) {
                $i = 0;
                foreach ( $totals as $total ) {
                    $i++;
                    ?><tr>
                        <th class="td" scope="row" colspan="2" style="text-align:left; <?php if ( $i == 1 ) echo \'border-top-width: 4px;\'; ?>"><?php echo $total[\'label\']; ?></th>
                        <td class="td" style="text-align:left; <?php if ( $i == 1 ) echo \'border-top-width: 4px;\'; ?>"><?php echo $total[\'value\']; ?></td>
                    </tr><?php
                }
            }
        ?>
    </tfoot>
</table>

<?php do_action( \'woocommerce_email_after_order_table\', $order, $sent_to_admin, $plain_text ); ?>

<?php do_action( \'woocommerce_email_order_meta\', $order, $sent_to_admin, $plain_text ); ?>

<?php do_action( \'woocommerce_email_customer_details\', $order, $sent_to_admin, $plain_text ); ?>

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

1 个回复
SO网友:ramesh

在函数中添加以下代码。当前主题的php文件

function render_product_description($item_id, $item, $order){
    $_product = $order->get_product_from_item( $item );
    echo "<br>" . $_product->post->post_content; 

}

add_action(\'woocommerce_order_item_meta_end\', \'render_product_description\',10,3);

相关推荐