[英]Woocommerce complete order and add info to email programmatically
I am trying to make an order Completed
manually and add tracking info to the email before it has been sent to the customer.我正在尝试手动Completed
订单,并在 email 发送给客户之前添加跟踪信息。 I added a note to the order successfully but note is not in the email.我在订单中成功添加了注释,但注释不在 email 中。 How I can add the tracking code to the email?如何将跟踪代码添加到 email?
Here is my code:这是我的代码:
if(!empty(wc_get_order($ord->orderId))){
$order = wc_get_order($ord->orderId);
if($ord->statusId == 2){ //completed
$order->add_order_note( 'Tracking Number:'.$ord->trackingNumber );
$order->update_status( 'completed', $ord->trackingNumber );
}
else if($ord->statusId == 3){
$order->update_status( 'cancelled' );
}
var_dump($order);
}
You can override emails default HTML template by copying /woocommerce/templates/
[+any file you would like to override] to your theme/child theme folder.您可以通过将/woocommerce/templates/
[+您想要覆盖的任何文件] 复制到您的主题/子主题文件夹来覆盖电子邮件默认 HTML 模板。 If you never overrode any woocommerce template in your theme - go here .如果您从未在您的主题中覆盖任何 woocommerce 模板 - go 这里。
The html generated for the completed
email is emails/customer-completed-order.php
file, add your code to include the tracking number or any text you would like.为completed
的 email 生成的 html 是emails/customer-completed-order.php
文件,添加您的代码以包含跟踪号或任何您想要的文本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.