I am constructing a mobile page for a store using a repeater instead of using the standard layouts from the Store app, as my client wants two columns of products on-screen on a phone…and the standard app layout defaults to one column on mobile.
I pull the data from the collection in code, and can display it fine. I then want to be able to add a filter for Collections, as referenced in the multi-ref field in Products.
I’ve read everything I can find to figure out how to do this in code but cannot figure out how to code it…the direction in the API docs just confuses me more.
What I have today is the following:
let allProducts = await wixData.query("Stores/Products").include("collections").find().then((results)=>{return results.items})
console.log(allProducts);
$w('#repeater1').data = allProducts;
$w('#repeater1').onItemReady(($item, data, index)=>{
$item("#productImage").src = data.mainMedia;
$item("#productTitle").text = data.name;
$item('#productPrice').text = "£"+data.price.toString();
if (data.discount.type!=="NONE"){
$item('#sale').show();
$item('#productPrice').text = "£"+data.discountedPrice.toString();
}
})
This sets the page up fine but how can I set up a filter from here, using the value from a dropdown menu?? I can grab the value fine, but what do I do with it to filter the data?
I really need some detailed coding guidance on how to re-filter allProducts by Collection…can anyone help??
Simon.