'Woocommerce - Save and display product previous sales prices

In our country,under the new law, the display of discounted product prices will change. We have to display: Regular Price Sales Price Lowest sales price in the last 30 days. And the % discount should be calculated with a new logic. e.g. if in the last 30 days there was a 20% discount from the regular price, and later we give a 25% percent, the appeared % discount wouldnt be 25%, that would be only 5% (because this is the difference between new and past sales prices) Could you give me an idea how could we do this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source