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        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @compatible    WooCommerce 6
 * @community     https://businessbloomer.com/club/
 */

define( 'WC_TEMPLATE_DEBUG_MODE', true );

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

/**
 * @snippet       Load Original WooCommerce Template
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @compatible    WooCommerce 6
 * @community     https://businessbloomer.com/club/
 */

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 custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

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. Follow @rmelogli

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

  1. Im using the Xstore theme, im trying to create a custom account page. the theme is applying custom css to the page causing issues with other plugins πŸ™

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

  3. 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!

  4. 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)

  5. 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 πŸ™‚

  6. 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? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. 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 the Business Bloomer Club to get quick WooCommerce support. Thank you!

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