覆盖客户已完成的订单.php不起作用



我已经覆盖了wordpress的儿童主题中的woo-commerce customer-comported-erder.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

如何修复它?

首先,我通过将以下行添加到 wp-config.php.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)

解决了问题

最新更新