
We’ve already studied how to display the number of sales for a given product ID via a shortcode – however that solution won’t work for a variation ID, because WooCommerce only counts the “parent product” sales.
We need a different workaround in this case. This will require we either query the orders that contain such variation ID, and then calculate the sum – or that we install a snippet on day 0 so that we can count variation sales from that moment onwards, without having to query and calculate anything.
We will study the latter, and then display the result via a shortcode, so that you can use it anywhere, even inside the variation description.
Enjoy!
Continue reading WooCommerce: Count Variation Sales (Shortcode)