← All articles
Stop Fake WooCommerce Orders Without a Plugin
Fake orders waste courier fees and distort your ad data. Here's a small snippet that blocks the most common pattern, repeat orders from the same phone number, without installing a plugin.
The idea
Before WooCommerce creates an order, count how many orders that phone number placed in the last 24 hours. If it's over the limit, stop checkout with a friendly message.
<?php
// Add to your child theme's functions.php or a code-snippets plugin
add_action('woocommerce_after_checkout_validation', function ($data, $errors) {
$phone = preg_replace('/\D/', '', $data['billing_phone'] ?? '');
if (strlen($phone) < 11) {
$errors->add('phone', 'Please enter a valid 11-digit phone number.');
return;
}
$recent = wc_get_orders([
'billing_phone' => $phone,
'date_created' => '>' . (time() - DAY_IN_SECONDS),
'return' => 'ids',
'limit' => 5,
]);
if (count($recent) >= 3) {
$errors->add('limit', 'You have placed several orders today. Please call us to confirm.');
}
}, 10, 2);
Why it works
- Most fake orders reuse one phone number
- Validating the length catches random digits
- Real repeat buyers get a phone number to call, not a dead end
Tip: keep your Purchase event firing only on real, confirmed orders so your ads optimise for buyers, not spammers.