1 回答

TA貢獻1801條經驗 獲得超16個贊
更新- 而不是覆蓋 Woocommerce 模板,總是首先嘗試使用可用的鉤子,例如:
add_action( 'woocommerce_order_item_meta_start', 'add_download_links_to_thank_you_page', 10, 3 );
function add_download_links_to_thank_you_page( $item_id, $item, $order ) {
// Set below your product attribute taxonomy (always starts with "pa_")
$taxonomy = 'pa_location';
// On email notifications
if ( ! is_wc_endpoint_url() && $item->is_type('line_item') ) {
$product = $item->get_product();
$label_name = get_taxonomy( $taxonomy )->labels->singular_name;
if ( $term_names = $product->get_attribute( $taxonomy ) ) {
echo '<br/><small>' . $label_name . ': ' . nl2br( $term_names ) . '</small>';
}
}
}
代碼位于活動子主題(或活動主題)的 functions.php 文件中。測試和工作。
您也可以使用woocommerce_order_item_meta_end
鉤子代替。
- 1 回答
- 0 關注
- 141 瀏覽
添加回答
舉報