Hook a section into WooCommerce Emails with customer ID

 ̄綄美尐妖づ 提交于 2021-02-18 19:30:20

问题


I am keen to hook a section into the WooCommerce emails with the customer number (which is the Wordpress user ID).

If I insert the following code directly into the email template file

echo $order->user_id;

It works just fine, but if I try and hook it in, nothing is returned - except the word 'Hooked' which shows my hook is correct.

add_action( 'woocommerce_email_after_order_table', 'lnz_hook_content', 1);

function lnz_hook_content() {

echo 'hooked'; // Test Purposes only
echo $order->user_id;

Any thoughts? Replies much appreciated.


回答1:


Sorted it. Needed to add the parameter into my new function:

add_action( 'woocommerce_email_after_order_table', 'lnz_hook_content', 1);

function lnz_hook_content( $order) {

echo 'hooked'; // Test Purposes only
echo $order->user_id;


来源:https://stackoverflow.com/questions/44358666/hook-a-section-into-woocommerce-emails-with-customer-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!