问题描述
在单个产品页面中,我想使用Woocommerce挂钩(删除其他信息"标签),从标签的添加到购物车"按钮下更改其他信息"的位置.
In single product pages, I would like to change the location of "additional information" from tabs, under add to cart button using Woocommerce hooks (removing the "additional information" tab).
我有:
add_action( 'woocommerce_product_additional_information', 'wc_display_product_attributes', 10 );
和: woocommerce_after_add_to_cart_button
我正在尝试:
remove_action( 'woocommerce_product_additional_information', 'wc_display_product_attributes', 10 );
add_action( 'woocommerce_after_add_to_cart_button', 'woocommerce_product_additional_information' );
和
remove_action( 'woocommerce_product_additional_information', 'wc_display_product_attributes', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_product_additional_information', 60 );
但这不起作用.
如何正确移动下方添加到购物车"按钮中的其他信息"?
How can I move properly "additional information" below add to cart button?
推荐答案
以下代码将删除其他信息"标签,并在添加到购物车"下方添加其他信息:
The following code will remove additional information tab and add additional information below add to cart:
// Remove additional information tab
add_filter( 'woocommerce_product_tabs', 'remove_additional_information_tab', 100, 1 );
function remove_additional_information_tab( $tabs ) {
unset($tabs['additional_information']);
return $tabs;
}
// Add "additional information" after add to cart
add_action( 'woocommerce_single_product_summary', 'additional_info_under_add_to_cart', 35 );
function additional_info_under_add_to_cart() {
global $product;
if ( $product && ( $product->has_attributes() || apply_filters( 'wc_product_enable_dimensions_display', $product->has_weight() || $product->has_dimensions() ) ) ) {
wc_display_product_attributes( $product );
}
}
代码进入您的活动子主题(或活动主题)的function.php文件中.经过测试,可以正常工作.
Code goes in function.php file of your active child theme (or active theme). Tested and works.
这篇关于从WooCommerce中“添加到购物车"按钮下的产品选项卡中移动其他信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!