Javascript function string to sort product results to best sellers.

New Member
2 0 0

On our store (upon viewing this pae you may see a best sellers sorting tab, but that's actually not configured properly). We are trying to add in a best sellers tab to our sorting list, but the issue is the people who designed the theme made the sorting system reliant on GraphQL, rather than the standard sort_by functions. Thus, here's the tabs they provided in our theme.bundle.js file, and the functions behind the labels you see on the page:


case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var b=[{label:"Newest Arrival",sortFunction:function(e,t){return new Date(t.createdAt.replace(" ","T").split(" ")[0])-new Date(e.createdAt.replace(" ","T").split(" ")[0])}},{label:"A - Z",sortFunction:function(e,t){var n=e.title.toLowerCase(),r=t.title.toLowerCase();return n<r?-1:n>r?1:0}},{label:"Z - A",sortFunction:function(e,t){var n=e.title.toLowerCase(),r=t.title.toLowerCase();return n>r?-1:n<r?1:0}},{label:"Price Low to High",sortFunction:function(e,t){return e.prices.low-t.prices.low}},{label:"Price High to Low",sortFunction:function(e,t){return t.prices.high-e.prices.high}}]


I can't for the life of me figure out the function to call and sort out all top selling products within this same sortFunction structure, and if any of you could provide some assistance that would be super appreciated. 

Replies 0 (0)