Say a total of x=700 items of a product are in stock, and the product has 6 variations. Out of these variations amount of d=1 is out of stock.
I’d like to efficiently get and display, say 12, products that have the highest z=x/(1+d) value, from select product categories with limited amount of products from the same category. Number of total variations per product may vary, and I’d like to update the listing once in a week.
I’d appreciate any help! I personally have some experience in coding, but PHP and WooCommerce queries are new to me.