Home » WooCommerce: Disable Theme’s WooCommerce Template Overrides

WooCommerce: Disable Theme’s WooCommerce Template Overrides

by adminkys

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 tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 6
 * @donate $9     https://www.tutoraspire.com
 */

define( 'WC_TEMPLATE_DEBUG_MODE', true );

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

/**
 * @snippet       Load Original WooCommerce Template
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 6
 * @donate $9     https://www.tutoraspire.com
 */

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

function tutoraspire_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’

You may also like