WooCommerce stores with large inventory often decide to hide out of stock products from the website. As you all know, there is a WooCommerce setting for that, right under Settings > Products > Inventory called “Out of stock visibility“. With the tick of a checkbox you can toggle the visibility of products that ran out of stock and immediately return a clean shop page with no unpurchasable items.
The story is, it could be you may want to still show out of stock items on a specific page via a custom shortcode, or limit the out of stock visibility setting only to certain categories.
Well, today we will learn a cool WordPress hook called “pre_option_option“, that basically allows us to override whatever settings we have in the WordPress admin, and assign our own value on a specific page or condition. Enjoy!