【问题标题】:Adding an image near the footer on WooCommerce completed orders email notification在 WooCommerce 的页脚附近添加图像已完成订单电子邮件通知
【发布时间】:2017-05-19 10:23:01
【问题描述】:

我正在尝试使用此代码在 WooCommerce 完成订单电子邮件通知的页脚附近插入图像,但不幸的是它不起作用!

这是我正在尝试的代码:

    <?php
    echo ("Hello");
    ?>
    <div>
        <img src="myPic.jpg" alt="myPic" />
    </div>

请问有什么线索吗?

谢谢

【问题讨论】:

    标签: php wordpress woocommerce orders email-notifications


    【解决方案1】:

    您最好在 woocommerce_email_customer_details 动作挂钩中使用自定义挂钩函数,例如,这样:

    add_action( 'woocommerce_email_customer_details', 'custom_image_near_email_footer' , 50, 4);
    function custom_image_near_email_footer( $order, $sent_to_admin, $plain_text, $email ) {    
        // For customer order notification with "completed" status
        if ( 'customer_completed_order' == $email->id ) 
            echo '<div style="text-align:center;">
                <img src="'.home_url( "wp-content/uploads/2017/05/myPic.jpg" ).'" alt="myPic"/>
            </div>';
    }
    

    您也可以使用只有一个参数($email 参数)的 woocommerce_email_footer 动作挂钩。

    代码进入您的活动子主题(或主题)的 function.php 文件或任何插件文件中。

    此代码经过测试,可在 WooCommerce 2.6.x 和 3.0+ 版本上运行

    【讨论】:

    • 我刚刚尝试了您的代码,它再次像魅力一样工作。非常感谢先生
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-12
    • 1970-01-01
    • 2018-05-26
    相关资源
    最近更新 更多