admin管理员组

文章数量:1122832

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="">
        <img src=".png" alt="Product Rating">
    </a>
</div>

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">
    </a>
</div>
Share Improve this question edited Jan 1, 2016 at 19:23 Pieter Goosen 55.4k23 gold badges115 silver badges209 bronze badges asked Jan 1, 2016 at 12:27 AnsAns 4292 gold badges5 silver badges10 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 12

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>'; 
}

You can also try this:

    <a href="<?php get_permalink(get_the_id()); ?>">
      <img src="http://animax.cf/wp-content/uploads/2015/12/product-reviews.png" alt="Product Rating">/>
    </a>

本文标签: woocommerce offtopicGet product link