Hi,
I had 3 Single Layouts for products. Each Layout has custom design depending on the product category .
Now since i started to modify some elements in each Layout, each product regardless the category is showing now only one single layout design ignoring the function i have got from the support theme a while ago.. you can find it here: https://toolset.com/forums/topic/different-single-layout-templates-of-product-woocommerce-depending-on-category/
function assign_layout_by_post_status( $id, $layout ){
if(!is_singular('/product')) return $id; // add this line
global $product;
$product_cats = get_the_terms( $product->get_id(), 'product_cat');
if(is_array($product_cats)){
foreach($product_cats as $k=>$v):
if($v->slug == 'rentalcarcat'){
$id = 8670;
}else if($v->slug == 'usedcarcat'){
$id = 8674;
}
endforeach;
}
return $id;
}
add_filter('get_layout_id_for_render', 'assign_layout_by_post_status', 10, 2);
Could you please let me know if this function is not working anymore? or do you have any alternative solution for this?
Thanks
My issue is resolved now. Thank you!