Fallback for no products in a product set

Topic summary

Using buybutton JS (Shopify’s Buy Button JavaScript library) to render product sets from collections; rendering works when products exist but an empty collection triggers a JavaScript “Not Found” error.

Wants to suppress the error and display a fallback div message: “{collection name} products not available at this time” when no products are present.

Requests guidance on how to hook into the API to detect an empty collection and conditionally render a fallback template instead of erroring.

Mentions extensive searching without finding a solution.

No responses, decisions, or workarounds are provided; the question remains open with the key need being a method to check for zero products before rendering.

Summarized with AI on February 23. AI used: gpt-5.

I’m using the buybutton JS. I’ve got product sets rendering just fine when their are products in a collection. However, when a collection is empty, I’m getting a JS ‘Not Found’ error. How can I suppress that error, and just display a div with something along the lines of “collection name products not available at this time” message if no products are in a collection.

I’ve Googled, til I could Google no more looking for a way to handle that situation.

How can I hook into the API to check if no products are available, and if no products then display this fallback template?

Thanks in advance!