Looper showing out of stock products

Hi,

Building a Woocommerce single product page using layout builder, and using loopers to generate related products using the following query string:

`product_cat={{dc:term:slug}}&post_type=product&posts_per_page=4&offset=0&ignore_sticky_posts=1&post__not_in%5B0%5D={{dc:post:id}}&orderby=rand`

The results don’t seem quite on track with the standard WC Related Products widget, but it’s close enough!

Main issue is that ‘out of stock’ products are also being returned. I can set a condition on repeated elements so that {{dc:woocommerce:product_price}} > 0 doesn’t return that individual (out of stock) product, but that reduces the total number of products displayed and hence messes the layout up. Can also set a condition for Product (is) is In Stock which also works :slight_smile: just figured checking the price would be easier in the query string for testing.

Can’t seem to get the query string to ignore out of stocks. Any insights most welcome…! Just adding &{{dc:woocommerce:product_price}}>0 to the query string is obviously not working!

Hi @noodles,

Thanks for reaching out.
You can’t remove the Out of Stock product through the Query String, you need to add the condition Product(s) is not In Stock in the looper as shown in the given screenshot.

Hope it helps.
Thanks

Thanks for the reply.

That’s how we had our conditions set up, and it wouldn’t retrieve product details correctly. Instead, it just left gaps where looper content would normally be. It’s like the looper consumer thought “I’ve had a word with the Provider, and I’m going to put a placeholder down for the product info to go into, but I’ll just check on the conditions before I do that. Whoa! Easy cowboy! This here condition says not to put anything in it! I’ll just be leaving the placeholder there and move on to the next one.”

Anyways, after talking it through with my dog, educated guesses and some searching around, the following worked on the Looper Provider:

product_cat={{dc:term:slug}}&post_type=product&posts_per_page=4&offset=1&ignore_sticky_posts=1&post__not_in%5B0%5D={{dc:post:id}}&orderby=rand&meta_query%5B0%5D%5Bkey%5D=_stock_status&meta_query%5B0%5D%5Bvalue%5D=instock

Hope that helps someone :smile:

Hi @noodles,

Glad that you are able to find the solution.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.