質問

Can anyone tell me how do I bold this highlighted text "Product name" from notification message.

Note: Message comes from .csv file. Image blow

役に立ちましたか?

解決

I have the exact same business requirement. It is not possible to add html tags in translation csv file but you may enter specific unique character in csv file for specific message. So I add jQuery code to do this work, I know it is not the best practice but it worked for me. As there is no answer yet against this question so I share what I did.

First you have to add unique specific characters (strong) and (/strong) in your theme translation csv file and string variable between those specific characters like

You added %1 to your shopping cart.","You added (strong)%1(/strong) to your shopping cart.

Then Add this jQuery code in your JS file

jQuery(document).ajaxStop(function() {
    var notificationMessage = jQuery.trim(jQuery("#maincontent.page-main.container > .messages .messages").find( "div:eq(1)" ).text());
    if(notificationMessage != ""){
        setTimeout(function () {
            var strong = jQuery('#maincontent.page-main.container > .messages .messages:contains("(strong)")').html();
            if(typeof strong !== 'undefined'){
                strong = strong .replace("(strong)", "<strong>");
                strong = jQuery.trim(strong.replace("(/strong)", "</strong>"));
            }
            jQuery('#maincontent.page-main.container > .messages .messages:contains("(strong)")').html(strong);
        }, 200);
    }
});

I hope this will help

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top