Jonathon Posted May 3, 2015 Report Posted May 3, 2015 What I want to do: Sort products based on price. yes there can be multi prices per item but in my case the prices[0] for all products suites my needs for ordering. What I have tried function compareProducts($a, ${ return $a['pricing'][0]['price'] - $b['pricing'][0]['price'];}$packages = usort($packages, ' compareProducts'); But this is not chaning the order. Or can I change this in the Controler, with a order by statement as this would be the correct place to change this. Thanks Quote
0 Tyson Posted May 4, 2015 Report Posted May 4, 2015 Where are you trying to sort packages? Packages on the order form are shown within their package group. Packages within a package group can be sorted in the admin interface under [Packages] -> [Groups], clicking a package group table row, and clicking+dragging the package table rows around relative to each other. Sorting the packages by price may not be working because of your comparison function. It is best if the comparison function return an integer of 3 possible values: -1 ($a > $, 0 ($a == $, or 1 ($a < $ Quote
Question
Jonathon
What I want to do:
Sort products based on price. yes there can be multi prices per item but in my case the prices[0] for all products suites my needs for ordering.
What I have tried
function compareProducts($a, $
{
return $a['pricing'][0]['price'] - $b['pricing'][0]['price'];
}
$packages = usort($packages, ' compareProducts');
But this is not chaning the order. Or can I change this in the Controler, with a order by statement as this would be the correct place to change this.
Thanks
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.