• I just wanted to share my method for adding custom placeholders. This does not work for the Subtitle Text field since it isn’t hookable but will work for the Body Text of non-order and order emails, as well as the Additional Content field.

    add_filter( 'kadence_woomail_no_order_body_text', 'custom_woomail_no_order_body_text', 10, 2 );
    function custom_woomail_no_order_body_text( $body_text, $email ) {
        if ( is_a( $email->object, 'WP_User' ) ) {
            $body_text = str_replace( '{customer_email}',  $email->object->user_email, $body_text );
        }
        return $body_text;
    }
    
    add_filter( 'kadence_woomail_order_body_text', 'custom_woomail_order_body_text', 10, 5 );
    function custom_woomail_order_body_text( $body_text, $order, $sent_to_admin, $plain_text, $email ) {
        if ( is_a( $order, 'WC_Order' ) ) {
            $body_text = str_replace( '{custom_field}',  $order->get_meta('custom_field'), $body_text );
        }
        return $body_text;
    }
    
    add_filter( 'woocommerce_email_format_string', 'custom_add_extra_placeholders', 21, 2 );
    function custom_add_extra_placeholders( $string, $email ){
        if ( is_a( $email->object, 'WC_Order' ) ) {
            $string = str_replace( '{custom_field}',  $email->object->get_meta('custom_field'), $string );
        }
        return $string;
    }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Example of how to add custom placeholders’ is closed to new replies.