I have some product categories which I don't to show the price to the user. Successfully hide the price from the product pages and also from the cart page but the price still showing in the cart icon when the user hovers over the icon and a dropdown list appear of the products that are in the cart.
Anyone know how to fix this? Any help will be appreciated.This is the code that I am using to hide the price for the specific category.
add_filter('woocommerce_cart_item_price', 'hide_woocommerce_cart_item_price', 10, 3);
add_filter('woocommerce_cart_item_subtotal', 'hide_woocommerce_cart_item_price', 10, 3);
function hide_woocommerce_cart_item_price( $price, $cart_item, $cart_item_key ) {
$product = wc_get_product($cart_item['product_id']);
$hide_for_categories = array( 'berkley','cotton-lite','kinna','linen','luster','nairobi','panama','plisse','prints','sequoia','shantung','brocade','boucle','dover','lite-out','lite-out-duplex','moire','sheerweave-blackout','sutton','texas-green','windsor','sheer','sheerweave-3-5-10','sheerweave-specialty');
// Don't show price when its in one of the categories
if ( has_term( $hide_for_categories, 'product_cat', $product->get_id() ) ) {
return '';
}
return $price;
}