How to Add a Widget to a nopCommerce Plugin (Widget Zones Explained)

Plugin development 9 Updated

How to Add a Widget to a nopCommerce Plugin (Widget Zones Explained)

A code-first walkthrough of nopCommerce widget zones: implement IWidgetPlugin, pick a zone from PublicWidgetZones, render a view component and switch it on, checked against 5.00.1.

The PublicWidgetZones class in the nopCommerce 5.00.1 source on GitHub, beside the three names a widget plugin needs: IWidgetPlugin, PublicWidgetZones and NopViewComponent

Key takeaways

  • A widget plugin implements IWidgetPlugin: HideInWidgetList, GetWidgetZonesAsync and GetWidgetViewComponent.
  • Zones are strings. In nopCommerce 5.00.1 the PublicWidgetZones class lists 195 of them, so use its constants instead of typing names.
  • The zone points at a view component that derives from NopViewComponent and renders in InvokeAsync.
  • Enable the widget under Configuration → Widgets. A wrong zone name fails silently.

You have built a nopCommerce plugin, it installs, and it shows under Local Plugins. The banner or the product-page note it was meant to add is nowhere on the storefront. Installing a plugin does not render anything; rendering takes a second interface, IWidgetPlugin, and the exact name of a zone.

This guide picks up where plugin creation leaves off: the interface, choosing a zone, the view component that renders, and the admin step that switches it on. We checked every type and zone name against the nopCommerce 5.00.1 source on GitHub on 25 November 2026.

Key fact: nopCommerce does not throw an error for a zone name that does not exist. It simply never calls your component, so the zone string is the first thing to check.

What Is a Widget Zone, Exactly?

The checkout zone names in the PublicWidgetZones class of nopCommerce 5.00.1, such as checkout_confirm_top, with 195 public widget zones in total

A widget zone is a named slot that a Razor view exposes. The view asks nopCommerce for whatever widgets are active in that zone and renders them, without knowing which plugin they come from. Your plugin never edits a core view to appear on a page.

The public zone names live in one class, PublicWidgetZones, in the Nop.Web.Framework project. At release-5.00.1 it defines 195 of them, each a property that returns a string. A separate AdminWidgetZones class covers the admin area.

Group Examples from PublicWidgetZones
Catalog and contenthome_page_before_products, categorydetails_top, productdetails_before_pictures
Checkout and orderscheckout_confirm_top, checkout_payment_method_bottom, order_summary_totals
Layout, on every pageheader_after, footer, body_start_html_tag_after

Need a widget built and tested? BSS builds nopCommerce plugins and widgets for stores and agencies.

View nopCommerce services

The IWidgetPlugin Interface

The IWidgetPlugin interface in nopCommerce 5.00.1 with HideInWidgetList, GetWidgetZonesAsync and GetWidgetViewComponent, beside the Google Analytics widget returning its four zones

IWidgetPlugin lives in Nop.Services.Cms and extends IPlugin with three members. Once they are in place, nopCommerce handles enabling, disabling and rendering.

public class WidgetZoneDemoPlugin : BasePlugin, IWidgetPlugin
{
    // Hide it from Configuration → Widgets when the plugin has its own settings page
    public bool HideInWidgetList => false;

    public Task<IList<string>> GetWidgetZonesAsync()
    {
        return Task.FromResult<IList<string>>(new List<string>
        {
            PublicWidgetZones.ProductDetailsBeforePictures,
            PublicWidgetZones.CheckoutConfirmTop
        });
    }

    public Type GetWidgetViewComponent(string widgetZone)
    {
        return typeof(WidgetZoneDemoViewComponent);
    }
}

GetWidgetZonesAsync returns a list, so one plugin can render into several zones. GetWidgetViewComponent is called with the zone name, so different zones can point at different components. Using the PublicWidgetZones constants instead of typed strings catches a renamed zone at compile time.

The built-in Google Analytics widget in 5.00.1 does exactly this. It returns HeadHtmlTag, ProductDetailsTop, ProductBoxAddinfoAfter and Footer, and sets HideInWidgetList to false.

A widget hiding in a payment plugin

The PayPal Commerce plugin's main class implements both IPaymentMethod and IWidgetPlugin, with HideInWidgetList set to true, so owners configure it from Payment methods rather than the widget list.

Building the Widget: View Component and View

The GetWidgetViewComponent method of the nopCommerce Google Analytics widget, which returns its view component type for each of its zones

GetWidgetViewComponent must return a view component type, a class that derives from nopCommerce's NopViewComponent, not a controller action or a bare Razor view. The Google Analytics widget follows that pattern, with an InvokeAsync method that receives the zone and extra data.

public class WidgetZoneDemoViewComponent : NopViewComponent
{
    public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
    {
        var model = new WidgetZoneDemoModel { WidgetZone = widgetZone };
        return View("~/Plugins/Widgets.WidgetZoneDemo/Views/PublicInfo.cshtml", model);
    }
}

Both parameters are worth using. widgetZone is the name the page passed in, so one component can render differently per zone. additionalData is whatever model the host view passes, such as the product on a product page, or null where there is none.

Widget plugin build checklist

  • Look up the zone in PublicWidgetZones for the version you target.
  • Implement IWidgetPlugin on the plugin class, including HideInWidgetList.
  • Return the zone constants from GetWidgetZonesAsync.
  • Return a NopViewComponent subclass from GetWidgetViewComponent.
  • Write InvokeAsync and its Razor view.
  • Install the plugin, then enable it under Configuration → Widgets.

Choosing (and Verifying) the Right Zone

The top of the PublicWidgetZones class in nopCommerce 5.00.1, beside three real zone names: productdetails_before_pictures, checkout_confirm_top and home_page_before_products

A zone that is misspelled, renamed or missing from your version does not raise an error. Your component is simply never called. Take the name from the source of the version you target, not from an old forum thread.

Zone names usually describe the page and the position, such as productdetails_before_pictures or checkout_confirm_top. Open PublicWidgetZones.cs at the release tag you run and search for the page you want.

Approach What it involves Trade-off
Use the constantsReference PublicWidgetZones properties in codeA removed zone breaks the build, which is what you want
Read the sourceSearch PublicWidgetZones.cs at your release tagAccurate for that version; needs repeating after upgrades
Log zones in stagingA temporary widget that records every zone it is asked to renderShows which zones a page really renders, at the cost of an extra step
BSS plugin that saves the work
BSS Banner

If the widget you need is a promotional banner, this plugin lets store owners display banners for promotions, products or offers without new code.

From the BSS team

When we build widget plugins, we reference the PublicWidgetZones constants rather than typing zone names, so an upgrade that renames a zone shows up as a build error instead of a blank spot on the page. Our BSS Banner plugin is one we maintain this way.

Registering the Widget and Fixing a Missing One

The official nopCommerce Widgets documentation, which configures widgets under Configuration and Widgets, beside four checks for a widget that does not show

A widget that compiles and installs still does not render until it is switched on. The official documentation configures widgets under Configuration → Widgets: install the plugin if needed, then mark the widget active. The zones come from your plugin's code, so there is no zone picker to fill in.

When a widget does not show, four causes cover most cases.

Not installed or not active
Check Configuration → Widgets first. An inactive widget renders nowhere.
Wrong store
In a multi-store install, check the settings for the store you are testing, not only the default one.
A wrong zone name
Zone strings are not checked at run time. A typo means your component is never called.
Cached plugin data
After changing the zones of an installed plugin, restart the application or clear the cache before testing again.

Test in a private window, so cached pages in your browser cannot hide the change. For the plugin basics, our guide to creating a nopCommerce plugin covers the project, plugin.json and installation.

From the BSS team

If you would rather hand the plugin work to a team that already ships it, our nopCommerce services include custom plugins and widgets, tested on staging before they reach your store.

Frequently Asked Questions

What's the difference between a nopCommerce widget and a regular plugin?
Every widget is a plugin, but not every plugin is a widget. IPlugin gets a plugin installed and configured. IWidgetPlugin is the extra interface that lets a plugin render a view component into one or more widget zones.
Can one widget plugin render into more than one zone?
Yes. GetWidgetZonesAsync returns a list, and nopCommerce calls GetWidgetViewComponent for each zone with its name, so one plugin can map zones to different components or reuse one and branch on the zone.
Why isn't my widget showing up?
Usually one of four things: the widget is not installed and active under Configuration → Widgets, it is not set up for the store you are testing, the zone name is wrong, or the application is still using cached plugin data from before your change.
Do I need a separate view component for every zone?
No. The component receives the zone name in InvokeAsync, so one NopViewComponent can render a different view for each zone.
Where do I find the list of widget zone names?
In the PublicWidgetZones class of the nopCommerce source, in the Nop.Web.Framework project. At release 5.00.1 it lists 195 public zones; check it at the release tag you run, because names change between versions.

Final Thoughts

A missing widget rarely means nopCommerce is broken. One link in the chain is missing: the interface, the zone name, the view component or the admin switch.

Use the PublicWidgetZones constants, keep the component small, and switch it on under Configuration → Widgets. After the first widget, the next one is the same four steps.

MM

Written by Mahia Mosarrat

Software Engineer · Bangladesh Software Solution

Software Engineer at BSS in Dhaka, building nopCommerce plugins and themes with full-stack skills in C#, React and Angular.

Read nextPlugin development How to Create a Plugin in nopCommerce 4.80 12 min read