Woocommerce 中新订单的邮件中的商品能不能附上商品链接,方便客户点击查看。

Woocommerce 中新订单的邮件中的商品能不能附上商品链接,方便客户点击查看。


  • 该话题包含 4 个回复,2 人参与,最后由 大熊 更新于 5年 前
正在查看 5 个帖子:1-5 (共 5 个帖子)
  • 作者
    帖子
  • 大熊
    参与者
    • 文章数量: 19
    @qzxx
    楼主

    原来的代码是这样的。

    /*** @hooked WC_Emails::email_header() Output the email header*/do_action( 'woocommerce_email_header', $email_heading, $email ); ?><p><?php printf( __( '已收到你的订单,您的订单如下:', 'woocommerce' ), $order->get_formatted_billing_full_name() ); ?></p><?php/**

    有客户反馈,收到的邮件中产品名称只有商品名称,能不能附上商品链接,方便点击查看。

    诗语
    管理员
    • 文章数量: 5,866
    @feibisi

    试一下下面的代码

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

    添加到你的子主题的里。

    诗语
    管理员
    • 文章数量: 5,866
    @feibisi

    还有这一段也可以试试,哪个能用用哪个

    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>'; 
    }
    大熊
    参与者
    • 文章数量: 19
    @qzxx
    楼主

    谢谢您,这段测试了可以正常使用的,这样就方便多了,客户核对商品时,可以直接点击进去查看了。

    大熊
    参与者
    • 文章数量: 19
    @qzxx
    楼主

    这两个代码,全试了,全可以正常使用的。

正在查看 5 个帖子:1-5 (共 5 个帖子)
  • 哎呀,回复话题必需登录。

未找到对应子版块?请直接在 [疑难杂症] 版块中发帖提问。

收藏纪念品


有奖活动

参与论坛社区问答,有机会获赠文派瓦普(Wapuu.com)手办模型。

话题信息

商业系统