Skip to content
Advertisement

Display lowest variation price and discounted percentage in WooCommerce

Based on this post :

I’ve been trying to show everywhere on my website the lowest variation price with the associated discount %, for variable and non variable products.

Here is the current code that I am using:

JavaScript

If I only keep the second function, it works on every product but not on variable products, which show a price range on shop pages. If I add the first function, it shows instead of a price range the price of the lowest product variation, but without the discount % next to it.

I could add the % code of the second function to the first, but this is messy, is there a way to merge these functions so that I can have the discount % shown everywhere, and also next to the lowest variation when it’s a variable product?

Advertisement

Answer

This can be done changing a little bit the first function that will replace both hooked functions:

JavaScript

This code goes in function.php file of your active child theme (or theme).

Tested and works with your customizations made in your previous questions/answer.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement