I am trying to retrieve products from the API and order by price but I am seeing some strange behavior.
An example result set of product prices in order:
$1.00
$10.00
$110.00
$2.00
$200.00
$2.50
It seems like its comparing these values as strings rather than floats (or something of the sorts). therefore 110.00 comes before 2.00
UPDATE:
Here is the url I am hitting (oauth info removed):
http://www.example.com/wc-api/v3/products?filter%5Bcategory%5D=all&filter%5Bclass%5D=all&filter%5Blimit%5D=6&filter%5Bmin_price%5D=0&filter%5Border%5D=ASC&filter%5Borderby%5D=meta_value&filter%5Borderby_meta_key%5D=_price&filter%5Bq%5D=&filter%5Btag%5D=all&page=1
and parameters in a more readable format:
filter[category]: all
filter[class]: all
filter[limit]: 6
filter[min_price]: 0
filter[order]: ASC
filter[orderby]: meta_value
filter[orderby_meta_key]: _price
filter[tag]: all
page: 1
The solution was to use
meta_value_num
for theorderBy
filter. This was poorly documented in WooCommerce and I have created an issue with them.