Order Complete email filtering

Hi,

I successfully filtered many of the default emails Hivepress sends, like Booking confirmed etc. Basically I create a shortcode with an addfilter and then paste the shortcode in the relevant empty Hivepress email template (in this example, Booking confirmed).

All of them work fine, except the order complete email. The code in the shortcode is very similar to all other shortcodes, but it always sends out an empty email with the subject defined in the Hivepress email template subject instead of the new one. An example of the code is

add_filter(
	'hivepress/v1/emails/Order_Complete',
	function( $email ) {
        if ( !isset($email['tokens']['order_number']) ) {
			return $email;
		}
		
		$order = wc_get_order( $email['tokens']['order_number'] );

		if ( !$order ) {
			return $email;
		}
        [...some more well tested code...]
         
    $email['subject'] = 'My new subject';
	$email['body'] = 'My new body';
    return $email;
}
);

You can assume that it’s not a coding mistake, since it’s basically a copy of other working snippets, and I thoroughly checked.

Something is preventing the shortcode to execute. I tried with even simpler code, like only returning a changed body with no extra code, but nothing works.

Any help? Basically I wanted to use the Order Complete email into a “Request a review” email, changing the recipient, subject and body.

Thank you

Hi,

Hooks are case-sensitive, please try hivepress/v1/emails/order_complete hook instead. You can add error_log at the beginning of the function to log something is the hook is fired and test it this way. Please also note that this email is sent to the vendor (not customer).

Hope this helps

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.