Multiple Related Product Loops Based On Stock Status – WooCommerce



This downloadable product includes 3 custom product loops which display based on the stock status of the current single product.

  • If the single product is Out of Stock ( OOS ), Loop 1 displays before the product and Loop 2 & Loop 3 display after the product.
  • If the single product is In Stock, Loop 2 & Loop 3 display after the product.
  • Both Loop 1 & Loop 2 display related products by category however you can easily change this to tag.
  • Loop 3 displays products by brand regardless of category. Code is included to create a brand using the taxonomy slug yith_product_brand
  • All loops only display in stock ( IS ) products.
  • All loops compare product IDS and remove duplicate products.

By default, Loop 1 displays 4 products, Loop 2, 16 products and Loop 3, 8 products.

You can easily position any loop using one of the single product page hooks

What’s Included

  • 1 year code updates
  • Free installation & setup for absolute beginners
  • Code guarantee or your money back


There’s only 1 step :

Copy & paste the PHP code ( excluding the opening PHP tag ) from the functions.php file to the end of your child themes functions file or custom functionality plugin.

* If you already use a plugin or code to add taxonomy terms & term meta, only copy the code starting from line 83 in functions.php.

Note : Make sure you go to WooCommerce > Status > Tools to clear transients. Also clear all types of caching once you have installed the code or made changes.

These solutions may also help :