0

I have a customer order email with this hook

do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );

In this hook we have the email-downloads content which gets loaded first and then the email-order-details. I need to get the email-order-details first and the downloads below but can't for the life of me figure it out.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
Remco
  • 361
  • 2
  • 18

1 Answers1

2

If you look to WC_Emails constructor function you will see those 2 related code lines:

add_action( 'woocommerce_email_order_details', array( $this, 'order_downloads' ), 10, 4 );
add_action( 'woocommerce_email_order_details', array( $this, 'order_details' ), 10, 4 );

Based on that code, the following hooked function will set the display of the order downloads section after the order details:

add_action( 'woocommerce_email_order_details', 'wc_email_order_details_action_callback', 1 );
function wc_email_order_details_action_callback() {

    remove_action( 'woocommerce_email_order_details', array( WC()->mailer, 'order_downloads' ), 10 );

    add_action( 'woocommerce_email_order_details', array( WC()->mailer, 'order_downloads' ), 11, 4 );
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399