0

I´m making my first Woocommerce theme. In the documentation and in plugins/woocommerce/templates/single-product.php, it´s written :

This template can be overridden by copying it to yourtheme/woocommerce/single-product.php

But when I do this, it does not work and if I put the file on my theme root, it got it, why ?

Comments inside files and WooCommerce documentation are not updated ?

3
  • 2
    did you add add_theme_support( 'woocommerce' ); in your theme ? Oct 23, 2019 at 17:45
  • 2
    @Chetan is correct. And single-product.php in the root theme folder works because that is a valid/recognized template for single posts of the product type - i.e. single-<post type>.php - and by default, it has a higher priority and would be used even if your theme does have woocommerce/single-product.php.
    – Sally CJ
    Oct 23, 2019 at 18:37
  • @ChetanVaghela Thank you ! It´s exaclty what I wanted to know.
    – J.BizMai
    Oct 23, 2019 at 19:24

2 Answers 2

1

As @ChetanVaghela said in comments, to use the woocommerce structure you need to add this code line :

add_theme_support( 'woocommerce' ); 
0

Sally in the comments above gave a very informative answer to this question, which answers the OP.

I would like to quote it again:

single-product.php in the root theme folder works because that is a valid/recognized template for single posts of the product type - i.e. single-<post type>.php - and by default, it has a higher priority and would be used even if your theme does have woocommerce/single-product.php

Also Chetan mentioned to add theme support with

add_theme_support( 'woocommerce' ); 

But note, if at woocommerce.php file resides a your your theme's root folder, the single-product.php and archive-product.php wont work.

WooCommerce plugin comes with a handy checking tool at your Dashboard. Go the WooCommerce -> Status

  • And it reports if your theme has been modified to add wocommerce support or not.
  • Any flags to notice
  • And at the last section it shows the list of template files which are overwritten and if there are issues regarding them. For example, if your theme has a woocommerce.php it would notify you it too!

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.