0
votes

The solution provided in the link below no longer works:

Using a custom single product template for a specific product category in Woocommerce

I have worked through the diagnositic steps adumbrated by LOIC.

I added a copy of the single-product.php file to the woocommerce folder in my child theme.

When I checked the Woo status page it confirms that that page is overwriting the woo template.

I created a new product and assigned it the category: Custom (with the slug: custom).

I placed the following code in my functions.php:

add_filter( 'template_include', 'custom_single_product_template_include', 50, 1 );
function custom_single_product_template_include( $template ) {
    if ( is_singular('product') && (has_term( 'custom', 'product_cat')) ) {
        $template = get_stylesheet_directory() . '/woocommerce/single-product-custom.php';
    } 
    return $template;
}

I edited out the hooks from a copy of the single-product.php and renamed it: single-product-custom.php and put it in the woocommerce folder in my child theme.

Cleared all site caching and my browser history.

However, the test product is still displaying the default single product page.

Where I am going wrong and where do I go from here?

1
could you first test with only one condition? if ( is_singular('product') ) {Shir Gans
Hey. Yes check problem still there. Just to be sure, the file I have in woocoommerce folder in my child theme should be a copy (customized version) of the woo single-product.php template and not a copy of the content-single-product.php template. Is that correct?khunmax

1 Answers

0
votes

Problem resolved. Note: if you are seeking to use this solution there a couple of posts here with conflicting information. The solution above does work. The file to be placed in your theme folder is single-product woo template (with your custom title) not the content-single-product template as suggested in some other posts on this subject. Also take care to note Loic's advice: If you are using a child theme. You create a woocommerce folder in your CT and then place the copy file in there. Do not place it inside a templates subfolder (as is the case in the Woo Plugin file structure).