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 关注
- 126 浏览
添加回答
举报