how to get variation id on product page?
-
WC version: 2.5.2 (but will be upgrading to the latest soon)
I’m trying to display the sale end date next to the variation price on a product page. I can do it no problem on simple products. But on variation products, I can’t seem to get the variation ID of the price that is shown to get the date.
I’m trying to use:
add_filter( 'woocommerce_get_variation_price_html', 'custom_price_html', 2, 2 );
And then in my function I need to get the sale end date:
get_post_meta($variation_id, '_sale_price_dates_to', true)
But I can’t for the life of me figure out how to get the $variation_id.
Does anyone know how?
Thanks in advance!NOTE: i know you can loop through all variations from the parent ID, but in this case, the variation price HTML is already from a specific variation ID, so I’m assuming it’s possible to grab the ID that the price was generated from. If a loop has to be used, how would you make sure the ID pulled matches with the current price displayed?
- The topic ‘how to get variation id on product page?’ is closed to new replies.