# Limit Orders per Customer per Day

> Blocks a customer from placing more than a set number of orders in 24 hours, matched by billing email, to stop card testing and reseller bots.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, checkout, fraud, limits
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-daily-order-limit/

## Code

```php
$wpide_daily_orders = 3; // Orders allowed per email in 24 hours.

add_action( 'woocommerce_after_checkout_validation', function ( $data, $errors ) use ( $wpide_daily_orders ) {
    $email = sanitize_email( (string) ( $data['billing_email'] ?? '' ) );

    if ( ! is_email( $email ) || $errors->has_errors() ) {
        return;
    }

    $recent = wc_get_orders( array(
        'billing_email' => $email,
        'date_created'  => '>' . ( time() - DAY_IN_SECONDS ),
        'status'        => array( 'wc-pending', 'wc-processing', 'wc-on-hold', 'wc-completed' ),
        'limit'         => $wpide_daily_orders,
        'return'        => 'ids',
    ) );

    if ( count( $recent ) >= $wpide_daily_orders ) {
        $errors->add( 'validation', 'You have reached the daily order limit. Please contact us if you need to place another order today.' );
    }
}, 20, 2 );
```

## Notes

Failed and cancelled orders do not count, and orders shop managers create in the admin are not affected.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Limit Orders per Customer per Day" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
