Recently a client needed a 25% discount on their WooCommerce website. Pretty simple to do; either by manually updating each product or using a bulk editor.
A month later the same client wanted the discount to be removed and the regular price set to reflect the same 25% reduced price. Also, quite easy to do, but afterwards some of the prices seemed to be incorrect (they weren’t), but I thought I made a mistake using the bulk editor, so I wanted to check that before restoring the database.
This might seem like an elementary math problem, but for some reason I could not figure this out on a Friday afternoon. Just increasing the price with 25% was wrong, but I had a brain freeze how to do this. After some Googling and reading complicated math formulas, I finally asked ChatGPT to explain it to me.
Me: how do I add 25% back to a price after subtracting it?
To add 25% back to a price after subtracting it, you can follow these steps:
- Subtract the 25% from the original price: original price – 0.25 * original price = 0.75 * original price
- This result will be the amount that is left after subtracting 25% from the original price.
- To add the 25% back to the original price, you can simply divide the amount obtained in step 2 by 0.75:(0.75 * original price) / 0.75 = original price
Therefore, the final formula to add 25% back to a price after subtracting it would be:
original price = (price after subtracting 25%) / 0.75
For example, if the original price was $100, then the price after subtracting 25% would be:
$100 – 0.25 * $100 = $75
To add the 25% back to $75, you can use the formula:
original price = $75 / 0.75 = $100
So, the original price of $100 has been restored.
What a perfect explanation! Just divide the new updated price with the inverse of the fraction, in this case 0.75.
I love how it breaks it down and then provides a remarkably simple example. Finally, I understand this completely and it will be a breeze doing this in future.