Getting hit with fake WooCommerce orders or card testing scams? In this video I’ll show you how to block bots by adding a simple code snippet. This quick fix helps protect your store, reduce fraud, and keep your checkout safe.
Timestamps:
- 2:24 Enable Rate Limit Checkout
- 4:10 Add Code Snippets
Code Snippets
/** disable wc_endpoint to stop carding attacks **/
function disable_wc_endpoint_v1() {
$current_url = $_SERVER['REQUEST_URI'];
if (strpos($current_url, '/wp-json/wc/store/v1/checkout') !== false) {
wp_redirect(home_url('/404.php'));
exit;
}
}
add_action('rest_api_init', 'disable_wc_endpoint_v1');
/** disable wc_endpoint to stop carding attacks **/
function disable_wc_endpoint() {
$current_url = $_SERVER['REQUEST_URI'];
if (strpos($current_url, '/wp-json/wc/store/checkout') !== false) {
wp_redirect(home_url('/404.php'));
exit;
}
}
add_action('rest_api_init', 'disable_wc_endpoint');