Can’t get woocommerce_get_price_html to work [closed]

I think your are missing parameters (even if you’re not using those) as per its definition and always try to return into filters instead of echo the value. Try the following: add_filter( ‘woocommerce_get_price_html’, array( $this, ‘get_price_html’ ), 10, 2); public function get_price_html( $price_html, $product ) { return ‘<a href=”https://wordpress.stackexchange.com/questions/344716/my-price”>’ . $product->get_price() . ‘</a>’; }

How to target parent product category and its children using WooCommerce?

the WordPress function cat_is_ancestor_of() is made for WordPress categories, but not for WooCommerce product categories which is a custom taxonomy product_cat. For Custom taxonomies you can use WordPress term_is_ancestor_of() function like: term_is_ancestor_of( 19, get_queried_object_id(), ‘product_cat’ ) So in your code: if ( is_product_category( ‘foo-category’ ) || term_is_ancestor_of( 19, get_queried_object_id(), ‘product_cat’ ) ) { wc_get_template( ‘archive-foo.php’ … Read more