php – How to change WooCommerce loop product title HTML output in single product page and archive page

I’m currently working on designing my custom WooCommerce theme and wondering how I could change the HTML output of loop_product_title in single product page and in archive pages.

I have less knowledge of functions but I made this content but it did not work. I just want the loop product title to have element and in archives pages to have .

if ( is_product() ){
function woocommerce_template_loop_product_title() {
echo '<h2 class="product-title">' . get_the_title() . '</h3>';
}
elseif ( is_shop() ){
function woocommerce_template_loop_product_title() {
echo '<span class="product-title">' . get_the_title() . '</span>';
}
}
}

Please someone help me out. I have tried the best of what I could.