woocommerce 循环中的第一项仍然显示元素
我正在尝试删除 Woocommerce“添加到购物车”按钮以及特定产品类别的产品价格 - 我必须开始工作......几乎!
循环中的第一项仍然显示产品价格,请参见屏幕截图。
我不太确定为什么?也许我的钩子不太对?
这是我的代码:
//REMOVE ADD TO CART AND PRICE
//removes add to cart buttons and product price on product of 'muslin' category
add_action('woocommerce_after_shop_loop_item_title', 'remove_product_description_add_cart_button' );
function remove_product_description_add_cart_button() {
$categories = array('muslins');
if ( has_term( $categories, 'product_cat', get_the_id() ) ) {
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price',10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart',10);
}
}
Im trying to remove Woocommerce 'add to cart' button and the product price on a specific product category - which ive got to work... ALMOST!
The first item in the loop is still showing the product price, see screenshot.
im not really sure why? Perhaps my hook aren't quite right?
here is my code:
//REMOVE ADD TO CART AND PRICE
//removes add to cart buttons and product price on product of 'muslin' category
add_action('woocommerce_after_shop_loop_item_title', 'remove_product_description_add_cart_button' );
function remove_product_description_add_cart_button() {
$categories = array('muslins');
if ( has_term( $categories, 'product_cat', get_the_id() ) ) {
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price',10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart',10);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论