簡體   English   中英

在WooCommerce上添加圖片附近的圖片已完成訂單電子郵件通知

[英]Adding an image near the footer on WooCommerce completed orders email notification

我正在嘗試使用此代碼在WooCommerce完成訂單電子郵件通知中插入頁腳附近的圖像,但不幸的是它不起作用!

這是我正在嘗試的代碼:

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

請問任何線索?

謝謝

你最好在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>';
}

您也可以使用woocommerce_email_footer動作鈎子,它只有一個參數( $email參數)。

代碼放在活動子主題(或主題)的function.php文件中,或者放在任何插件文件中。

此代碼經過測試,適用於WooCommerce版本2.6.x和3.0+

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM