1 回答

TA貢獻(xiàn)1815條經(jīng)驗(yàn) 獲得超13個(gè)贊
以下將使用您的代碼實(shí)現(xiàn)訂單商品名稱下的訂單電子郵件通知顯示:
add_action( 'woocommerce_order_item_meta_start', 'add_estimated_delivery_time_to_emails', 10, 3 );
function add_estimated_delivery_time_to_emails( $item_id, $item, $order ) {
// On email notifications and for line items
if ( ! is_wc_endpoint_url() && $item->is_type('line_item') ) {
if( $plevertijd = get_field('plevertijd', $item->get_product_id() ) ) {
echo '<span class="product_melding_kleur"><i class="fa fa-truck"></i>Levertijd: <a href="/verzending-en-levertijd/" alt="Verzending en levertijd" >' . $plevertijd . '</a></span>';
} else {
$terms = get_the_terms( $item->get_product_id(), 'product_cat' );
if ( ! empty($terms) ) {
$term = array_pop( $terms );
if( $levertijd = get_field('levertijd', $term ) ) {
echo '<span class="product_melding_kleur"><i class="fa fa-truck"></i>Levertijd: <a href="/verzending-en-levertijd/" alt="Verzending en levertijd" >' . $levertijd . '</a></span>';
}
}
}
}
}
代碼進(jìn)入您的活動(dòng)子主題(或活動(dòng)主題)的 functions.php 文件。它應(yīng)該有效。
在前端訂單上顯示:
如果您希望它顯示在客戶訂單(前端)上,您可以從IF聲明中刪除以下內(nèi)容:! is_wc_endpoint_url() &&
您也可以改用woocommerce_order_item_meta_end掛鉤,以在產(chǎn)品變體的產(chǎn)品屬性之后顯示。
- 1 回答
- 0 關(guān)注
- 198 瀏覽
添加回答
舉報(bào)