'Woocommerce Hide Price by Categories + is_product_category(), is_shop()

can you help me with the code below? I need to hide price for specific category but on shop and category pages, not on product detail or admin.

I need to add is_product_category() and is_shop() code but have no idea where exactly.

The Snippet is by jeroensormani.com

add_filter( 'woocommerce_get_price_html', function( $price, $product ) {
    if ( is_admin() ) return $price;

    // Hide for these category slugs / IDs
    $hide_for_categories = array( 'singles', 'albums' );

    // 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; // Return original price
}, 10, 2 );

add_filter( 'woocommerce_cart_item_price', '__return_false' );
add_filter( 'woocommerce_cart_item_subtotal', '__return_false' );


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source