NeuroAgent

How to Properly Edit WooCommerce Cart Template

Complete guide to editing WooCommerce cart template. Learn why changes aren't applying and how to properly override cart.php in your WordPress theme.

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.

NeuroAgent

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

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 woocommerce and cart folders 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:

php
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.php file 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:

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:

php
// 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:

  1. Create a child theme of your main theme
  2. Copy the woocommerce/cart/cart.php structure to the child theme
  3. Make changes to the copied file

Step-by-step guide to editing cart.php

Step 1: Preparation

  1. Create a backup of your website
  2. Ensure you have access to FTP or your hosting’s file manager
  3. Activate the child theme (if using one)

Step 2: Creating the correct structure

  1. Navigate to your theme’s folder: /wp-content/themes/your-theme/
  2. Create a woocommerce folder (if it doesn’t exist)
  3. Inside woocommerce, create a cart folder
  4. Copy the cart.php file from /wp-content/plugins/woocommerce/templates/cart/cart.php to the created folder

Step 3: Configuring the theme

  1. Open the functions.php file in your theme
  2. Add the code to declare WooCommerce support
  3. Save the file

Step 4: Making changes

  1. Open the copied cart.php file
  2. Make the necessary changes
  3. Save the file

Testing and verifying changes

1. Verifying the correct path

Ensure the file is in the correct path:

bash
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:

php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);

Check the error log for messages about WooCommerce templates.

4. Checking via developer tools

  1. Open the cart page in your browser
  2. Press F12 to open developer tools
  3. Check the “Network” tab and see which files are loaded
  4. Verify that your custom template is being used

Sources

  1. Template structure & Overriding templates via a theme | WooCommerce developer docs
  2. WooCommerce Overriding Templates are not working after the latest update. 8.9.1 | WordPress.org Support
  3. WooCommerce Cart Template Override Not Working | Reddit
  4. How to Override WooCommerce Templates Complete Guide
  5. How to Override Template Files in WooCommerce

Conclusion

  1. The main problem is the lack of WooCommerce support declaration via the add_theme_support('woocommerce') function in your theme’s functions.php file.

  2. The correct folder structure should be: wp-content/themes/your-theme/woocommerce/cart/cart.php

  3. Check for conflicting files, especially woocommerce.php in your theme’s folder, which may interfere with template overriding.

  4. For modern WooCommerce versions, you may need to disable the block-based cart using the woocommerce_blocks_enable_cart filter.

  5. 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.