Every template copy in the theme is a debt that comes due with every WooCommerce update.
The case
After a WooCommerce update the Add to cart button disappeared on variable products. Nobody touched the theme.
But the theme holds 40 template overrides copied years ago. One of them is single-product/add-to-cart/variable.php. Its only difference from the original is one icon.
Every template copy is a debt that comes due with every update.
Order of choice
- Settings
- A hook or filter in a plugin
- A block or pattern (in a block theme:
templates/single-product.html) - A template override, as the last resort, and watch its
@version
A block product template in the theme (excerpt):
<!-- wp:woocommerce/product-image-gallery /-->
<!-- wp:post-title {"level":1,"__woocommerceNamespace":"woocommerce/product-query/product-title"} /-->
<!-- wp:woocommerce/product-price {"isDescendentOfSingleProductTemplate":true} /-->
<!-- wp:woocommerce/add-to-cart-form /-->
Outdated copies are listed in WooCommerce → Status → System status, the Templates section: the copy’s version next to the core version.
The interview question
Why are template overrides a risk?
Weak answer. Because you have to update them.
Strong answer. A copy “freezes” the template at the version it was copied from. New hooks, security and accessibility fixes never reach it. So I override only what can’t be changed with a hook, keep the diff with the original minimal and check WooCommerce → Status → Templates after every update.
👉 The full chapter is in the course WooCommerce Development for Middle Devs: Module 2. Hooks and Extensions
🔔 More WooCommerce videos: youtube.com/@4wpdev