Frankly not a very useful answer from the woocommerce support. Fortunately I found the solution here: https://stackoverflow.com/questions/49242740/woocommerce-external-affiliate-product-image-and-title-to-external-link-new-t?rq=1
I also added rel=”nofollow” in the code. So in total, the code I added to functions.php of the theme was (remember to create child theme):
remove_action(‘woocommerce_before_shop_loop_item’, ‘woocommerce_template_loop_product_link_open’);
add_action(‘woocommerce_before_shop_loop_item_title’, ‘woocommerce_template_loop_product_link_open’, 15);
add_action(‘woocommerce_before_shop_loop_item’, ‘woocommerce_add_aff_link_open’, 10);
add_action(‘woocommerce_before_shop_loop_item_title’, ‘woocommerce_add_aff_link_close’, 10);
function woocommerce_add_aff_link_open(){
$product = wc_get_product(get_the_ID());
if( $product->is_type( ‘external’ ) ) {
echo ‘get_product_url() . ‘” class=””>’;
}
}
function woocommerce_add_aff_link_close(){
$product = wc_get_product(get_the_ID());
if( $product->is_type( ‘external’ ) ) {
echo ‘‘;
}
}
function woocommerce_template_loop_product_link_open() {
global $product;
if( $product->is_type( ‘external’ ) ) {
$link = apply_filters( ‘woocommerce_loop_product_link’, $product->get_product_url(), $product );
echo ‘‘;
} else {
$link = apply_filters( ‘woocommerce_loop_product_link’, get_the_permalink(), $product );
echo ‘‘;
}
}