I'm trying to sort a query of product custom post type, ordering by the product weight (ASC - from lightest to heaviest). The product weight is entered in a Advanced Custom Fields "field" on the product edit screen.
The query is working fine, except for when the number contains a comma (ex 1,000). It will put a product with a weight of 1,000 at the top of the list (first). So is somehow not looking at the number past the comma, so views it as 1, not 1,000.
Fortunately, I was able to convince my client to leave out the commas and are using the php number_format() to display the comma on the front end.
However, I don't like relying on my client to remember to exclude the comma for the sorting to work correctly.
Is there a way to have WP Query properly sort number values with commas in them? Maybe with an action or filter to remove the comma before saving in the DB and then adding it back once it's displayed in a template file? I really don't have much experience with actions and filters in WordPress yet.
Thanks in advance.