在WooCommerce中,我想在单个产品页面的摘要中显示产品元数据中的产品尺寸。可能吗?
任何曲目都表示赞赏。
编辑 - 更多细节:
以下钩子函数将在产品单页的产品简短描述下显示格式化的产品尺寸(仅限):
add_action( 'woocommerce_single_product_summary', 'display_product_formated_dimensions_table', 25 );
function display_product_formated_dimensions_table(){
global $product;
if ( $product->has_dimensions() ) {
echo '<table class="shop_attributes"><tr>
<th>' . __( 'Dimensions', 'woocommerce' ) . '</th>
<td class="product_dimensions">' . esc_html( wc_format_dimensions( $product->get_dimensions( false ) ) ) . '</td>
</tr></table>';
}
}
代码位于活动子主题(或活动主题)的function.php文件中。经过测试和工作。