我已经在Wordpress的子主题中覆盖了woo-commerce customer-completed-order.php 模板。虽然订单已创建,但不会发送电子邮件。
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$order = wc_get_order( $order_id ); // optional (to test without it)
foreach ($order->get_items() as $item_id => $item) {
$product_name = $item['name']; // product name
}
/**
* @hooked WC_Emails::email_header() Output the email header
*/
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<p><?php printf( __( "Hi there. Your recent order on %s has been completed.", 'woocommerce' ), $product_name ); ?></p>
<?php
如何解决?
答案 0 :(得分:0)
首先,我通过将以下行添加到 wp-config.php 来启用php错误记录:
// log php errors
@ini_set('log_errors','On'); // enable or disable php error logging (use 'On' or 'Off')
@ini_set('display_errors','Off'); // enable or disable public display of errors (use 'On' or 'Off')
@ini_set('error_log','php-errors.log'); // path to server-writable log file
php_errors.log中有错误:
PHP致命错误:未捕获错误:调用成员函数 boolean
上的get_items()
删除行$order = wc_get_order( $order_id ); // optional (to test without it)
解决了问题