在 WooCommerce 3.6 中向单个产品添加行附加信息 table
Add rows to Single product Additional information table in WooCommerce 3.6
我正在尝试向单一产品附加信息添加一行 table。
实际上有什么钩子或过滤器可以做到这一点吗?我已经搜索了钩子,但找不到解决方案。
感谢任何帮助。
自从 WooCommerce 3.6 版,您可以使用 woocommerce_display_product_attributes
过滤器钩子以这种简单的方式添加自定义 label/value 对 "Additional Information" table (制表符):
add_filter( 'woocommerce_display_product_attributes', 'custom_product_additional_information', 10, 2 );
function custom_product_additional_information( $product_attributes, $product ) {
// First row
$product_attributes[ 'attribute_' . 'custom-one' ] = array(
'label' => __('Label One'),
'value' => __('Value 1'),
);
// Second row
$product_attributes[ 'attribute_' . 'custom-two' ] = array(
'label' => __('Label Two'),
'value' => __('Value 2'),
);
return $product_attributes;
}
代码进入您的活动子主题(或活动主题)的 functions.php 文件。测试和工作。
我正在尝试向单一产品附加信息添加一行 table。
实际上有什么钩子或过滤器可以做到这一点吗?我已经搜索了钩子,但找不到解决方案。
感谢任何帮助。
自从 WooCommerce 3.6 版,您可以使用 woocommerce_display_product_attributes
过滤器钩子以这种简单的方式添加自定义 label/value 对 "Additional Information" table (制表符):
add_filter( 'woocommerce_display_product_attributes', 'custom_product_additional_information', 10, 2 );
function custom_product_additional_information( $product_attributes, $product ) {
// First row
$product_attributes[ 'attribute_' . 'custom-one' ] = array(
'label' => __('Label One'),
'value' => __('Value 1'),
);
// Second row
$product_attributes[ 'attribute_' . 'custom-two' ] = array(
'label' => __('Label Two'),
'value' => __('Value 2'),
);
return $product_attributes;
}
代码进入您的活动子主题(或活动主题)的 functions.php 文件。测试和工作。