Template for different category on woocommerce product [closed]

Woocommerce has it’s own function woocommerce_get_template_part() for loading template parts, use it like this:

woocommerce_get_template_part( $slug, $name );

which refers to the according file {$slug}-{$name}.php or used like this:

woocommerce_get_template_part( $slug );

refers to the file {$slug}.php, it automatically

Looks in yourtheme/slug(-name).php and yourtheme/woocommerce/slug(-name).php

it can be used with a conditional like this:

    if( has_term( 'shop', 'product_cat' ) ) {
        woocommerce_get_template_part( 'single-product-shop' );
    } else {
        woocommerce_get_template_part( 'content', 'single-product' );
    }

Leave a Comment