Hi there!
Thanks for contacting us!
I understand you would like to style variable product pages with CSS.
If you are looking to style elements within the product information area – you could use the CSS class – product-type-variable
If you’d like to style any element on the variable product page – You can try adding the snippet below in your theme’s functions.php file.
add_filter( 'body_class', function ( $classes ) {
if ( ! is_admin() && is_product() ) {
global $post;
$product = wc_get_product( $post->ID );
$cssclass = 'my_class_'.$product->get_type();
return array_merge( $classes, array( $cssclass ) );
}
else{
return $classes;
}
});
This would add a CSS class called my_class_variable
to <body>
element of variable products. The code also works for any other product type.
I hope this helps! 🙂
I went with the snippet and it worked. Thanks so much
Hey @mnahmed,
I’m happy to hear that you’ve got this sorted now.
I’ll go ahead and mark this thread as resolved.
Take care and have an amazing weekend ahead.