I want rating from customers by sending mail after order is completed. If customer will click link on mail for review it should redirect to same current product page of my site.

How do I do this. I override woocommerce/emails in my child theme. I have customized customer-completed-order.php

<div class="rating">
    <h2> Please Rate this product and review. </h2>
    <a href="http://animax.cf/product/happy-ninja/#reviews">
        <img src="http://animax.cf/wp-content/uploads/2015/12/product-reviews.png" alt="Product Rating">

WooCommerce default customer-complete-order.php email template does not link the order item to corresponding product. You need to use woocommerce_order_item_name filter and update the item name to have link. I just tried below code and it adds the link to order item (product name). Put this code in functions.php file of your theme. Hope this helps:

add_filter('woocommerce_order_item_name', 'woo_order_item_with_link', 10, 3);
function woo_order_item_with_link( $item_name, $item, $bool ) {
    $url = get_permalink( $item['product_id'] ) ;
    return '<a href="'. $url .'">'. $item_name .'</a>'; 
| improve this answer | |
  • how do i insert that product link into <a> tag of above code. – Ans Jan 2 '16 at 12:02
  • Customer complete order email will contain order items which will be added dynamically. You need to use the code I provided as it is. The $url variable applies the link to each item in order email. – Prasad Nevase Jan 2 '16 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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