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
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
* @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 Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @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’
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
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
Very, very thank.
Welcome
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!!
π
Thank you!
Rodolfo, if you do not need that Woocommerce folder why do not just delete it?
Because at the next update it will come back – hence why I use the snippet (will work all the time)
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?
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 π
Hello, Rodolfo,
I added the code but the notifications are not gone https://prntscr.com/l9vuwx
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!