为此,您需要重写类或创建自定义电子邮件类型,我可以给出一个简短提示,说明将在类中进行的修改,如果您不想在woocommerce更新中失去更改,您可以在子主题或插件中重写。
在里面/woocommerce/includes/emails/class-wc-email-customer-completed-order.php
第37行:
$this->placeholders = array(
\'{site_title}\' => $this->get_blogname(),
\'{order_date}\' => \'\',
\'{order_number}\' => \'\',
\'{order_name}\' => \'\',
);
我在这里补充道
{order_name}
,
然后在第86行
if ( is_a( $order, \'WC_Order\' ) ) {
$this->object = $order;
$this->recipient = $this->object->get_billing_email();
$this->placeholders[\'{order_date}\'] = wc_format_datetime( $this->object->get_date_created() );
$this->placeholders[\'{order_number}\'] = $this->object->get_order_number();
$this->placeholders[\'{order_name}\'] = $this->object->get_billing_first_name();
}
在这里,我将名字定义为
{order_name}
, 现在,您可以在woocommerce电子邮件设置中使用此占位符,网址为
/wp-admin/admin.php?page=wc-settings&tab=email§ion=wc_email_customer_processing_order