【问题标题】:Adding a hyperlink to the WooCommerce email template向 WooCommerce 电子邮件模板添加超链接
【发布时间】:2019-11-23 08:44:26
【问题描述】:

我正在尝试将超链接添加到我刚刚添加到 Woocommerce 上的电子邮件模板中的产品图片缩略图。

这是我用来添加图片的php代码:

add_filter( 'woocommerce_email_order_items_args', 'iconic_email_order_items_args', 10, 1 );

function iconic_email_order_items_args( $args ) {

    $args['show_image'] = true;
    $args['image_size'] = array( 50, 50 );

    return $args;

现在我需要做的是使图像可点击,以便将用户重定向到产品页面。如果有更多经验的人提供任何建议,我将不胜感激。

谢谢,

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    要将产品链接添加到图像和项目名称中,请将此代码添加到functions.php

    add_filter( 'woocommerce_order_item_thumbnail', 'add_email_order_item_permalink', 10, 2 ); // Product image
    add_filter( 'woocommerce_order_item_name', 'add_email_order_item_permalink', 10, 2 ); // Product name
    function add_email_order_item_permalink( $output_html, $item, $bool = false ) {
        // Only email notifications
        if( is_wc_endpoint_url() )
            return $output_html;
    
        $product   = $item->get_product();
    
        return '<a href="'.esc_url( $product->get_permalink() ).'">' . $output_html . '</a>';
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-29
      • 2015-04-26
      • 1970-01-01
      • 2017-04-24
      • 1970-01-01
      • 2020-09-16
      • 2015-01-02
      • 2013-10-04
      相关资源
      最近更新 更多