phpwordpresswoocommerce

Woocommerce not using the right templates


I'm having some template hierarchy issues trying to add woocommerce to a custom theme I made for a client. The site isn't using the templates it should be. The shop page the plugin generates is using 'page.php' instead of 'archive-product.php' and products are using 'single.php' instead of 'single-product.php'. I created a folder called woocommerce in my theme folder and copied those two WC template files over, but they're not being used. I used a function to force using the right templates, which worked but now the products don't appear on the shop page like they did when the wrong templates were being used. I've never worked with WC before, so is there something basic I've missed?

Things I've tried:


Solution

  • It's a custom theme, so first of all you should check if WooCommerce support is declared in the functions.php. Woocommerce Integration with theme can be done using declaration of support in the theme. Php code:

    function wpse319485_add_woocommerce_support() {
    add_theme_support( 'woocommerce' );
    }
    add_action( 'after_setup_theme', 'wpse319485_add_woocommerce_support' );
    

    link:https://github.com/woocommerce/woocommerce/wiki/Declaring-WooCommerce-support-in-themes