。
我正在尝试使用此代码在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
动作钩子。
代码进入函数.php活动子主题(或主题(的文件或任何插件文件中。
此代码经过测试,适用于WooCommerce版本2.6.x和3.0 +