Woocommerce Product Category Dropdown

Have some basic custom inventory pages outside WordPress for managing stock / cost of goods on a basic Woocomerce installation

Need to be able to select products by categories / parent categories

  • Products are in [posts]
  • Categories are in [term_taxonomy]
    • where [taxonomy] = ‘product_cat’
    • self linked table for parent / child categories
      • [parent] = [term_taxonomy_id]
  • Category names & slug are in [terms]
  • Category display order is in [termmeta] where [meta_key] = ‘order’
  • Posts are linked to categories via [term_relationships]
    • [posts].[id] = [term_relationships].[object_id]
    • [term_relationships].[term_taxonomy_id] = [term_taxonomy].[term_taxonomy_id]