I'm trying to add a dynamic placeholder {tipo_ordine}
to the subject on WooCommerce email notifications.
I tried Additional placeholders for Woocommerce email notifications subject with ACF answer code, making some minor changes to it:
add_filter( 'woocommerce_email_format_string', 'add_custom_email_format_string', 10, 2 );
function add_custom_email_format_string( $string, $email ) {
// HERE the ACF slug to be used to get the value
$meta_key = 'tipo_ordine';
// Get the instance of the WC_Order object
$order = $email->object;
// Get ACF value (with the correct Order ID)
$value = get_field( $meta_key, $order->get_id() );
// Additional subject placeholder
$new_placeholders = array( '{tipo_ordine}' => $value );
// Get the clean replacement value string for "{tipo_ordine}" placeholder
return str_replace( array_keys( $additional_placeholders ), array_values( $additional_placeholders ), $string );
}
But It doesn't work. What I am doing wrong?