Creating a nopCommerce Plugin in version 3.90 and below

I recently worked with a client using an older version of nopCommerce that needed to have a plugin made for functionality. In particular, this plugin integrates with updown.io to allow for turning checks on and off during scheduled maintenance.

To do this, you’ll need to have the nopCommerce source code available for use.

Creating the Plugin

To get started, create a Class Library in the Plugins folder:

  • Make sure to change the location to the plugin folder below the name.
  • Use naming convention Nop.Plugin.{category}.{name}
  • The categories you can use include:
    • ExternalAuth
    • Widgets
    • ExchangeRate
    • DiscountRules
    • Payments
    • Shipping
    • Tax
    • Misc

Next, go into properties and make sure your Target framework is .NET Framework 4,.5.1.

Next, change the output path for all configurations to deploy to:

..\..\Presentation\Nop.Web\Plugins\{group}.{name}\

This will build the output of the plugin into the Web project, which will ultimately deploy to the nopCommerce application.

After that, copy a web.config file from another plugin.

Next, create a Description.txt file with the following content:

Group: {group}
FriendlyName: {friendly name}
SystemName: {group}.{name}
Version: 0.1
SupportedVersions: {your version of nopCommerce}
Author: {you}
DisplayOrder: 1
FileName: Nop.Plugin.{group}.{name}.dll
Description: {a description}

Set both the web.config and Description.txt files to ‘Copy if newer’.

Finally, there is a Class.cs file that was created when creating the Class Library. Rename the file to {name}Plugin.cs and use the following code snippet:

public class YourPlugin : BasePlugin, IMiscPlugin
    {
        public void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues)
        {
            actionName = "Configure";
            controllerName = "Your";
            routeValues = new RouteValueDictionary()
            {
                { "Namespaces", "Nop.Plugin.Misc.Your.Controllers" },
                { "area", "" }
            };
        }
    }

Once this is done, you should be able to clean, build, and publish the project. Check the plugins list of the admin backend to see your plugin listed:

Just to ensure everything is working, go ahead and install the plugin. The plugin should install successfully, and the plugin will then be running on your site. You’re now ready to make changes to the plugin to modify NopCommerce capabilities.

Next Steps

After the initial plugin was created, next steps include:

  • Creating a logo named logo.png and upload it to the plugin. Set the image to ‘Copy if newer’ and size the image to around 50×50.
  • Set up a configuration page to allow for customizing data on the plugin (notice that for now, clicking on ‘Configure’ if applicable will crash the site.)

Reference: 
http://docs.nopcommerce.com/pages/viewpage.action?pageId=22675509

Leave a Reply

Your email address will not be published. Required fields are marked *