A site-down triage scenario that reasons through load-order bugs, gives an immediate mitigation separate from the permanent fix, and flags whether the bug pattern will recur elsewhere.
Works with Claude / GPT2,400 uses★ 4.7
The prompt
debug-wordpress-fatal-error
A client's site just went down with this in the debug log:
[PHP Fatal error: Uncaught Error: Call to undefined function wc_get_product() in
/wp-content/themes/client-theme/functions.php:212]
CONTEXT: [this line was added to functions.php yesterday to show a custom "related
products" block on single product pages; WooCommerce is active, but this error
started right after a WooCommerce update]
ENVIRONMENT: PHP 8.2, WordPress 6.7
Work this the way a senior dev would triage a site-down ticket, in order:
1. Translate the error precisely: which function is missing, and why would a
function that clearly depends on WooCommerce be undefined when WooCommerce is
active? Reason toward load order and hook timing, not just "WooCommerce isn't
installed."
2. State the most likely root cause given the context: is this a load-order bug (the
function is called before WooCommerce has finished loading, e.g. outside a
`woocommerce_loaded` or `init` hook) or a genuine incompatibility introduced by
the update?
3. Give the exact code fix as a before/after diff, showing the correct hook to wrap
the code in.
4. Give a separate, immediate mitigation to get the site back up right now (e.g.
comment out the specific function call via SFTP). Assume there's no staging site
and this needs to happen in the next 5 minutes.
5. Flag whether this bug pattern, calling a plugin function directly in a theme
without a hook or `function_exists` guard, is likely to recur elsewhere in this
theme, and where to check.
Replace the error, context, and environment details with your actual situation.
The reasoning step in (1) matters more than it looks: most people jump straight to
“WooCommerce must be broken” when the real cause is almost always that the custom code
runs too early in the request lifecycle. Useful alongside CodeWP when
the fix needs a proper custom snippet rather than a one-line patch.
Pro tip: always ask for the immediate mitigation and the permanent fix separately.
You need the site back up before you have time to do it properly.