Search
RSS

Blog

Comments (0) Settings in nopCommerce

General rules for using settings in nopCommerce are as follows:

1. If you have a single store (so you don't use a multistore feature), you can always inject settings by DI.
2. If you use a multistore feature, then getting settings depends on the place of use:

a) you can still inject settings by DI in any code that is called by a user request (controller actions, factory methods, service methods, some code on views, etc.), they will be injected for the current store (for which the request is executed);
b) when configuring a plugin or settings in the admin area, you should load the settings for the selected store ID to override them for this store;
c) in any code that is called by third-party and not by user actions (for example, schedule tasks, webhook notifications from third-party services, etc.), getting settings should be considered case-by-case:

i) You can inject settings, but get ready that they will be injected for the store for which the webhook was registered, or from which the whole application was started (usually the first one from the list) in the case of schedule tasks.
ii) You can somehow get the store ID (e.g. from a query string in case of webhooks) and load the settings according to this ID.
iii) You can load all the settings, and then use them separately for each store (suitable for tasks with synchronization).

So in our Brevo plugin we use few approaches at the same time:
2-a in the view component, since this code is called by the user;
2-b in the plugin configuration;
2-c-iii in the schedule task since this is a synchronization task.

If you are developing your own plugin or customizing the solution, follow the rules above.

Comments (0) Upgrade a Version

Depending on the system, configuration and access there are different ways people like to upgrade.
The way I do it is to create a new installation in a new directory for v4.7.
Then I run the Install to create a a test database.
This allows you to check the install is all working before making any changes to the configuration.
Once you have checked everything is working in this test mode, take a copy of the newly create .json files in case you need to go back.
Then you can then you edit the .json files above to make any changes to the configuration and point the system to your existing database to do the upgrade.
You can then test everything is working with the production configuration
Then I install the plugins which should do their own upgrade of the database as required.

Also refer to Upgrading nopCommerce

Comments (0) Basic Setup for IIS

Installing nopCommerce and having issues ?

Here is a document which shows the basic Setup for IIS
You can download here https://www.selectsystems.com.au/Content/Server%20install%20IIS%20and%20SQL%20Server.pdf

Or check for errors on a New Installation Here
https://www.selectsystems.com.au/checking-for-errors-on-a-new-installation-of-nopcommerce

Comments (0) Custom View Engine
You can override the default _AddToCart.cshtml or one in another pluign using a Custom View Engine
Comments (0) Display a PDF from Jscipt Ajax Call

I searched for the answer for a while before I found this works

                $.ajax({
                    cache: false,
                    type: "POST",
                    url: "@Html.Raw(Url.Action("DailyReport"))?date=" + $('#EventStartDateTimeUtc').val() +
                        "&groupProductId=" + ddlGroupProductId + "&associatedProductId=" + ddlAssociatedProducts,
                    xhrFields: { responseType: "blob" },
                    success: function (data) {
                        var blob = new Blob([data]);
                        var link = document.createElement('a');
                        link.href = window.URL.createObjectURL(blob);
                        link.download = "Daily_Report_" + $('#EventStartDateTimeUtc').val() + ".pdf";
                        link.click();
                        var file = new File([blob], filename, { type: 'application/force-download' });
                        window.open(URL.createObjectURL(file));
                    },
                    error: function (error) {
                        alert("Error: " + error);
                    }
                });

Comments (0) Developing with Paypal

For Paypal Commerce Plugin I have setup Sandbox and can do transactions no problem.

But where do you see the transactions in Paypal when using the Sandbox like you would in your Buinsess Dashboard ?
What is the link ?

One option is lookign at notifications See https://developer.paypal.com/developer/notifications

Notifications only show the emails sent to the buyer and don't contain full transaction details, though they can be used as a confirmation of successful payments without visiting a sandbox account.

The other option is using Sandbox.

The link is https://www.sandbox.paypal.com, this sandbox test site mirrors the features on the PayPal production servers.

You can create an individual test account, or use the ones automatically created for a developer account (https://developer.paypal.com/dashboard/accounts).
You have to set up a sandbox in the plugin configuration and pay with the above test account during the checkout. Transactions will be shown on the sandbox test site (https://www.sandbox.paypal.com/activities/), just like for a Business account.


 

Comments (0) Testing/debugging multi-store on Localhost
You can create New Local use Domains in the Local DNS
Comments (0) nopCommerce Plugin Development Manual
This guide covers various aspects, best practices and approaches for nopCommerce plugin development. Plugin is a software component enabling nopCommerce basic features extension. There is an official nopCommerce plugin marketplace distributing both free and paid plugins. Plugins enable developers to add new features and/or customize a UI theme without modifying nopCommerce source code. This is important for stable running of a web application and for upgrading nopCommerce platform to newer versions.
Comments (0) Architecture of nopCommerce

nopCommerce is a highly customizable and flexible, multi-store, multi-vendor, SEO friendly, full featured open-source E-Commerce solution. Which is build on top of Microsoft ASP.NET Core framework. nopCommerce is always up to date with latest technology and follows best practices.

See Architecture of nopCommerce

Comments (0) Calling a Partial View of Nop.Web from Plugin Custom View Engine

One of the nice feature of the .NetCore framework is its pluggability. This means you can completely replace the default view engine(s) with a custom one.

One of the reason for using a custom view engine is to change the default views location and sometimes you need to change the views location at run-time. To do this you can extend the default view engine(s) and then change the default views location variables at run-time. 

Here is an example when the default Checkout Views are replaced with Partial Views loaded from a Payment Plugin 

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Mvc.Razor;

using Nop.Core;
using Nop.Core.Data;
using Nop.Core.Infrastructure;
using Nop.Services.Plugins;
using Nop.Services.Configuration;

using Nop.Web.Framework.Themes;

namespace Nop.Plugin.Pluign.Name.ViewEngine
{
    public class CustomViewEngine : IViewLocationExpander
    {

        public string storeTheme = "DefaultClean";

        public void PopulateValues(ViewLocationExpanderContext context)
        {
            if (context.AreaName?.Equals("Admin") ?? false)
                return;

            var settingService = EngineContext.Current.Resolve<ISettingService>();
            var storeContext = EngineContext.Current.Resolve<IStoreContext>();

            storeTheme = settingService.GetSettingByKey("storeinformationsettings.defaultstoretheme", "DefaultClean", storeContext.CurrentStore.Id, true);

            var themeContext = (IThemeContext)context.ActionContext.HttpContext.RequestServices.GetService(typeof(IThemeContext));
            context.Values[storeTheme] = themeContext.WorkingThemeName;
        }

        public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations)
        {

            //Confirm database is installed
            if (DataSettingsManager.DatabaseIsInstalled)
            {
                var pluginService = EngineContext.Current.Resolve<IPluginService>();

                var plugin = pluginService.GetPluginDescriptorBySystemName<IPlugin>("Plugin.Name", LoadPluginsMode.InstalledOnly);
                if (plugin != null)
                {
                    if (plugin.SystemName == "Plugin.Name")
                    {
                        if (context.AreaName == "Admin")
                        {

                        }
                        else
                        {
                            if (!context.Values.TryGetValue(storeTheme, out string theme))
                                return viewLocations;
                            if (context.ControllerName == "RealOnePageCheckout" && context.ViewName == "RealOnePageCheckout")
                            {
                                viewLocations = new[] { $"~/Plugins/Plugin.Name/Views/FrontView/RealOnePageCheckout.cshtml" }.Concat(viewLocations);
                            }
                            else if (context.ControllerName == "Checkout" && context.ViewName == "BillingAddress")
                            {
                                viewLocations = new[] { $"~/Plugins/Plugin.Name/Views/FrontView/BillingAddress.cshtml" }.Concat(viewLocations);
                            }
                            else if (context.ControllerName == "Checkout" && context.ViewName == "ShippingMethod")
                            {
                                viewLocations = new[] { $"~/Plugins/Plugin.Name/Views/FrontView/ShippingMethod.cshtml" }.Concat(viewLocations);
                            }
                            else if (context.ControllerName == "Checkout" && context.ViewName == "OpcShippingMethods")
                            {
                                viewLocations = new[] { $"~/Plugins/Plugin.Name/Views/FrontView/OpcShippingMethods.cshtml" }.Concat(viewLocations);
                            }
                            else if (context.ControllerName == "Checkout" && context.ViewName == "Completed")
                            {
                                viewLocations = new[] { $"~/Plugins/Plugin.Name/Views/FrontView/Completed.cshtml" }.Concat(viewLocations);
                            }
                        }
                    }
                }
            }

            return viewLocations;
        }
    }
}