Classic woocommerce template overrides

From Lonsdale201/wp-agent-skills · View interactive version

Classic woocommerce template overrides is an AI agent skill from the GitHub repository Lonsdale201/wp-agent-skills. Create or audit WooCommerce template overrides in a classic PHP theme. Covers the `yourtheme/woocommerce/` override path, the WooCommerce template path, `wc_get_template()`, `wc_get_template_part()`, `woocommerce.php`, `single-product.php`, `archive-product.php`, taxonomy templates, `WC_TEMPLATE_DEB

How to use this skill

Skill file

Classic WooCommerce Template Overrides

Use this when a classic theme needs to change WooCommerce markup. Prefer hooks and filters first. Use template overrides only when the required markup change cannot be done safely through hooks.

When to Use This Skill

Override Lookup

Woo looks for theme overrides in the active theme using WC()->template_path(), which defaults to woocommerce/.

Typical paths:

yourtheme/
|-- woocommerce/
|   |-- archive-product.php
|   |-- content-product.php
|   |-- single-product.php
|   |-- content-single-product.php
|   |-- loop/
|   |   `-- add-to-cart.php
|   `-- single-product/
|       `-- product-image.php

Rules:

Hook/Filter First

Most Woo frontend templates are hook skeletons. Customize with hooks before copying templates.

Example: move single product price after excerpt.

add_action( 'after_setup_theme', 'mytheme_single_product_summary_order' );

function mytheme_single_product_summary_order() {
	remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
	add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 25 );
}

Rules:

Template Loader Files

Woo's supported classic loader can resolve:

Rules:

Outdated Template Discipline

Every copied Woo template is a maintenance contract.

Workflow:

  1. Check WooCommerce > Status > System Status for outdated templates.
  2. Compare the theme override against the same file in the installed Woo version.
  3. Copy the new template from wp-content/plugins/woocommerce/templates/.
  4. Reapply only the theme-specific changes.
  5. Keep the new @version header.
  6. Retest product types, notices, account/cart/checkout flows, and accessibility.

Rules:

WC_TEMPLATE_DEBUG_MODE

WC_TEMPLATE_DEBUG_MODE forces Woo to ignore theme overrides and use plugin templates.

Use it to answer:

Do not leave debug mode enabled in production.

Child Themes

Child themes override Woo templates before parent themes because WordPress locate_template() checks the stylesheet directory first.

Rules:

Escaping and Data Access

Rules:

High-Risk Overrides

Avoid or heavily review:

These templates carry payment, account, accessibility, JavaScript, or compatibility contracts.

Review Checklist

Common Mistakes

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.