Basic Rate-limiting in WooCommerce with native class

WC_Rate_Limiter is a great little utility class in WooCommerce codebase which is not very popular but could be very helpful at times. I accidentally stumbled upon it while reading the source code of WooCommerce and thought of sharing it on my blog.

You would want to use rate-limiting to prevent user from performing an action again and again too frequently. For example, one would want to rate-limit file download so that a file can be downloaded only once a day.

It’s very easy and straight-forward to accomplish this with a few lines of code.


$action is a custom action name for the event. You can name it anything.

$delay is the time interval for which you want to rate-limit the action.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Up Next:

WooCommerce is_catalog() function

WooCommerce is_catalog() function