The person building a WP site for me is stuck for some time now with this problem. He needs to attach some custom PDF files into the order confirmation mail. He uses woocommerce_emails_attach_downloadables function to do that. For some reason that function is getting called with the $order parameter being empty.
Here is the code he uses :
add_filter( 'woocommerce_email_attachments', 'attach_order_notice', 10, 3 );
function attach_order_notice ( $attachments, $email_id, $order )
{
//
// Only for "New Order" email notification (for admin)
if( $email_id == 'customer_on_hold_order' ){
$pdf_options = array(
// "source_type" => 'html',
// "source" => '<html>hello</html>',
"source_type" => 'url',
"source" => 'http://tt.dev.co.il/checkout/order-received/757/?key=wc_order_5bce0e5ba39b8',
"action" => 'save',
"save_directory" => get_template_directory() .'/pdfs',
"file_name" => 'print-pdf'. json_encode($order) .'.pdf');
// phptopdf($pdf_options);
$attachments[] = get_template_directory() . '/pdfs/print-pdf.pdf';
}
return $attachments;
}
So my questions are:
What are those cases ?
What can cause $order to be passed as empty ?