How to get product order by two custom taxonomy in wordpress

WordPress is notoriously against ordering by terms. Of course it’s precisely what people need to accomplish in practice. And precisely a mess with a very clunky database representation of them (which is planned to be slowly improved over several releases to be fair).

In a nutshell the issues with your query are:

  • it’s preferable to work with WP_Query, even if you are considerably customizing SQL
  • you are missing the whole third wp_term_taxonomy table 🙂

While I don’t think there is any truly canonical way to do it, the most reliable approach I had seen and used is covered in Sortable Taxonomy Columns post.