7

I want to add the product link in the Processing Order email which User receives when order. When an order is placed an Order Email sent, I want to get the product link there when user clicks redirects to the detail product page when clicked. Is there any way, I get the product link or the Product Title would Hyperlink.

THANKS

4 Answers 4

12

The answer from gunbunnysoulja works great but needs two little updates:

  • get_product needs to be wc_get_product
  • $_product->id needs to be $_product->get_id()

The updated answer is as follows:

add_filter( 'woocommerce_order_item_name', 'display_product_title_as_link', 10, 2 );
function display_product_title_as_link( $item_name, $item ) {

    $_product = wc_get_product( $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );

    $link = get_permalink( $_product->get_id() );

    return '<a href="'. $link .'"  rel="nofollow">'. $item_name .'</a>';
}
1
  • 2
    this worked like a charm! Thank you so much for taking time to jump in and share this!!
    – jord8on
    Oct 4, 2020 at 5:57
5

I am currently using this solution, which I found in the comments on another page. This is not my code.

http://www.vanbodevelops.com/tutorials/add-a-link-back-to-the-order-in-woocommerce-new-order-notifications-email#comment-636

add_filter( 'woocommerce_order_item_name', 'display_product_title_as_link', 10, 2 );
function display_product_title_as_link( $item_name, $item ) {

$_product = get_product( $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );

$link = get_permalink( $_product->id );

return '<a href="'. $link .'"  rel="nofollow">'. $item_name .'</a>';

}
1
  • For those interested, it goes in the functions.php file, not the email template. I'm wanting to make it share-able on facebook.
    – Jason
    Mar 3, 2015 at 20:03
1

To link a product name with its product page in your order emails, open the functions.php file of your child theme and add the following snippet of code:

* Product Links in WooCommerce Order Emails
*/

    add_filter('woocommerce_order_item_name', 'woocommerce_order_item_link', 10, 3);

    function woocommerce_order_item_link( $item_name, $item, $bool ) {
        $url = get_permalink( $item['product_id'] ) ;
        return '<a href="'. $url .'">'.$item_name .'</a>'; 
    }

0
0

I have been wondering how this works as well. There is little info available anywhere - at least not much with detailed step by step instructions.

The best solution I have came up with is to edit the customer-processing-order.php.

All I did was open it up in a text editor and added a few lines of text to:

"Your order has been received and is now being processed. Your order details are shown below for your reference. Please visit "http://www.youlinkurl".

The end user will have to copy and paste that link unfortunately but at least it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.