I have 2 custom email mailers setup as wc_shipped_order & wc_received_order and it works great. I have the trigger set so when the status of an order is changed to "shipped" it triggers the shipped order email mailer.
I'm trying to add a Tracking shipping code through another custom plugin via the action hook woocommerce_email_before_order_table with the following:
add_action( 'woocommerce_email_before_order_table', 'tracking_number_email', 10, 4 );
function tracking_number_email( $order, $sent_to_admin, $plain_text, $email ) {
if( 'wc_shipped_order_email' == $email->id ){
echo '<p><strong>'.__('Australia Post Tracking Number').': </strong>' . get_post_meta( $order->get_id(), 'tracking_number', true ) . '</p>';
}
}
However when I try and add an if statement to check if the mailer was wc_shipped_order, I get an error. The actual echo part works, but the IF statement is failing and throwing out this error:
Notice: Trying to get property 'id' of non-object in /var/www/wp-content/plugins/my-custom-functions/inc/php/functional.php(103) : eval()'d code on line 239
It has no idea what $email->id is and I've tried dumping that variables for $email but theres nothing there.
Can someone help me?