I currently have two types of product, one being full-priced (in a collection called ‘non-member’) and a cloned version which is discounted for subscribers (in a collection called ‘BSM’).
I need to know if there is a way to remove all the subscriber products (BSM) from the results, so that only ‘non-member’ products appear, rather than pulling through all products.
import wixData from 'wix-data';
$w.onReady(function () {
// Write your JavaScript here
// To select an element by ID use: $w("#elementID")
// Click "Preview" to run your code
});
export function dataset2_ready() {
$w("#repeater1").onItemReady( ($item, itemData, index) => {
$item("#price").text = itemData.price + ' ' + itemData.currency;
});
}
let lastFilterName;
let lastFilterPrice;
let debounceTimer;
function filter(name) {
if (lastFilterName !== name) {
let newFilter = wixData.filter();
if(name)
newFilter = newFilter.contains('name', name);
$w("#dataset2").setFilter(newFilter);
lastFilterName = name;
}
}
export function searchBar_keyPress(event) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w("#searchBar").value, lastFilterPrice);
}, 100);
}
Hey Shan, thanks for your reply. I think I used your tutorial video as a starting point (I recognise the name Dude Lemon), so thank you! I have tried to add this as a filter, but I am a noob (first time using Corvid) and I’m still stuck. I have added the code where I thought it should be and changed the collectionField and COLLECTION_ID but it’s not working. Please can you point me in the right direction?
import wixData from 'wix-data';
$w.onReady(function () {
// Write your JavaScript here
// To select an element by ID use: $w("#elementID")
// Click "Preview" to run your code
});
export function dataset2_ready() {
$w("#repeater1").onItemReady( ($item, itemData, index) => {
$item("#price").text = itemData.price + ' ' + itemData.currency;
});
}
let lastFilterName;
let lastFilterPrice;
let debounceTimer;
function filter(name) {
if (lastFilterName !== name) {
let newFilter = wixData.filter();
if(name)
newFilter = newFilter.contains('name', name);
$w("#dataset2").setFilter(newFilter);
lastFilterName = name;
$w("#dataset2").setFilter(newFilter.and(newFilter.eq("collections", "#Non-member")));
}
}
export function searchBar_keyPress(event) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w("#searchBar").value, lastFilterPrice);
}, 100);
}
@oscar The code I wrote should work on a normal database field (text, numerical, etc) but I think the ‘collections’ field is a reference/multi-reference field so you might have to use .hasSome