Check AI-written WooCommerce code before it touches orders
Paste WooCommerce code an AI wrote or changed. Get the order, checkout and money mistakes it made, ranked must-fix or should-fix, with the safe replacement.
What you fill in
- The code or diff to review
- What the code is meant to do
- WooCommerce version and supported range
- Order storage mode: new order tables, legacy, or both
- Checkout type: block checkout, classic shortcode, or both
- Payment and shipping plugins it touches
The full prompt
Check this WooCommerce code before it goes near real orders
About my store
- Store and what the code is for: [e.g. a coffee subscription store; code adds a gift message field to checkout]
- WooCommerce version and the range the code must support: [e.g. 9.x]
- Order storage: [NEW ORDER TABLES (HPOS), LEGACY POSTS, OR BOTH; say "not sure" if unknown]
- Checkout type: [BLOCK CHECKOUT, CLASSIC SHORTCODE CHECKOUT, OR BOTH]
- Plugins it touches: [e.g. Stripe gateway, a shipping rates plugin]
- The code or diff: [PASTE]
Your job
Act as a senior WooCommerce developer reviewing code an AI assistant wrote. AI-written WooCommerce code often targets the platform as it was years ago, and with money on the line "works on my demo store" is not enough. Review only; do not rewrite the whole file unless I ask. If my storage mode or checkout type is unknown, review for both.
Must fix: order and product data
- Orders are not posts. Order data goes only through the order functions and objects (get the order, read and write its meta, then save). Reading or writing order data with post meta functions, post queries on the order post type or direct database joins on post meta breaks on stores using the new order tables.
- Products, customers and coupons are changed through their objects and saved, not by writing meta directly; stock and order status change through WooCommerce's own functions, so lookup tables, emails and other plugins' hooks still fire.
- Compatibility is declared for the new order tables, and for block checkout if the code touches checkout. A missing declaration shows a warning to every store owner.
Must fix: checkout and money
- Checkout rules are checked on the server for the checkout the store actually runs (classic, block, or both). Browser-side checks are for convenience only.
- Money is never a float: no hand-typed currency symbols, no general number formatting on prices, no equality tests on totals. Use WooCommerce's own price, decimal and tax rounding helpers.
Should fix: runtime
- The cart and session do not exist in REST, scheduled, command-line or some admin contexts; check before using them. Never assume a logged-in customer in gateway or webhook callbacks. Confirm every hook and function exists in the supported version range.
- Prefer hooks and filters over template files copied into a plugin, which freeze at one version and break on updates.
- Background jobs and syncs use WooCommerce's bundled scheduler, not raw cron loops, and handlers cope with the same order event arriving twice.
Security floor, every time: all output escaped for its context; request data unslashed then sanitised; a capability check and a nonce on every change of state; every database query with a variable prepared.
If you can read the official WooCommerce developer docs, check any hook name you are unsure of.
Output
- SHIP OR HOLD: one line. Any must-fix finding means hold.
- Findings: Rule | Severity (must fix or should fix) | File and line or function | What is wrong | Safe fix (short code or the function to use).
- SECURITY FLOOR: escaping | sanitising | capability and nonce | prepared queries, each pass or fail with where.
- TEST BEFORE LIVE: one order through each checkout type on a staging copy, a refund, and the order emails.
- NOT CHECKED: anything you could not judge without more files.
Check before you answer
- Every finding names its file and line or function.
- No order data is read or written through post meta in your fixes.
- Both checkout types are covered when the type is unknown.
- Every security floor line has a result.
- Testing happens on staging, never on the live store.
Used by Yaroslav, Shopify theme developer.