When the “Hide out of stock items from the catalog” option is enabled in WooCommerce settings, FiboSearch automatically inherits this setting. However, if you wish to hide products from the catalog while still displaying them in search results, you can override this behavior using the following snippet:
// Force FiboSearch to show out of stock products in the autocomplete. add_filter( 'dgwt/wcas/settings/load_value/key=exclude_out_of_stock', function ( $value ) { return 'off'; }, PHP_INT_MAX - 5 );
ⓘLearn how to add this snippet to your WordPress.
If you’re using FiboSearch Pro, rebuild the index in WooCommerce
> FiboSearch
> Indexer
after adding the code.
The code above will show out of stock products only in the autocomplete. To show them also on the search results page, use the following code together with the previous snippet:
// Show out of stock products on the search results page, // even if out of stock products are hidden from the catalog. add_filter( 'pre_option_woocommerce_hide_out_of_stock_items', function ( $hide ) { if ( is_search() ) { $hide = 'no'; } return $hide; } );
ⓘLearn how to add this snippet to your WordPress.