How do I properly edit the WooCommerce cart template? I created a cart folder inside my WordPress theme and added a cart.php file at the path /public_html/wp-content/themes/ТЕМА/woocommerce/cart, but the changes I made are not displaying on the cart page. I already cleared the cache, but that didn’t help. I also tried editing the cart.php file directly in the WooCommerce plugin folder, but there are still no changes. Please advise on what I need to do for my changes to take effect.
How to Properly Edit WooCommerce Cart Template
To properly edit the WooCommerce cart template, you need to create the correct folder structure in your theme, declare WooCommerce support in functions.php, and check for possible conflicts. The main problem is that changes are not applied due to incorrect theme configuration or conflicts with other files.
Table of Contents
- Correct folder structure for overriding templates
- Declaring WooCommerce support in the theme
- Common problems and their solutions
- Alternative methods for overriding templates
- Step-by-step guide to editing cart.php
- Testing and verifying changes
Correct folder structure for overriding templates
For successfully overriding the WooCommerce cart template, the folder structure should be as follows:
wp-content/themes/
└── your-theme/
├── functions.php
└── woocommerce/
└── cart/
└── cart.php
Important points:
- The file must be named exactly
cart.php - The
woocommerceandcartfolders must be inside your theme’s folder - The full path should be:
/wp-content/themes/your-theme/woocommerce/cart/cart.php
According to the official WooCommerce documentation, this structure allows you to safely override templates without the risk of losing changes when the plugin is updated.
Declaring WooCommerce support in the theme
The most common reason why changes are not applied is the lack of WooCommerce support declaration in your theme. Add the following code to your theme’s functions.php file:
function mytheme_add_woocommerce_support() {
add_theme_support( 'woocommerce' );
}
add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );
Why this is important:
- Without declaring WooCommerce support, WooCommerce will use default rendering based on shortcode
- This is a mandatory requirement for the template override system to work
- As noted in the documentation, without this function, no overrides will work
Common problems and their solutions
1. Conflict with woocommerce.php file
If your theme has a woocommerce.php file, it takes priority over other templates and may interfere with overriding. In this case:
Check for the presence of a
woocommerce.phpfile in your theme’s folder. If it exists, WooCommerce will use it instead of the overridden templates.
2. Enabled block-based cart
In newer versions of WooCommerce, the block-based cart may be enabled. Disable it by adding to functions.php:
// Disable block-based cart
add_filter('woocommerce_blocks_enable_cart', '__return_false');
3. Caching
Clearing cache is good, but sometimes deeper cache clearing is required:
- Clear your plugin cache (if using WP Rocket, W3 Total Cache, etc.)
- Clear WordPress object cache
- Clear your browser cache and check in Incognito mode
Alternative methods for overriding templates
1. Using a functionality plugin
Create a separate plugin for overriding templates:
// In the plugin file
add_filter('woocommerce_locate_template', 'intercept_wc_template', 10, 3);
function intercept_wc_template($template, $template_name, $template_path) {
global $woocommerce;
$_template = $template;
if (!$template) {
$file = $woocommerce->plugin_path() . '/templates/' . $template_name;
if (file_exists($file)) {
$template = $file;
}
}
$plugin_path = untrailingslashit(plugin_dir_path(__FILE__)) . '/woocommerce/';
if (file_exists($plugin_path . $template_name)) {
$template = $plugin_path . $template_name;
}
return $template;
}
2. Using a child theme
It’s always recommended to use a child theme for customization:
- Create a child theme of your main theme
- Copy the
woocommerce/cart/cart.phpstructure to the child theme - Make changes to the copied file
Step-by-step guide to editing cart.php
Step 1: Preparation
- Create a backup of your website
- Ensure you have access to FTP or your hosting’s file manager
- Activate the child theme (if using one)
Step 2: Creating the correct structure
- Navigate to your theme’s folder:
/wp-content/themes/your-theme/ - Create a
woocommercefolder (if it doesn’t exist) - Inside
woocommerce, create acartfolder - Copy the
cart.phpfile from/wp-content/plugins/woocommerce/templates/cart/cart.phpto the created folder
Step 3: Configuring the theme
- Open the
functions.phpfile in your theme - Add the code to declare WooCommerce support
- Save the file
Step 4: Making changes
- Open the copied
cart.phpfile - Make the necessary changes
- Save the file
Testing and verifying changes
1. Verifying the correct path
Ensure the file is in the correct path:
wp-content/themes/your-theme/woocommerce/cart/cart.php
2. Checking file permissions
The file should have permissions 644 (read/write for owner, read for others).
3. Testing in debug mode
Add to wp-config.php:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
Check the error log for messages about WooCommerce templates.
4. Checking via developer tools
- Open the cart page in your browser
- Press F12 to open developer tools
- Check the “Network” tab and see which files are loaded
- Verify that your custom template is being used
Sources
- Template structure & Overriding templates via a theme | WooCommerce developer docs
- WooCommerce Overriding Templates are not working after the latest update. 8.9.1 | WordPress.org Support
- WooCommerce Cart Template Override Not Working | Reddit
- How to Override WooCommerce Templates Complete Guide
- How to Override Template Files in WooCommerce
Conclusion
-
The main problem is the lack of WooCommerce support declaration via the
add_theme_support('woocommerce')function in your theme’sfunctions.phpfile. -
The correct folder structure should be:
wp-content/themes/your-theme/woocommerce/cart/cart.php -
Check for conflicting files, especially
woocommerce.phpin your theme’s folder, which may interfere with template overriding. -
For modern WooCommerce versions, you may need to disable the block-based cart using the
woocommerce_blocks_enable_cartfilter. -
Always use a child theme for customization so your changes won’t be overwritten when the main theme is updated.
If after following all these steps the changes still don’t apply, it’s recommended to contact your theme’s developers or official WooCommerce support for additional diagnosis.