问题
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