title: Sorting WooCommerce Products by Distance
body: <p>I am developing a WooCommerce multi vendor site and need to be able to sort the products by distance from the site visitor.</p>
  <ul>
  <li>I have latitude and longitude values stored against each product in the catalogue.</li>
  <li>I know the latitude and longitude of the visitor</li>
  <li>I know the formula to calculate the distance between the two</li>
  </ul>
  <p>My thought is to add an alias field to the products returned by WooCommerce, potentially using the woocommerce_product_query hook that contains the distance from the site visitor and then sorting on that alias field. I know how to do this in SQL, E.g. something along the lines of:</p>
  <p>SELECT *, {FORMULA FOR CALCULATING DISTANCE} AS distance FROM {TABLE} SORT BY distance;</p>
  <p>but I cannot figure out how to add this alias field to the returned fields using the hooks provided by WooCommerce.</p>
  <p>Has anyone had any experience in achieving this or something similar? Or perhaps I am approaching it from the wrong angle!</p>
  <p>If so any help would be greatly appreciated.</p>