WordPress at a glance
function is not described

wc_fix_product_attachment_link() WC 1.0

Prevent product attachment links from breaking when using complex rewrite structures.

No Hooks.

Return

String. Nothing.

Usage

wc_fix_product_attachment_link( $link, $post_id );
$link(string) (required)
Link.
$post_id(int) (required)
Post ID.

Code of wc_fix_product_attachment_link() WC 5.2.2

<?php
function wc_fix_product_attachment_link( $link, $post_id ) {
	$parent_type = get_post_type( wp_get_post_parent_id( $post_id ) );
	if ( 'product' === $parent_type || 'product_variation' === $parent_type ) {
		$link = home_url( '/?attachment_id=' . $post_id );
	}
	return $link;
}