How to add content to top header in nopCommerce

We all have seen that many websites post some of the content like address, phone number and social media links etc on the top header. This design strategy is quite useful in presenting your information to the online users right away. 

Many online store sites like to post their contact information on the top header so that customer gets the access to the information from any page which is using the top header. This way, online customers do not have to spend time in search for contact or about us page.

You can use top header section for posting content like:
- Customer service phone number
- Store address
- Customer service email address
- Live chat button
- Social media links

Today, we will go over the process of adding content to top header in nopCommerce.

Go to: Views \ Shared \ Header.cshtml

nopcommerce header


Open "Header.cshtml" file and find this code:

<div class="header">
    @Html.Widget("header")
    <div class="header-upper">
        <div class="header-selectors-wrapper">
             
            @Html.Action("TaxTypeSelector", "Common")
             
            @Html.Action("CurrencySelector", "Common")
             
            @Html.Action("LanguageSelector", "Common")
             
            @Html.Widget("header_selectors")
        </div>
        <div class="header-links-wrapper">
            @Html.Action("HeaderLinks", "Common")
            @Html.Action("FlyoutShoppingCart", "ShoppingCart")
        </div>
    </div>
    <div class="header-lower">
        <div class="header-logo">
            <a href="@Url.RouteUrl("HomePage")">
                <img title="" alt="@storeName" src="@Url.Content(logoPath)">
            </a>
        </div>
        <div class="search-box store-search-box">
            @Html.Action("SearchBox", "Catalog")
        </div>
    </div>
</div>




You can adjust the position of the custom content as per your design requirements but in the example, we will post custom content at the very top of the header.

Let's try to add some text right "above" this:
<div class="header-links-wrapper">

So, the code should look something like this:

<div class="header">
    @Html.Widget("header")
    <div class="header-upper">
        <div class="header-selectors-wrapper">
             
            @Html.Action("TaxTypeSelector", "Common")
             
            @Html.Action("CurrencySelector", "Common")
             
            @Html.Action("LanguageSelector", "Common")
             
            @Html.Widget("header_selectors")
        </div>
 
        <!--START: Custom Text-->
        <div id="customheadercontent" style="font-size: 15px; color: #0B2F3A; float: left; height: 46px; line-height: 46px;">
            123 Street, City, State 11111 (Customer Service #: 000-000-0000 )
        </div>
        <!--END: Custom Text-->
        <div class="header-links-wrapper">
            @Html.Action("HeaderLinks", "Common")
            @Html.Action("FlyoutShoppingCart", "ShoppingCart")
        </div>
    </div>
    <div class="header-lower">
        <div class="header-logo">
            <a href="@Url.RouteUrl("HomePage")">
                <img title="" alt="@storeName" src="@Url.Content(logoPath)">
            </a>
        </div>
        <div class="search-box store-search-box">
            @Html.Action("SearchBox", "Catalog")
        </div>
    </div>
</div>



Make sure to save changed and go to public store to see your custom content on the top header like this:

nopcommerce top header

A copy of this article is also available on Arvixe Blog.

About Author

Written By Lavish Kumar

Based out of New York, USA, Lavish Kumar is a full stack web developer by profession and founder of Striving Programmers, a trusted community for developers that offers a wealth of articles and forums to assist individuals with improving their software development skills.

Leave your comment
Comments
2/12/2016 12:46 PM
what is the path to the css file that I can style that? I have successfully added that! Thank you so much!
2/12/2016 12:55 PM
I'm glad this article is helpful to you. The stylesheet of your website theme is in this location: Themes\YourThemeName\Content\styles.css

If you are using the default out of the box theme then the name of the theme will be "DefaultClean". Let me know if you have any question(s).
2/14/2016 8:02 AM
Got it. Thanks! Do you do paid custom work (css)? I'd like to change my menu look. and minor front page display. Thanks!
2/14/2016 8:29 AM
Yes, I do offer paid services for custom projects. if you have any custom work, please feel free to use contact page on the site to email me the requirements / details. Thanks!