Hi, my first post, so be kind. I’m developing a web site for my wife’s business (already fraught with risk). She cooks fresh vegan dishes for collection. New ones each week, any left over get frozen or given away (in theory, she launches soon). Using Wix stores, we have a three collections ‘Fresh’, ‘Frozen’ and ‘No Stock’. The latter is for dishes which were previously Fresh or Frozen but which are either out of stock or unsuitable for freezing.
On the shop page we show the Fresh collection in a gallery and then below, the Frozen collection in another gallery.
It is possible there could be no Frozen dishes left, so I want to be able to check whether the Frozen collection is empty (based on if any products are in the collection, not whether the products have non-zero quantity) and then push a message into a text field on the shop page, by the side of the ‘Frozen Meals’ title.
I’ve looked at similar code on the forum and modified this but I’m still getting a compile error. I’m new to JS though many moons ago did cut C, Fortran (yes really) and still play with VBA in Excel, so not completely daft.
Probably a very simple thing, but as we all know these are often the most frustrating…
The text field is ‘frozenNumber’
import wixData from ‘wix-data’ ;
let noFrozenText = “sorry, there are no frozen meals available currently” //initialize variable to display “sold out” text when inventory is 0
$w . onReady ( function () {
//TODO: write your page related code here…
getFrozenCounts ();
});
function getFrozenCounts () {
wixData . query ( “Stores/Frozen” ) //my store collection name
. count ()
. then ( ( num ) => {
let numberOfItems = num ;
if ( numberOfItems === 0 ) {
// no frozen dishes
$w ( “#frozenNumber” ). text = “There are " + num + " frozen dishes available to order” ;
} else {
$w ( “#frozenNumber” ). text = noFrozenText ;
} ;
} );
}
Thanks in advance, Ratty