I have found a solution but i am not sure how good it is
1) Copy the shortcode into your functions.php
If you copy the function from the above link to Woocommerce Docs and create a your own shortcode (it_related_products_function) with it and then add 'class' => ''
to the arguments you can now pass ‘class’ to your shortcode.
function it_related_products_function( $atts ) {
if ( isset( $atts['per_page'] ) ) {
$atts['limit'] = $atts['per_page'];
}
$atts = shortcode_atts( array(
'limit' => '4',
'columns' => '4',
'orderby' => 'rand',
'class' => '',
), $atts, 'related_products' );
ob_start();
$atts['posts_per_page'] = absint( $atts['limit'] );
woocommerce_related_products( $atts );
return ob_get_clean();
}
2) Grab the attribute in your related.php
and echo if is set
<section class="woocommerce columns-4 <?php echo !empty($class) ? $class : "" ?>">
3) Now you can use your custom shortcode with ‘class’ anywhere
<?php echo do_shortcode('[it_related_products limit="4" class="row it-books-fp red-border-bottom"]'); ?>