Home > other >  How to change "Billing details" title to a title with html tags on WooCommerce checkout pa
How to change "Billing details" title to a title with html tags on WooCommerce checkout pa

Time:04-11

I am trying to change "Billing details" title on the checkout page with a hook, i want the title to contain HTML tags like : img and div tags.

this is what i tried, it change the title but consider the html tags as regular text.

function filter_gettext( $translated, $original_text, $domain ) {   
    // Is admin
    if ( is_admin() ) return $translated;
    
    // No match
    if ( $original_text != 'Billing details' ) return $translated;
    
    // Match
    $translated = '<div>123</div>';
    
    return $translated;
}
add_filter( 'gettext', 'filter_gettext', 10, 3 );

expected output is : 123

CodePudding user response:

add_filter('esc_html', 'billing_details_title', 10, 2);

function billing_details_title($safe_text, $text) {

    if ('Billing details' === $text && is_checkout()) {
        return '<div>123</div>';
    }
    return $safe_text;
}

enter image description here

  • Related