Percentage discounts in WooCommerce

Mar 28, 2023 | Learning, WooCommerce


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:


  1. Subtract the 25% from the original price: original price – 0.25 * original price = 0.75 * original price
  2. This result will be the amount that is left after subtracting 25% from the original price.
  3. 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.

Thanks ChatGPT!

Related posts

Using AI to improve work

Using AI to improve work

Artificial intelligence (AI) is all the rage now, and we decided to give it a go with something practical. We do a lot of custom development using Custom Post Types and Custom Taxonomies. This would entail the writing of custom queries to display the correct...

read more

Why WordPress for your business makes sense

Are you a businessperson? Or are you planning to become one? Do you wish to open a WordPress website-based business online and make it grow? It takes you only one “Yes” out of three answers to conclude that you are in a right place, where I will be more than happy to...

read more

Pin It on Pinterest

Share This