Redis and qTranslate X causing Woocommerce stock issue

I have been working on a stock issue on Woocommerce for the past few week, which involved using Redis and qTranslate X keeps displaying incorrect stock amount.

So what happen is I have a Woocommerce site with Redis turn on for the object caching purpose when the user updates the stock from the backend, it doesn’t reflect at the front end. So when Staff A update Product B from 2unit to 5unit, the users still seeing 2 unit from the frontend.

After doing some debugging, it seems like the Redis cache didn’t regenerate when the post update, so the front end is using an outdated cache. In fact, Woocommerce does handle expired cache for this kind of scenario, but the problem is qTranslate X keeps another set of Redis cache for each language, this is why the front end stock didn’t show the updated results.

So the easy solutions are code a custom hook under functions.php when doing the clean_post_cache action. It will clean out the qTranslate X language Redis cache when there is a need to clean the post cache.

You may also like...