Okay I figured it out!
After doing some digging, I found that there are restrictions on querying the “collections” field in “Stores/Products”. The basic idea is that you can only search for the collections if you know the _id field.
I have tested the below code on my site and it returns the correct number for each collection. Replace your current function with the async function below.
async function getFrozenCounts() {
var frozenCollection = (
await wixData.query('Stores/Collections')
// Get the collection from the Wix Collections database
.eq("name", "Frozen")
.find()
).items[0]
wixData.query("Stores/Products") // Wix Stores database
.include("collections")
.hasSome("collections", frozenCollection._id)
.count()
.then((num) => {
let count = num;
if (num > 0) {
// If there ARE frozen dishes
$w("#frozenNumber").text = "There are " + count + " frozen dishes available to order";
console.log("Number of Items = " + count)
} else {
// If there are NO frozen dishes
$w("#frozenNumber").text = noFrozenText;
console.log("None = " + count)
}
})
}
You can also read more here if you’d like: