【发布时间】:2017-02-24 10:08:57
【问题描述】:
我在这里搜索过,一些帖子帮助我几乎解决了这个问题:
我的包裹公司在订单中添加了订单备注,其中包括包裹的文本和跟踪网址。然后他们将订单完成。
此 URL 需要添加到给客户的订单完成邮件中。
此代码有效,但前提是我手动发送订单完成邮件:
add_action( 'woocommerce_email_before_order_table', 'woo_add_order_notes_to_email' );
function woo_add_order_notes_to_email() {
global $woocommerce, $post;
$args = array(
'post_id' => $post->ID,
'status' => 'approve',
'type' => 'order_note'
);
$notes = get_comments( $args );
if ( $notes ) {
foreach( $notes as $note ) {
$notecontent = $note->comment_content;
if( preg_match('/[a-zA-Z]+:\/\/[0-9a-zA-Z;.\/?:@=_#&%~,+$-]+/', $notecontent, $matches) != 0 ) {
echo '<p>You can follow your order via this link: <a href = "' . $matches[0] . '">' . $matches[0] . '</a></p>';
}
}
}
}
希望大家能帮帮我。
【问题讨论】:
标签: php wordpress email woocommerce