Create two sorting options in bricks for meta value _price to sort by price low to high and high to low.
but clearly some sort of issue,
Running on localwp instance on desktop.
Create two sorting options in bricks for meta value _price to sort by price low to high and high to low.
but clearly some sort of issue,
Running on localwp instance on desktop.
Hi,
thank you for your report. I’ve tested this on my install, but I can’t reproduce this bug. I’m also using local WP.
It seems that the Product B is sorted wrongly. What happens if you add another product, is sorted correctly?
Best regards,
M
Looks like you are sorting on a key that doesn’t exist. What happens if you change _price to max_price?
_price
and _regular_price
are the meta keys used by woocommerce, there is no max price meta key, just showing the database as an example of the price data, I assume it’s stored there if not elsewhere?
{Edit: nvm the price is stored in post_meta}
Hi,
just to test this out. Can you remove the “Order by” from the query?
Also, if you switch to Storefront theme, is sorting working ok?
Thanks,
M
Not sure what you mean by storefront theme?
The query look in the examples in the pictures is a custom loop,
If i used the order by filter from the built-in products
element, then sorting works as expected
and even just using the sort from the build in products element whilst the custom query loop is still on there on the page, it also sorts the custom query loop correctly.
But I do not want to use the built-in products grid, I have less control and cant use something like the range filter with it.
I’m guessing if Meta numeric value is not used, it sees it as a string and string sorting numbers goes wack for example, with 900 being seen as larger than 1500.
Yep,
that was my guess, and I wanted just to confirm it, that’s why I asked if you can test removing “Order by” in your query.
Anyway, I’m happy that it works now. I’ll mark this topic as a NO BUG and I’ve marked your message as a solution.
Best regards,
Matej
Should probably make that clarification in the docs about using meta numeric values if sorting numbers. I don’t see any mention of this technicality in Query Sort, Filter & Live Search – Bricks Academy (bricksbuilder.io)
Hi.
Yeah, maybe we should.
In the meantime, there is a official WordPress documentation about those parameters : WP_Query – Class | Developer.WordPress.org
Matej
Not everyone who is using bricks is going to be that technically inclined to have the foresight to look in the wordpress docs about such a specific thing, even though sorting is a defacto standard of a products page. I do a bit of programming myself and even I did not think of this initially.
Yep, I agree with you. Once we redo our Academy, we should include more examples and explanations, just to minimize “issues” like this.
Thanks for your opinion
Matej