-
-
Save bekarice/8c688ee9aa39f9479abd1d31f13c3c75 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // only copy if needed | |
/** | |
* Link products to the product page within order emails. | |
* | |
* @param string $item_name the item name in the email | |
* @param \WC_Order_Item $item the order item | |
* @return string updated item name | |
*/ | |
function sww_wc_email_product_link( $item_name, $item ) { | |
$product = $item->get_product(); | |
$product_link = $product && $product->get_permalink( $item ) ? $product->get_permalink( $item ) : null; | |
// only make our changes if in an email context | |
if ( $product_link && did_action( 'woocommerce_email_order_details' ) > 0 ) { | |
$item_name = sprintf( '<a href="%s">%s</a>', $product_link, $item_name ); | |
} | |
return $item_name; | |
} | |
add_filter( 'woocommerce_order_item_name', 'sww_wc_email_product_link', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you ! It works !