SQL Injection Prevention — a practical guide to WooCommerce SQL injection with clear examples you can reuse in real projects.
WooCommerce Plugin Development Series (83/101). Prefer one article? Read the complete WooCommerce plugin development tutorial.
Short description
Never concatenate unsanitized request data into SQL.
Safe SQL
$wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM ... WHERE order_id = %d', $order_id));