Home › Forums › WoodMart support forum › Product price showing in search results › Reply To: Product price showing in search results
nathaliedxb
Hi Aizaz,
I created a staging site and changed the theme to Twenty-Twenty Two (WordPress default) as per your request, but I cannot even see a search feature on this theme to test what you are asking 🙁
Please see staging here using the default theme: https://woocommerce-627090-2841648.cloudwaysapps.com/
Basically, when we used to use the Rey theme (before changing to Woodmart) we encountered a similar issue whereby the product price for out-of-stock items was still showing in the search results. The theme developer provided us with this code:
add_filter( ‘woocommerce_get_price_html’, ‘bbloomer_hide_price_if_out_stock_frontend’, 9999, 2 );
function bbloomer_hide_price_if_out_stock_frontend( $price, $product ) {
if ( is_admin() && ! isset($_REQUEST[‘s’]) ) return $price; // BAIL IF BACKEND
if ( ! $product->is_in_stock() ) {
$price = apply_filters( ‘woocommerce_empty_price_html’, ”, $product );
}
return $price;
}
This code worked perfectly to stop the price showing for out-of-stock items in the search results, I tried to apply the same code but it didn’t work on woodmart, could you please help with this?
Thanks so much in advance!