Let Link Software handle your WordPress updates, backups, and security for you. Packages start as low as $39/month.
How to Fix WooCommerce Scheduled Sales That Aren’t Updating
Last Updated January 21st, 2022 · WordPress
It’s time for yet another fix to a frustrating WooCommerce problem. This time I’m going to walk you through the process of making WooCommerce scheduled sales work correctly.
A client wanted to set up some one-day sales for products in their WooCommerce store. So they went into each product and set a scheduled sale. Here’s an example:
They saved their changed products and waited patiently for midnight to strike on the start date of their sale for the new pricing to become available to their customers.
Midnight came. Nothing happened.
They waited until the morning just in case it was some weird time zone issue. Still, nothing happened. The products were all listed at their regular prices.
Frustrated, they logged back in to delete their sale and try again just as they had done the day before. Then they saved the products a second time. Magically, their sale prices were now running and everything was working as they wanted.
Of course, what was the point of scheduling the sale if you ultimately had to manually update each product on the sale’s day to get results? To make matters worse, some days the sale prices weren’t being removed from the front end of the site even after the scheduled stop date had come and gone.
The Solution for Fixing Broken WooCommerce Scheduled Sales
We went down a handful of rabbit holes thanks to some bad advice on WooCommerce forums and ticket systems. A lot of people blamed other plugins or caching as the culprit for broken scheduled sales. Unfortunately, that ended up being a dead-end for me.
It eventually became clear this was a problem with WP Cron and WooCommerce’s scheduled tasks. In particular, we had to make some adjustments to the recurrence rate of the woocommerce_scheduled_sales cron event. This event is what triggers the actual pricing changes to the products with scheduled sales.
The best way to examine your site’s WP Cron events is by using the excellently named WP Crontrol plugin. This beautiful piece of software lets you see exactly what scheduled events your WordPress install is set to run as well as what time and how often they execute.
Imagine our surprise when we learned the settings for woocommerce_scheduled_sales were telling it to run only once per day at exactly 11 PM.
The flaw here is pretty obvious. If the scheduled sale dates are set to go off at midnight they are never going to execute properly if the event that triggers them is executing itself an hour too early each day.
We changed the event’s recurrence to “Once Hourly” and made sure the next run was set an hour from our edit.
After forcing WP Crontrol to execute the task manually the sale prices on all products immediately began showing correctly.
An Update and a Warning
Since this post was written we’ve experienced a few more issues with the woocommerce_scheduled_sales event.
There have been times when the event was deleted/disabled entirely from a WordPress installation. We have also experienced the recurrence rate being reset back to “Once Daily” after a WooCommerce upgrade.
It’s important to know just because you fix this issue one time doesn’t mean it won’t be back causing you trouble again in the future.
Why does this happen?
There have been several issues with this client’s WooCommerce install ever since a version rollback from the initial 3.0 release. I’m not sure if that’s the culprit though. Many people have experienced the same issue and have reported it on various tech support boards and forums around the web (and few seem to have found the solution).
WP Cron is generally derided as a poor attempt at running scheduled tasks so maybe the base issue lies there. It depends on visitors to your site to actually initiate the execution of the events. A traditional cron job runs on the server and fires off when you tell it. This means you aren’t waiting for an unrelated website visitor to initiate the call.
In the end, the actual fix is very simple even if the cause isn’t so apparent. Hopefully, this post will help you get your troubles sorted out.
Looking for more help with WooCommerce?
Link Software LLC provides a host of WordPress plugin development services. Contact us to learn more about what we can offer.
We also have a brand new plugin that can help you with your online store: Remove WooCommerce Features. With this plugin, you can remove and disable dozens of unwanted features that WooCommerce, and your theme, have enabled by default. Turn off specific checkout fields, remove related product listings, hide quantity buttons, and much more.