Protect a custom PHP shopping cart from checkout bots
Many Indian sellers, like a Moradabad brassware exporter or a Tiruppur garment maker, run an online store built years ago in custom PHP. It works, sales come in, and nobody wants to touch the code. But bots now hit the cart: adding stock to hold it, creating fake orders, testing coupons and spamming sign-ups. There is no plugin to install. This guide explains how to protect a home-grown cart without a full rewrite.
How bots abuse old custom carts
- Scripts add limited stock to carts and leave it there, so real buyers see Out of stock during a sale.
- Fake cash-on-delivery orders with invented addresses waste packing and courier costs for the seller.
- Sign-up and login pages have no limits, so bots create accounts and try passwords freely.
- Old code passes form input straight to SQL queries, leaving the cart open to injection attempts.
Protecting a custom cart step by step
- Map the risky routes. List the URLs that change data: add to cart, checkout, sign-up, login, coupon and contact. These are where bots cause harm. Product and category pages matter less. Protecting a handful of routes gives most of the benefit without touching the whole codebase.
- Add server-side checks on those routes. Insert a check at the start of each risky route that asks whether the request looks safe. If not, stop it. This is a small code change in each file, not a rewrite. Keep a backup of each file before editing, and test checkout end to end afterwards.
- Limit cart holds and orders. Release items from carts after a short time if not checked out. Limit orders per phone number and IP per day, especially for cash on delivery. These business rules stop stock hoarding and fake COD orders even if a bot gets through.
- Fix the riskiest queries. Ask a developer to find queries that join user input directly into SQL, starting with login, search and checkout. Switch them to prepared statements. Meanwhile, block requests with clear injection patterns at the edge to buy time.
- Review fake orders weekly. Each week, look at cancelled and returned COD orders. Note patterns like the same address format or phone range. Feed these into your rules. Over a few weeks, fake orders should fall, and courier costs with them.
How VadiGuard helps
Framework-agnostic PHP integration
VadiGuard provides a PHP integration that works with any framework or none, plus a JavaScript SDK for the browser. A custom cart can add checks on key routes without moving to a new platform, and setup of the script tag takes minutes.
Bots, sign-ups and logins covered
Bot detection, fake email detection, rate limiting and brute-force lockout apply to cart, sign-up and login routes. Real buyers do not see puzzles, so checkout conversion stays where it is while abuse falls.
Injection blocked while you fix code
VadiGuard blocks SQL injection and XSS attempts in real time. This gives an old cart a protective layer while your developer works through the riskiest queries, and real-time logs show which routes attackers probe.
An old custom cart can be protected without a rewrite. Map risky routes, add server-side checks, limit holds and orders, fix the worst queries and review weekly. VadiGuard's PHP integration fits this approach. The team can review your cart in a demo.
Questions people ask
Do we need to rebuild our store first?
No. VadiGuard's framework-agnostic PHP integration can be added to existing routes. A rebuild may help long-term but is not required to add protection.
Can VadiGuard stop fake cash-on-delivery orders?
It can stop many automated fake orders using bot detection, fake email checks and rate limits. Fake orders placed by real people need business rules like order limits and phone verification.
What if our code is very old PHP?
Very old PHP versions may need checking. Share your PHP version and setup with the team to confirm compatibility.
Will it affect payment gateway callbacks?
Callbacks from your gateway should be allowed through. Plan rules with your developer so trusted callback routes are not blocked.