问题描述
我想使用可以在WooCommerce中的订单过帐中创建但使用占位符的自定义字段。如您所知,在WooCommerce的电子邮件设置中,您可以在其中编辑电子邮件正文,内容为:
可选的电子邮件正文文本。您可以使用以下占位符:
{order_date}
,{order_number}
,{order_status}
,{billing_first_name}
,{billing_last_name}
,{billing_company}
,{blogname}
,{ {1}}
我想知道创建自己的占位符的方法。我之所以尝试这样做,主要是因为我想包括我的客户的运输跟踪号。
{site_title}
我已经使用过它并且可以使用,但是自定义字段已添加到“订单明细”的末尾,并且不需要添加任何占位符,但是我想将其与占位符关联,这样就可以在电子邮件的其他部分(例如标题,主题或正文)中使用它,例如,放在正文中:
您的跟踪号码是/**
* To use:
* 1. Add this snippet to your theme's functions.PHP file
* 2. Change the Meta key names in the snippet
* 3. Create a custom field in the order post - e.g. key = "Tracking Code" value = abcdefg
* 4. When next updating the status,or during any other event which emails
* the user,they will see this field in their email
*/
add_filter( 'woocommerce_email_order_Meta_keys','my_custom_order_Meta_keys' );
function my_custom_order_Meta_keys( $keys ) {
$keys[] = 'Tracking Code'; // This will look for a custom field called 'Tracking Code' and add it to emails
return $keys;
}
PD:我有Woocommerce插件“ WooCommerce管理员自定义订单字段”,它可以帮助
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)