NopCommerce – ASP.NET open source e-commerce solution

I had a chance to work for first time with nopCommerce about one year ago. Now again, two weeks ago I was in need to make small research about open-source asp.net e-commerce solutions.

I did the research and have found that there are several e-commerce open-source projects, the best ones (by my results) are already listed in eCommerce Windows Web App Gallery, and of course nopCommerce is number one most popular open source e-commerce project with most downloads and highest rating of five stars. That’s the general opinion, of course someone may agree or disagree with that…

By my own opinion, comparing with the nopCommerce version I have tested about one year ago (nopCommerce v1.50) the current version (nopCommerce v1.90) is much better even on first sight. The guys from nopCommerce has made very good job by changing and improving the entire architecture of the solution.

In order to remind myself about the remarks I had for v1.50, I have downloaded both versions, v1.50 and v1.90 (Its nice to see they keep history and download links from all versions). You can also see all the changes between versions here.

- INSTALLATION

1. Extract the downloaded nopCommerce v1.90 and open the solution with Visual Studio.NET 2010.

I have renamed the default nopCommerce_1.90_source to NopCommerceStore

2. Run the application either using Visual Studio.NET Web Development Server or you can host it directly on IIS (IIS 7.5 preferably)

3. Once you start the application, the following screen will appear

You should chose the right option for you. If you have already been working with nopCommerce, then you can upgrade directly from here. However, we will now show the installation step only.

Click NEXT

I’m using integrated Windows authentication. You can use SQL Server account, but make sure your account has rights to create databases.

Once you are done, click NEXT.

Now, I assume you don’t have other nopCommerce database, so we chose ‘Create a new database’ option here and write the database name. Also don’t forget to tick the ‘Create sample data’ so that you will have some data to test. Then click NEXT.

This will take few seconds and the following screen will appear

Write your email and password which you are going to use to access the Administration dashboard and click SAVE CHANGES. After that, once you see message ‘Admin account has been changed’ you can click ‘Go to site’.

Tip: Once you finished with installation, open the ConnectionStrings.config inside the NopCommerceStore web application. There you will see the connection string which was built using this installation wizard. If you want to reinstall the application, you can simply delete the connection string from ConnectionStrings.config and run the application again.

 


- NopCommerce Front-End and Administration Dashboard

Now, once you are done, the nopCommerce store should be up and running

Click at Log in in the top-right menu and log in with your email / password you have set in the fourth installation step.

Once you log in, you will be redirected to the home page (Default.aspx). Now again in the top-right menu click on ‘Administration’. The first time should take 10 – 15 seconds to enter the administration board, especially if you are running the application directly from VS.NET (not published in IIS). Once you open the Administration dashboard, you can start exploring it.

Mainly, the administrator features are divided into several main categories:

  1. Catalog – for managing the products, product categories, attributes and manufacturers
  2. Sales – for managing orders, recurring payments, current shopping carts and sales reports
  3. Customers – for managing customers, roles and have some statistical view of the e-shop customers
  4. Promotions – for managing discounts, affiliates, newsletter subscribers, prices etc.
  5. Content Management – global management for the CMS, such as polls, news, blog, topics etc.
  6. Configuration – Everything related to configurations. I’ve bolded this since I’m spending most of the time here (as a developer)
  7. System – logging, maintenance and global system information

Now, lets get back to the code


- Code Structure

NopCommerce v1.90 solutions includes 56 projects and the main solution structure is:


Dependencies

Libraries

These are the nopCommerce libraries used in all places within the project code.

Payment

For payment options, you have another solution folder with project for each payment method. If you want to add your own payment method which does not exists, you will need to create new project inside Payment solution folder.

PromotionProviders

Shipping

Tax

Web (NopCommerceStore)

 

- Analysis performed with NDepend

Let’s first attach NDepend to nopCommerce solution

Once you click OK, it may take sometime NDepend to get attached in the project since it will also run analysis (you see checked ‘Run Analysis Now!’).

Once it finishes, NDepend will automatically open page in web browser showing ‘NDepend Report’.

The report is quite big, so I will take first only the Application Metrics

Application Metrics
Number of IL instructions: 437436
Number of lines of code: 57424
Number of lines of comment: 92902
Percentage comment: 61
Number of assemblies: 56
Number of classes: 2377
Number of types: 2656
Number of abstract classes: 9
Number of interfaces: 63
Number of value types: 0
Number of exception classes: 1
Number of attribute classes: 0
Number of delegate classes: 164
Number of enumerations classes: 216
Number of generic type definitions: 48
Number of generic method definitions: 23
Percentage of public types: 85.43%
Percentage of public methods: 84.72%
Percentage of classes with at least one public field: 0.3%

These results should give you image of the complete nopCommerce solution. You can see the code is covered with 61% percent of comments, which is great for one open source project. The solution has in total 57424 lines of code, which is not so much for such a big solution, to be honest.


Dependency Graph

I couldn’t print screen the whole dependency graph, but the most interesting part is the one you see above. I would like to mention that nopCommerce solution is divided nicely, however if you want to get some part of it and reuse it in another project, that’s quite hard to do since many things are closely dependant. However, if you want to extend the solution with your own code, for example add new payment method, it’s quite easy since they have pretty nice abstract implementation of each layer.


Code Quality

With NDepend, you can do a lot other measurements and analysis, however I decided to check the code quality.

Finding Cyclomatic Complexity

CQL Query

SELECT METHODS WHERE
CyclomaticComplexity > 20
ORDER BY CyclomaticComplexity DESC

From total of 20173 methods tested there are 45 methods with cyclomatic complexity higher than 20 and only 16 methods with cyclomatic complexity higher than 30.

The most complex method with cyclomatic complexity of total 117 which is totally hard to maintain or modify and has to be (if possible) split in multiple methods is PlaceOrder(PaymentInfo, Customer, Guid, Int32&). The method has in total of 512 code lines.

Except this method and few other which are less complex, the rest of the code seems perfectly fine and very nicely structured following the coding standards.


Comments

To find the code comments percentage, we should run the following CQL

SELECT METHODS WHERE
PercentageComment > 0
ORDER BY PercentageComment ASC

So, with this we find all the methods where NDepend has found that the code has at least 1% of the code is commented (greater than 0). I must say that comparing to other open source projects, nopCommerce’s code is nicely commented.

- Modifying and Working with the code

Once you start reading the code, you will see that some parts of the code are intentionally made for you to be able to modify or add new additional features, but other parts are quite hard since these are much more dependant of the core solution features. For example, I had chance to test adding new payment method in nopCommerce. I started reading the current implementation of the 30+ payment methods:

Each payment method class that does the payment inherits from IPaymentMethod interface, which is implemented inside NopSolutions.NopCommerce.BusinessLogic.Payment.IPaymentMethod – interface for creating payment gateways.

IPaymentMethod - methods

IPaymentMethod – properties

All you need to do is to create new project inside Payment solution and a class that implements the IPaymentMethod interface. You can see the current implementations of the other payment methods for tips. Once you are finished, you have to register your new payment method from Administration dashboard –> Configuration –> Payment –> Payment Methods. Click Add New and fill the form. You should be careful when adding the Class Name. It should be the ‘namespace.class, projectName’

Example:

Payment –> Nop.Payment.Amazon has

namespace NopSolutions.NopCommerce.Payment.Methods.Amazon
{
    /// <summary>
    /// Represents an SimplePay payment gateway
    /// </summary>
    public class SimplePayPaymentProcessor : IPaymentMethod
    {

Therefore, the Class Name is: NopSolutions.NopCommerce.Payment.Methods.Amazon.SimplePayPaymentProcessor, Nop.Payment.Amazon

SimplePayPaymentProcessor is the class which implements the IPaymentMethod.

Configuration Template path and User Template Path are the paths of the web user controls for both of them respectively.

Configuration Templates are stored in NopCommerceStore(website)\Administration\Payment\PaymentMethodName\WebUserControl.ascx, for amazon –> Payment\Amazon\SimplePayConfig.ascx

User Templates are stored in NopCommerceStore(website)\Templates\Payment\PaymentMethodName\WebUserControl.ascx, for amazon –> ~\Templates\Payment\Amazon\SimplePayPayment.ascx

You can follow the examples to create your own and that’s it.

 

Conclusion
After the analysis and tests I made on nopCommerce, I would like to say that this is the best open source e-commerce solution for ASP.NET so far. I must say it works very fast when published and hosted on IIS web server. Moreover, on the nopCommerce site you can find many additional plug-ins, templates and other extensions which will help you create e-shop site in minutes.

I hope this blog post will encourage you to use this great open source solution, as well as to encourage even more the nopCommerce solution team to make it even better for the next releases!

I hope this was helpful blog post for you.

Regards,
Hajan

8 Comments

  • Hajan, very nice analysis, thanks for sharing. Apparently those guys did a great job to provide the community with such a rich
    Open source project.
    But we would love to see this project redeveloped in MVC 3.

    Thanks,

  • @George, we are sailing on a same boat! :) I'm also interested to see this in ASP.NET MVC 3... I even think that way the project will be more extensible.

    Thanks for your comments.

  • Yeah, nopCommerce is already moving to MVC. Other changes planned for the next release are repository layer, persistence-ignorant entities, code-first approach, a lot of unit tests, etc. Estimate release date - June-July 2011.

  • @nopsolutions, great... really great news! I'm eager to see nopCommerce implementation in ASP.NET MVC, as well as the changes you've mentioned in your comment. I'm looking forward to write more blog posts about nopCommerce in the future!

    Thank you for your comment.

  • NopCommerce is the best ecommerce and its free against dot net ecommerce but still some AJAX functionlities are needed to it as while checkin out that page it doesnt look very much effective and ad to cart option there is no need to go to cart to process directly instead of you may have alert message like some little javascript. and one more point the guest process its big and very much hectic to do sometime..!!

  • Thanks for providing this details..

  • I have some concerns with open source shopping cart software, regarding security issues that is why My opinion is to go for licensed softwares like bvCommerce, AbleCommerce or aspdotnetstorefront.

  • We have oracle application - can we integrate this with oracle application for inventory, payment etc.

Comments have been disabled for this content.