'First Item in woocommerce Loop still showing element
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);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
