2017-05-07 31 views
0

我已经重写了woo-commerce customer-completed-order.php模板在WordPress的子主题中。尽管如果订单已创建,则不会发送电子邮件。覆盖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 

如何解决?

+1

你到目前为止检查了什么问题? – Reigel

回答

0

首先,我启用了PHP错误通过添加以下行的wp-config.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 Fatal error: Uncaught Error: Call to a member function get_items() on boolean

所以删除线$order = wc_get_order($order_id); // optional (to test without it)

解决了问题