In WooCommerce, the product links in order details currently lead to the product edit page instead of the product page in the webshop. I tried adding some code to fix this and using
$product_link = $product ? get_permalink( $product->get_id() ) : '';
but it doesn’t work and it also duplicates the product title on the order details form.
Related question:
Change product url in woocommerce order detail
add_action( 'woocommerce_before_order_itemmeta', 'custom_order_item_product_link', 10, 3 );
function custom_order_item_product_link( $item_id, $item, $product ) {
if ( ! is_a( $product, 'WC_Product' ) ) {
return;
}
$product_link = $product->is_visible() ? $product->get_permalink() : '';
if ( $product_link ) {
printf( '<a href="%s">%s</a>', esc_url( $product_link ), esc_html( $product->get_name() ) );
} else {
echo esc_html( $product->get_name() );
}
}