im currently trying to get the recently sold products in woocommerce. In the DB-table woocommerce_order_items i can see every purchased product, and what item_order_id
it has as well as what order_id
it belongs to. If I sort this table descending, i get the recently bought product, but i don’t have the product ID
in this table.
I need to loop out this information from the table, and acquire the product id based on the order_item_id
to show the products last sold on the site.
Is this possible with a normal loop? Or do i have to use WPDB? The thing is, in the end, you are supposed to be able to sort products by Latest added products, most sold products, and latest sold products. The two first things uses a normal loop, and it would be nice if i could use that aswell for getting the latest sold products.
Thanks!
I know this is an old question but I had a probem pretty similar. I ended up using this: