1

I've this problem. Let me show pictures so I can explain better.

Variation product selected but because all the variations have the same price the price do not show in the bottom: Variation product selected but because all the variations have the same price the price do not show in the bottom.

Variation product selected, because they have different PROMO prices they show on top and the regular-promo price after selection: Variation product selected, because they have different PROMO prices they show on top and the regular-promo price after selection

What I need is that only after selected the variations the price is show in the bottom like the second image and calculation the discount between the promo variation price and the regular variation price. I need the same behavior in the two cases.

I've searched a lot, but none of the things have solved this behavior. Here some answer that are very close:

0

1 Answer 1

1

After some search, there this simple dedicated filter hook woocommerce_show_variation_price that will make exactly what you are expecting:

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;
}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

Tested and work… This will display the selected variation price even if all variations prices are the same…

3
  • Hello. Im very sorry for the delay in reporting about your help, i got a almost deadly flu. So, its not working. How can i debug to see whats its going on? And how about the discount percentage calculation only in the price after the variation is selected?
    – zeYuri
    Nov 27, 2017 at 19:24
  • @zeYuri Happy comme back to life!… Here you are asking 2 questions in One… Kindly this is not the way on StackOverFlow. So for now my code displays the selected variation price even if all prices are the same for all variations (the 'woocommerce_show_variation_price' hook is dedicated to that in WooCommerce). For the discount percentage, that should be another question that you will ask on a new question and I will answer to it with pleasure. If the code doesn't work for you, I can't tell… For me it works as I always test my code before. Nov 27, 2017 at 19:44
  • oh, got it. Yes this is working very nicely. thanks. i've made the other question. here stackoverflow.com/questions/47530715/…
    – zeYuri
    Nov 28, 2017 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.