【发布时间】:2020-11-22 20:59:33
【问题描述】:
Woocommerce 提供了向电子邮件主题添加占位符的选项。我想通过创建一个自定义占位符来扩展该功能,该占位符从 woocommerce 重力形式产品插件和 woocommerce 预订中提取信息。
我已经尝试Create additional variables/placeholders for Woocommerce email notifications subject 代码进行一些更改,看看我是否可以让它工作。另外,我尝试获取 woocommerce 元字段,但也没有用。
在此代码上,我无法获得与订单相关的预订:
// For woocommerce versions up to 3.2
add_filter( 'woocommerce_email_format_string' , 'filter_email_format_string', 20, 2 );
function filter_email_format_string( $string, $email ) {
// Get the instance of the WC_Order object
$booking = $get_order;
// Additional wanted placeholders in the array (find / replace pairs)
$additional_placeholders = array(
'{custom_one}' => $booking->get_start_date(),
);
// return the clean string with new replacements
return str_replace( array_keys( $additional_placeholders ), array_values( $additional_placeholders ), $string );
}
【问题讨论】:
-
这里的 $get_order 是什么?例如,请显示 $get_order 的 var_dump
标签: php sql wordpress woocommerce woocommerce-bookings