我在产品中创建了一个名为课程日期的自定义字段。我认为它是一个日期,例如1月30日。这是我在电子邮件中没有任何显示..我错过了什么?代码与新代码片段编辑下面以新订单显示自定义产品字段电子邮件
<?php
/**
* Customer processing order email
*
* @author WooThemes
* @package WooCommerce/Templates/Emails
* @version 2.4.0
*/
if (! defined('ABSPATH')) {
exit; // Exit if accessed directly
}
?>
<?php
$items = $order->get_items();
foreach ($items as $item) {
$product_name = $item['name'];
$product_id = $item['product_id'];
$product_variation_id = $item['variation_id'];
$course_date=get_post_meta($product_id, 'course-date', true);
//Note $course_date will get overwritten if there are more than one items in the order.
}
?>
<?php do_action('woocommerce_email_header', $email_heading); ?>
<p>This email is to notify you of your recent registration for the <b>Level 1 - Think and Grow Rich Institute Course</b>!</p>
<p>You are registered to attend on:</p>
<p><?php printf(__('<b>Registration ID:</b> %s', 'woocommerce'), $order->get_order_number()); ?></p>
<p><b>Course Registration Date:</b> <?php echo get_post_meta($post->id, 'course-date', true); ?></p>
<p><b>Time:</b> 8am Registration - 9am Event Begins (<a href="http://allfansnomoney.com/thinkandgrowrich/tentative-schedule/" target="_blank">See Full Schedule</a>)</p>
<p><b>Location:</b> 240 Belfield Rd, Toronto, ON M9W 1H3</p>
<p>If you have any questions please contact us by e-mail: <a href="mailto:[email protected]">[email protected]</a>.</p>
<p>Sincerely,<BR/>
The Think and Grow Rich Institute Team</p><BR/>
<p><em><b>"Whatever The Mind Can Conceive and Believe, It Will Achieve."</b> - Napoleon Hill</em></p>
<?php do_action('woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text); ?>
<?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'); ?>
你如何定义'$ _product'?你如何将此代码添加到电子邮件?哪里?请编辑您的问题与额外的信息。 – helgatheviking
我已编辑并包含完整的电子邮件模板。通过定义$ _product,我假设我必须添加一个片段或东西到functions.php?对不起还在学习 –
我可以雇用你为我完成这件事吗?我无法弄清楚,我需要尽快完成,请让我知道。 –