I am completely at a loss on how to get some 'relatively' simple data from my woocommerce orders.
What I need is a query that allows me to simply plug in a category as well as a tag and return the total sales (as income [$]) so that I can do some simple math with the results and display the amount.
I am trying to have a storefront on my studios website that is broken down into categories by project "Webcomic", "Game", Etc. and then filter the sales of ANY of the product sales within the category by the tag "contribution" or "sales".
The purpose for this is to have a very rudimentary metric display on a project page which breaks down what I've invested in the project in time and money, and what I've earned from it in patronage and merch sales.
The idea being that I go:
- Query: What are the total earnings of "$project" in "contributions"?
- Query 2: What are the total earnings of "$project" in "sales"?
- Display: "$project" has earned X in contributions and Y in sales. Totaling Z.
If not tags and categories, how would I go about giving my products custom fields that I'd be able to query through the orders?
Any help in this regard would be immensely helpful.
Added through further study:
This question asks WHERE the order data is being stored.
How would I go about querying the different chunks of data to trace a line to all the chunks I need?
Query shop_orders > Loop through Orders > push orders who's order_item has the right category and tags to an array
Is my initial thought. Would there be a more efficient way to do this?