1 回答

TA貢獻1815條經驗 獲得超13個贊
以下將使用您的代碼實現訂單商品名稱下的訂單電子郵件通知顯示:
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>';
}
}
}
}
}
代碼進入您的活動子主題(或活動主題)的 functions.php 文件。它應該有效。
在前端訂單上顯示:
如果您希望它顯示在客戶訂單(前端)上,您可以從IF聲明中刪除以下內容:! is_wc_endpoint_url() &&
您也可以改用woocommerce_order_item_meta_end掛鉤,以在產品變體的產品屬性之后顯示。
- 1 回答
- 0 關注
- 196 瀏覽
添加回答
舉報