I've this code below that shows the variation selected price after the user have selected the variation
add_filter( 'woocommerce_show_variation_price', 'filter_show_variation_price', 10, 3 );
function filter_show_variation_price( $condition, $product, $variation ){
if( $variation->get_price() === "" ) return false;
else return true;
}
I need to calculate the discount percentage between the promotional price that will show and the regular price. BUT ONLY after the variation is selected, not before (because i will remove the price from showing before via css).
I think this answer come close but not there yet.
All The code below will work for variable products only on single product pages.
The 2nd code from the linked answer that I have maid before, just works perfectly. I have maid some little changes to target only variable products.
I have added an additional hooked function that will remove the displayed price under the title for variable products only.
Here is all the needed code:
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
This code is tested and mostly works only for WooCommerce version 3+