add_filter('woocommerce_add_to_cart_validation', function($ok, $pid, $qty){ if (strtoupper($_SERVER['REQUEST_METHOD'] ?? '') !== 'POST') return false; if (empty($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'woocommerce-cart')) return false; return $ok; }, 10, 3);