What I need:
We are planning to start a campaign. We want to give a temporary 10% discount on every product we sell on our site for the next 30 days. We want to display both the regular price and the discounted price on all shop's pages.
- We have approximately 200,000 products.
- Our products don't have variations.
Requirements:
- All products should get 10% discount.
- The discount should be visible and active for all visitors.
- The discount should be applied automatically without any user actions.
- Both the regular price and the discounted price should be visible to all visitors of the site.
- It should be easy to remove the discount after 30 days.
- The solution should not relay on any additional plugins, except WooCommerce. We are trying to keep our third-party plugin usage to minimum.
- The modifications to the front-end should be minimal to none.
Environment:
- Our shop is built on WooCommerce 8.1.
- Using W3 Total Cache with Redis.
- Hosted on dedicated server with Ubuntu Server 22.04. Running Apache 2.4 with PHP 8.1 and MySQL 8.
What have I tried and didn't work:
- Using a plugin. All plugins I've tried have problems (or require too much manual clicking) handling 200,000 products.
- Creating a
couponand applying it programmatically onCartpage. This actually did the discount part. However, it required some modifications to the theme to show the new discounted price to the users.
Question:
How to do this?
Updated (allowing products with zero price and resetting existing sale prices)
Instead of overwriting products prices as you suggest in your comment, you could use the following to add a temporary global discount, that keeps the original product price with a general sale price with a 10% discount:
Code goes in functions.php file of your child theme (or in a plugin). Tested and works. It could work with your very large catalog.