Hello, i am trying to write a code for sorting searched results by price high to low…
For example, if customers searched for Bags, i want them to be able to sort these Bags by price … my code so far is
export function sortbyShop_change(event) {
if ($w(‘#dropdown1’).value === ‘high’)
$w(“#dataset1”).setSort(
wixData.sort()
.descending(“price”));
if
($w(‘#dropdown1’).value=== ‘low’)
$w(“#dataset1”).setSort(
wixData.sort()
.ascending(“price”));
if
($w(‘#dropdown1’).value=== ‘none’)
$w(“#dataset1”).setSort(
wixData.sort()
);
}
function sort(sortOrder) {
let sort = wixData.sort();
if (sortOrder === “high”) {
sort = sort.descending(“price”);
}
else {
sort = sort.ascending(“price”);
}
$w(“#dataset1”).setSort(sort);
}
let sortOrder = $w(‘#dropdown1’).value;
sort(sortOrder);
The code doesn’t work so far please someone adjust it for me. My coding skills are pretty limited