This download contains 3 loops which display products from the same brand as the single product. The product loops are added before the single product and after the single product based on the following conditions :
- If the single product is “Out of Stock” ( OOS ), Loop 1 displays products from the same brand before the OOS product.
- If the product is “In Stock” ( IS ), Loop 1 does NOT display before the IS product.
- Loop 2 displays after the single product regardless of whether the single product is in stock or out of stock.
The code removes the default related products loop and uses custom loops in order to remove duplicate products when using 2 loops on the same single product page.
The following gallery shows the loop added after the product on the single product page when the product is in stock when viewing the image on the left and 2 loops added on single products which are out of stock. One before the product and one after.
There’s only 1 step. Copy & paste the PHP code to the end of your child themes functions file or custom functionality plugin for code snippets.