WooCommerce: Disable Theme’s WooCommerce Template Overrides

A client purchased a premium “WooCommerce-ready” WordPress theme. Unfortunately, this theme comes with a /woocommerce folder, which means theme developers completely override WooCommerce template files by copying them to the folder, and customizing each of them by hand to match their design and functionality needs.

As you know from my “How To Become an Advanced WooCommerce Developer?” article, however, themes should NOT come with a /woocommerce folder – instead they should use “hooks” (actions and filters) to amend default WooCommerce plugin layouts and behavior. This is a huge problem for best seller themes and their legacy coding – and also a reason most themes break when you update WooCommerce…

So the question I asked myself was: how can I disable the entire /woocommerce folder (i.e. ALL WooCommerce template overrides) in a given theme or a single template, so that I can use the default WooCommerce ones instead?

Option 1: Disable Theme’s /woocommerce Folder Via FTP or File Manager

Renaming the theme’s /woocommerce folder (which contains WooCommerce template overrides) via FTP

The easiest thing to do is going to your theme’s folder inside wp-content and RENAME the /woocommerce folder to something else e.g. /DISABLED-woocommerce (see screenshot).

Super easy – but next time you update the theme, you’d need to re-do this. And trust me, you’ll probably forget about it and your WooCommerce site will break again…

Option 2: Disable ALL WooCommerce Overrides Via wp-config.php

This is a little gem (thanks to Damien Carbery). If you study WooCommerce plugin files, and specifically the wc_get_template_part() function, you will see a note:

WC_TEMPLATE_DEBUG_MODE will prevent overrides in themes from taking priority

So, thanks to Damien, I added the following line to wp-config.php:

/**
 * @snippet       Disable WooCommerce Theme Overrides Via wp-config
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 6
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

define( 'WC_TEMPLATE_DEBUG_MODE', true );

Option 3: Disable a Single WooCommerce Override (functions.php)

/**
 * @snippet       Load Original WooCommerce Template
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 6
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_filter( 'wc_get_template', 'bbloomer_dont_load_cart_template_theme_override', 9999, 5 );

function bbloomer_dont_load_cart_template_theme_override( $template, $template_name, $args, $template_path, $default_path ) {
	if ( $template_name == 'cart/cart.php' ) {
		$default_path = WC()->plugin_path() . '/templates/';
		$template = $default_path . $template_name;
	}
	return $template;
}

Possible values for $template_name:

  • ‘archive-product.php’
  • ‘checkout/form-billing.php’
  • ‘checkout/form-shipping.php’
  • ’emails/email-header.php’
  • ’emails/email-footer.php’
  • ’emails/email-customer-details.php’
  • ’emails/email-styles.php’
  • ‘single-product/add-to-cart/variation.php’
  • ‘cart/cart-empty.php’
  • ‘cart/cart.php’
  • ‘checkout/order-receipt.php’
  • ‘checkout/thankyou.php’
  • ‘checkout/cart-errors.php’
  • ‘checkout/form-checkout.php’
  • ‘myaccount/form-login.php’
  • ‘myaccount/form-edit-account.php’
  • ‘myaccount/lost-password-confirmation.php’
  • ‘myaccount/form-add-payment-method.php’
  • ‘order/form-tracking.php’
  • ‘order/order-details-customer.php’
  • ‘global/wrapper-start.php’
  • ‘global/wrapper-end.php’
  • ‘global/sidebar.php’
  • ‘loop/loop-start.php’
  • ‘loop/loop-end.php’
  • ‘loop/add-to-cart.php’
  • ‘loop/price.php’
  • ‘loop/rating.php’
  • ‘loop/sale-flash.php’
  • ‘loop/result-count.php’
  • ‘loop/pagination.php’
  • ‘single-product/product-image.php’
  • ‘single-product/product-thumbnails.php’
  • ‘single-product/tabs/tabs.php’
  • ‘single-product/title.php’
  • ‘single-product/rating.php’
  • ‘single-product/price.php’
  • ‘single-product/short-description.php’
  • ‘single-product/meta.php’
  • ‘single-product/share.php’
  • ‘single-product/sale-flash.php’
  • ‘single-product/add-to-cart/simple.php’
  • ‘global/quantity-input.php’
  • ‘single-product/tabs/description.php’
  • ‘single-product/tabs/additional-information.php’
  • ‘single-product/review-rating.php’
  • ‘single-product/review-meta.php’
  • ‘single-product/related.php’
  • ‘cart/cart-totals.php’
  • ‘cart/proceed-to-checkout-button.php’
  • ‘cart/mini-cart.php’
  • ‘global/form-login.php’
  • ‘global/breadcrumb.php’
  • ‘auth/header.php’
  • ‘auth/footer.php’
  • ‘single-product/add-to-cart/variation-add-to-cart-button.php’
  • ‘myaccount/navigation.php’
  • ‘myaccount/downloads.php’
  • ‘myaccount/payment-methods.php’
  • ‘myaccount/my-address.php’
  • ‘loop/no-products-found.php’
  • ‘single-product/photoswipe.php’
  • ‘cart/cart-item-data.php’
  • ‘content-widget-product.php’
  • ‘checkout/terms.php’

Where to add custom code?

You should place PHP snippets at the bottom of your child theme functions.php file and CSS at the bottom of its style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my guide "Should I Add Custom Code Via WP Editor, FTP or Code Snippets?" and my video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything went as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting.

If you think this code saved you time & money, feel free to join 17,000+ WooCommerce Weekly subscribers for blog post updates and 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance!

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

12 thoughts on “WooCommerce: Disable Theme’s WooCommerce Template Overrides

  1. Hi Rodolfo,

    I’m having issues with the shipping fees calculator not showing in the cart/checkout pages, i tried your solution but then I couldn’t load the cart page. Can you please let me know where exactly to add the line “define( ‘WC_TEMPLATE_DEBUG_MODE’, true );” in the file wp_config.php?
    Thanks a lot for your help

    1. If that doesn’t work for you, simply switch to Storefront theme temporarily and see if the error goes away, in which case it’s your theme’s fault

    1. Welcome

  2. You have just saved my life. As a total noob, I have just spent a week looking for ways to do this, and you solved it in one fell swoop. I think I might love you <3
    Thank you!!
    😉

    1. Thank you!

  3. Rodolfo, if you do not need that Woocommerce folder why do not just delete it?

    1. Because at the next update it will come back – hence why I use the snippet (will work all the time)

  4. Hey Rodolfo,
    What’s the point of preventing overrides in themes from taking priority altogether ?
    You always need to override emails at least.
    When I develop a theme, the Woocommerce folder is a must I think.
    Also, if you disable it in commercial theme you bought you harm the theme function.
    Could you refer to these issues?

    1. These are very good questions Yehuda, thanks!

      You always need to override emails at least” – not entirely true. WooCommerce email hooks are usually sufficient, also Woo are launching a new email template editor very soon.

      When I develop a theme, the WooCommerce folder is a must I think” – definitely not, I don’t like themes that do that (hence this tutorial). Actions and filters can make you achieve 99% of the customization you usually require. Storefront theme has no /woocommerce folder for example.

      Also, if you disable it in commercial theme you bought you harm the theme function” – yep, definitely possible, depending on how the theme is coded. Mostly if they also have woocommerce.php file override and other weird things. In general, themes should use WooCommerce hooks and not any other way for overriding WooCommerce.

      Hope this makes sense 🙂

  5. Hello, Rodolfo,

    I added the code but the notifications are not gone https://prntscr.com/l9vuwx

    1. Hey Christian, thanks for your comment 🙂 I don’t think this function also removed those override notifications – but for sure it does avoid those overrides are loaded. Just tried on a client’s website, works very well!

Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

Your email address will not be published. Required fields are marked *