Classic Theme Development
Classic themes use PHP template files and WordPress hooks to create custom WooCommerce experiences. This approach provides complete control over markup and functionality while maintaining upgrade compatibility through proper template override practices.This guide covers classic PHP-based themes. For block theme development using HTML templates and FSE, see Block Theme Development.
Template File Structure
WooCommerce organizes templates in a hierarchical structure withinwp-content/plugins/woocommerce/templates/:
Overriding Templates
Copy templates to your theme to customize them safely:1
Create WooCommerce Directory
In your theme folder, create a
woocommerce/ directory:2
Copy Template File
Copy the template from WooCommerce plugin to your theme, removing the
/templates/ subdirectory:3
Customize Template
Edit the copied file in your theme. The theme version will now override the WooCommerce default.
4
Maintain Templates
When WooCommerce updates, check System Status for outdated templates and update them accordingly.
Example: Overriding Single Product Template
Template Hooks
WooCommerce templates are built around hooks that allow adding or moving content without editing template files. This is the recommended customization method.Single Product Hooks
Thecontent-single-product.php template demonstrates extensive hook usage:
Common Hook Examples
Key Hook Categories
For a complete list of hooks, see the WooCommerce Action Reference.
Conditional Tags
Use conditional tags to determine which WooCommerce page is being displayed and customize content accordingly.Available Conditional Tags
Conditional Tag Usage Examples
WooCommerce Template Functions
WooCommerce provides numerous template functions for outputting product information:Product Information Functions
Shop Loop Functions
Integrating WooCommerce with Theme Layout
Method 1: Using Hooks (Recommended)
Replace WooCommerce’s default wrappers with your theme’s markup:- Requires minimal maintenance on updates
- Keeps WooCommerce templates untouched
- Integrates cleanly with theme structure
Method 2: woocommerce.php Template
Create a single template handling all WooCommerce content:When using
woocommerce.php, you cannot override archive-product.php as woocommerce.php takes priority.Declaring Theme Support
Always declare WooCommerce support infunctions.php:
Use the
after_setup_theme hook, not init. This ensures proper loading order.Maintaining Template Compatibility
1
Monitor Template Versions
WooCommerce includes version comments in templates:Check WooCommerce > Status > System Status for outdated template warnings.
2
Compare Template Changes
When updates occur, compare your override with the new core template:
3
Update Templates Selectively
Only update templates that have meaningful changes. Not all version bumps require updates.
4
Test After Updates
Always test template functionality after updating WooCommerce or modified templates.
Best Practices
Prefer Hooks Over Overrides
Use hooks whenever possible. They’re more maintainable and upgrade-safe than template overrides.
Never Remove Hooks
Always preserve
do_action() calls in template overrides to maintain plugin compatibility.Document Template Versions
Add
@version comments to custom templates noting the WooCommerce version they’re based on.Use Child Themes
Never modify parent theme files. Always use child themes for customizations.
Next Steps
Theme Customization
Learn CSS styling, child themes, and advanced customization techniques
Template Reference
Browse all WooCommerce template files on GitHub