How to declare WooCommerce support in your theme

Received a WooCommerce help SOS through our contact form, so here is the simple answer to a question we’ve been asked more than once!

Declaring WooCommerce theme support is really important after WooCommerce 3.3.0 – if your theme does not contain this in functions.php, then there’s a good chance any woocommerce templates you add to /wp-content/[your-theme]/woocommerce/ will not be loaded. This means you’ll lose all your customizations immediately on upgrade.

This is one of the first things to check if you recently updated WooCommerce and find you have lost your WooCommerce themes… is the necessary line (below) actually in your functions.php file in your theme, or child theme? No? Well add it!

[HINT if you came here looking for actual WooCommerce Support <- visit the link! i.e. if you wanted help and support with your wc project]

If you have WordPress + WooCommerce installed, and your theme doesn’t explicitly say it “supports WooCommerce” you’ll get a nag screen at the top that says something along the lines of “your theme doesn’t declare woocommerce support … “. In more recent versions, this has had a real impact, as it also means your WooCommerce templates (overrides you make to WooCommerce template files, held in your theme’s files) will potentially be ignored. This, if you have styled your store, you do not want.

From WooCommerce Github docs:

If you are using custom WooCommerce template overrides in your theme you need to declare WooCommerce support using the add_theme_support function. WooCommerce template overrides are only enabled on themes that declare WooCommerce support. If you do not declare WooCommerce support in your theme, WooCommerce will assume the theme is not designed for WooCommerce compatibility and will use shortcode-based unsupported theme rendering to display the shop.

Source, here.

This is Important

Basically, if your theme has any form of WooCommerce specific customization at all, you will want to declare WooCommerce support in your WordPress theme.

This is very important, in other words. Without this line, your customizations will break.

How to declare WooCommerce support in your theme

There are now a couple of ways to achieve this, one basic and one with settings. You can see which is which, and how to do both, below. Happy coding!

Basic WooCommerce Support



More advanced WooCommerce Support – with settings

The below method will allow you to specify default settings for your theme, which may be extremely useful. Note these settings may be configured in Customizer if they are not specified. Use as required.



Done!

Leave a comment below if this worked / didn’t work for you.

1 thought on “How to declare WooCommerce support in your theme”

Leave a comment

No links of any kind allowed in comments - if you add any links, your comment will automatically be deleted.