### NopCommerce web.config Example
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/description-of-the-web-config-file-in-project.md
This is a typical web.config file for a fresh installation of nopCommerce, illustrating various configuration settings for the web server.
```xml
```
--------------------------------
### Install Nginx
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/installation-and-upgrading/installing-nopcommerce/installing-on-linux.md
Install the Nginx web server package.
```bash
sudo apt-get install nginx
```
--------------------------------
### Start nopCommerce Service
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/installation-and-upgrading/installing-nopcommerce/installing-on-linux.md
Starts the nopCommerce systemd service, making the application accessible.
```bash
sudo systemctl start nopCommerce.service
```
--------------------------------
### Install libgdiplus on Debian/Ubuntu
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/installation-and-upgrading/installing-nopcommerce/installing-on-linux.md
Install the libgdiplus library to resolve image loading issues with GDI+ on Linux systems using apt-get.
```bash
sudo apt-get install libgdiplus
```
--------------------------------
### List Installed .NET Runtimes
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/installation-and-upgrading/installing-nopcommerce/installing-on-linux.md
Verify installed .NET Core runtimes on your system.
```bash
dotnet --list-runtimes
```
--------------------------------
### Install MySQL Server
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/installation-and-upgrading/installing-nopcommerce/installing-on-linux.md
Install MySQL Server version 8.0.
```bash
sudo apt-get install mysql-server-8.0
```
--------------------------------
### Install .NET Core Runtime
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/installation-and-upgrading/installing-nopcommerce/installing-on-linux.md
Update package lists and install the ASP.NET Core runtime version 9.0.
```bash
sudo apt-get update
sudo apt-get install -y aspnetcore-runtime-9.0
```
--------------------------------
### SQL Server Connection String Example
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/appsettings-json-file.md
Example of a connection string for SQL Server. Ensure to replace placeholders with your actual database credentials and server details.
```powershell
Data Source={localhost};Initial Catalog={your_data_base_name}};Integrated Security=False;Persist Security Info=False;User ID={your_user_id}};Password={your_password}};
Trust Server Certificate=True
```
--------------------------------
### Start and Check Nginx Service
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/installation-and-upgrading/installing-nopcommerce/installing-on-linux.md
Start the Nginx service and check its status.
```bash
sudo systemctl start nginx
```
```bash
sudo systemctl status nginx
```
--------------------------------
### InstallAsync Method Signature
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/description-of-plugin-system.md
This method is executed upon plugin installation. It's typically used for initializing settings, locales, and other necessary infrastructure for the plugin.
```cs
Task InstallAsync();
```
--------------------------------
### Install Flutter Dependencies
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/mobile-app/index.md
Run this command in the terminal to download the necessary libraries for the Flutter project.
```bash
flutter pub get
```
--------------------------------
### Create Runtime Directories
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/installation-and-upgrading/installing-nopcommerce/installing-on-linux.md
Creates essential subdirectories 'bin' and 'logs' within the nopCommerce installation for runtime operations.
```bash
sudo mkdir bin
sudo mkdir logs
```
--------------------------------
### InstallAsync Method
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/description-of-plugin-system.md
This asynchronous method is executed when the plugin is installed. It typically handles the initialization of settings, locales, and other necessary infrastructure for the plugin's correct configuration.
```APIDOC
### Method `InstallAsync`
```cs
Task InstallAsync();
```
The method is executed when the plugin is installed, this logic usually implements the initialization of settings, locales, and other infrastructure for the correct configuration of the plugin.
```
--------------------------------
### Download and Unpack nopCommerce
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/installation-and-upgrading/installing-nopcommerce/installing-on-linux.md
Downloads the nopCommerce release zip file and unpacks it into the designated directory. Requires unzip to be installed.
```bash
cd /var/www/nopCommerce
sudo wget https://github.com/nopSolutions/nopCommerce/releases/download/release-4.90.4/nopCommerce_4.90.4_NoSource_linux_x64.zip
sudo apt-get install unzip
sudo unzip nopCommerce_4.90.4_NoSource_linux_x64.zip
```
--------------------------------
### Implement InstallAsync for Widget Plugin
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/plugins/how-to-write-widget-for-nopCommerce.md
Override this method to include custom logic during plugin installation, such as adding settings, locale resources, or database tables.
```csharp
public override async Task InstallAsync()
{
// custom logic like adding settings, locale resources, and database table(s) here
await base.InstallAsync();
}
```
--------------------------------
### Configure Plugin Services for Dependency Injection
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/plugins/plugin-with-data-access.md
Register scoped services for your plugin. This setup is part of the application startup configuration.
```csharp
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Nop.Core.Infrastructure;
using Nop.Plugin.Other.ProductViewTracker.Services;
namespace Nop.Plugin.Other.ProductViewTracker.Infrastructure
///
/// Represents object for the configuring services on application startup
///
public class NopStartup : INopStartup
{
///
/// Add and configure any of the middleware
///
/// Collection of service descriptors
/// Configuration of the application
public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.AddScoped();
}
///
/// Configure the using of added middleware
///
/// Builder for configuring an application's request pipeline
public void Configure(IApplicationBuilder application)
{
}
///
/// Gets order of this startup configuration implementation
///
public int Order => 3000;
}
```
--------------------------------
### Initialize IScheduleTaskService Instance
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/unit-tests.md
The SetUp method, marked with OneTimeSetUp, is called once before all tests in the fixture. It initializes the IScheduleTaskService instance using GetService, which is essential for performing tests.
```csharp
private IScheduleTaskService _scheduleTaskService;
[OneTimeSetUp]
public void SetUp()
{
_scheduleTaskService = GetService();
}
```
--------------------------------
### Create a NopCommerce Plugin Class
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/guide-to-expanding-the-functionality-of-the-basic-functions-of-nop-commerce-through-a-plugin.md
Inherit from BasePlugin and override InstallAsync and UninstallAsync to add custom logic during plugin installation and uninstallation. This class serves as the foundation for your NopCommerce plugin.
```csharp
public class HelloWorldPlugin: BasePlugin
{
public override async Task InstallAsync()
{
//Logic during installation goes here...
await base.InstallAsync();
}
public override async Task UninstallAsync()
{
//Logic during uninstallation goes here...
await base.UninstallAsync();
}
}
```
--------------------------------
### Request Token using cURL
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/web-api/index.md
This example demonstrates how to use cURL to send a POST request to the token endpoint with the required credentials and content type.
```bash
curl -X 'POST' \
'http://localhost:15536/api-backend/Authenticate/GetToken' \
-H 'accept: application/json' \
-H 'Content-Type: application/json-patch+json' \
-d '{
"username": "admin@yourstore.com",
"email": "admin@yourstore.com",
"password": "123456"
}'
```
--------------------------------
### Registering a Plugin Route
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/register-new-routes.md
Implement the IRouteProvider interface to register custom routes for your plugin. This example shows how to map a specific route to a controller action.
```csharp
///
/// Represents plugin route provider
///
public class RouteProvider : IRouteProvider
{
///
/// Register routes
///
/// Route builder
public void RegisterRoutes(IEndpointRouteBuilder endpointRouteBuilder)
{
endpointRouteBuilder.MapControllerRoute(PayPalCommerceDefaults.ConfigurationRouteName,
"Admin/PayPalCommerce/Configure",
new { controller = "PayPalCommerce", action = "Configure" });
}
///
/// Gets a priority of route provider
///
public int Priority => 0;
}
```
--------------------------------
### Initialize ScheduleTask Instance for Testing
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/unit-tests.md
This updated SetUp method initializes both the IScheduleTaskService and a ScheduleTask instance. The ScheduleTask instance is pre-configured with sample data to be used across various tests.
```csharp
private IScheduleTaskService _scheduleTaskService;
private ScheduleTask _task;
[OneTimeSetUp]
public void SetUp()
{
_scheduleTaskService = GetService();
_task = new ScheduleTask { Enabled = true, Name = "Test task", Seconds = 60, Type = "nop.test.task" };
}
```
--------------------------------
### Visual Studio Code Launch Settings Profile
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/instruction-on-how-to-start-developing-on-nopcommerce.md
Specifies the launch profile to use when starting the nopCommerce project in Visual Studio Code. Ensure the profile commandName is 'Project'.
```json
"launchSettingsProfile": "Nop.Web",
```
--------------------------------
### PluginDescriptor Installed Property
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/description-of-plugin-system.md
This property verifies if a plugin is installed in the NopCommerce application.
```csharp
public virtual bool Installed { get; set; }
```
--------------------------------
### PreparePluginToUninstallAsync Method Signature
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/description-of-plugin-system.md
This method is invoked before the plugin is uninstalled. It can be used to implement pre-uninstallation logic, such as validating if other plugins depend on the current one.
```cs
Task PreparePluginToUninstallAsync()
```
--------------------------------
### Install Custom Permission in Plugin
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/permissions.md
Call the InstallPermissionsAsync method of the IPermissionService during plugin installation to register the custom permission.
```csharp
//add permission
await _permissionService.InstallPermissionsAsync(new WebApiBackendPermissionProvider());
```
--------------------------------
### PreparePluginToUninstallAsync Method
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/description-of-plugin-system.md
This asynchronous method is invoked before the plugin is uninstalled. It allows for logic to validate the uninstallation process, such as checking for dependencies from other plugins.
```APIDOC
### Method `PreparePluginToUninstallAsync`
```cs
Task PreparePluginToUninstallAsync()
```
This method will be invoked when we click the `UninstallAsync` button for the plugin. Code inside this method will be executed before the nopCommerce uninstalls the plugin from the system. In this method, we may want to write the logic to validate our plugin for uninstallation. For example, here we can check if there are other plugins which are depending on the plugin we are trying to uninstall. If so we may not want users to uninstall the plugin until the plugin depending on the current plugin is uninstalled.
```
--------------------------------
### PluginDescriptor ReferencedAssembly Property
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/description-of-plugin-system.md
Gets or sets the shadow-copied assembly that is active in the application.
```csharp
public virtual Assembly ReferencedAssembly { get; set; }
```
--------------------------------
### Create nopCommerce Directory
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/installation-and-upgrading/installing-nopcommerce/installing-on-linux.md
Creates the necessary directory to host the nopCommerce application files on the server.
```bash
sudo mkdir /var/www/nopCommerce
```
--------------------------------
### plugin.json for FixedOrByCountryStateZip Plugin
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/plugins/plugin.json.md
Example plugin.json for the FixedOrByCountryStateZip plugin, used for tax rate configuration.
```json
{
"Group": "Tax providers",
"FriendlyName": "Manual (Fixed or By Country/State/Zip)",
"SystemName": "Tax.FixedOrByCountryStateZip",
"Version": "4.70.1",
"SupportedVersions": [ "4.70" ],
"Author": "nopCommerce team",
"DisplayOrder": 1,
"FileName": "Nop.Plugin.Tax.FixedOrByCountryStateZip.dll",
"Description": "This plugin allow to configure fix tax rates or tax rates by countries, states and zip codes"
}
```
--------------------------------
### PluginDescriptor OriginalAssemblyFile Property
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/description-of-plugin-system.md
Used to get or set the original assembly file from which a shadow copy was made.
```csharp
public virtual string OriginalAssemblyFile { get; set; }
```
--------------------------------
### Visual Studio Code Server Ready Action Configuration
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/instruction-on-how-to-start-developing-on-nopcommerce.md
Configures the action to take when the server is ready, allowing for custom URI formatting to disable SSL. The pattern matches the 'Now listening on:' output.
```json
"serverReadyAction": {
"action": "openExternally",
"pattern": "\bNow listening on:\s+http://\S+:([0-9]+)",
"uriFormat": "http://localhost:%s"
}
```
--------------------------------
### Registering Services with INopStartup
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/inversion-of-control.md
Implement the INopStartup interface to register services within your nopCommerce application. The ConfigureServices method receives an IServiceCollection for adding dependencies. Use the Order property to manage the registration sequence and override existing dependencies.
```csharp
public class NopStartup : INopStartup
{
public virtual void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.AddScoped();
...
}
public void Configure(IApplicationBuilder application)
{
}
public int Order => 2000;
}
```
--------------------------------
### PluginDescriptor PluginType Property
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/description-of-plugin-system.md
Used to get or set the type of the plugin, referencing the class that implements the IPlugin interface.
```csharp
public virtual Type PluginType { get; set; }
```
--------------------------------
### Chrome CSP Violation Message
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/csp-headers.md
Example of a Content Security Policy violation message observed in Chrome developer tools.
```js
Refused to load the script 'script-uri' because it violates the following Content Security Policy directive: "your CSP directive".
```
--------------------------------
### Initialize Database with Migrations
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/update-existing-entity.md
This C# code snippet demonstrates how to initialize the database by applying all pending UP migrations using the IMigrationManager. This is typically called during the database initialization process.
```csharp
public virtual void InitializeDatabase()
{
var migrationManager = EngineContext.CurrenResolve();
migrationManager.ApplyUpMigrations(typeof(NopDbStartup).Assembly);
}
```
--------------------------------
### Get Widget Zones for Rendering
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/plugins/how-to-write-widget-for-nopCommerce.md
Specifies the public widget zones where the widget should be rendered. This method is part of the IWidgetPlugin interface.
```csharp
public Task> GetWidgetZonesAsync()
{
return Task.FromResult>(new List {PublicWidgetZones.HeadHtmlTag });
}
```
--------------------------------
### Add .NET Repository
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/installation-and-upgrading/installing-nopcommerce/installing-on-linux.md
Add the .NET backports package repository to your system.
```bash
sudo add-apt-repository ppa:dotnet/backports
```
--------------------------------
### Override InstallAsync Method in Plugin
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/plugins/how-to-write-plugin-4.90.md
Implement this method to add custom logic during plugin installation. Ensure you call the base implementation.
```csharp
public override async Task InstallAsync()
{
await _settingService.SaveSettingAsync(new PayPalStandardPaymentSettings
{
UseSandbox = true
});
await _localizationService.AddOrUpdateLocaleResourceAsync(new Dictionary
{
...
});
await base.InstallAsync();
}
```
--------------------------------
### plugin.json for Google Analytics Widget Plugin
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/plugins/plugin.json.md
Example plugin.json for the Google Analytics widget plugin, used for integrating with Google Analytics.
```json
{
"Group": "Widgets",
"FriendlyName": "Google Analytics",
"SystemName": "Widgets.GoogleAnalytics",
"Version": "4.70.1",
"SupportedVersions": [ "4.70" ],
"Author": "nopCommerce team, Nicolas Muniere",
"DisplayOrder": 1,
"FileName": "Nop.Plugin.Widgets.GoogleAnalytics.dll",
"Description": "This plugin integrates with Google Analytics. It keeps track of statistics about the visitors and ecommerce conversion on your website"
}
```
--------------------------------
### Restart Nginx Server
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/installation-and-upgrading/installing-nopcommerce/installing-on-linux.md
Restarts the Nginx web server to apply any configuration changes or to ensure it is running correctly after nopCommerce setup.
```bash
sudo systemctl restart nginx
```
--------------------------------
### Enable UseHttpXForwardedProto Setting
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/getting-started/advanced-configuration/how-to-install-and-configure-ssl-certificates.md
Add this setting to your appsettings.json file and restart the website to potentially fix issues related to missing HTTP_X_FORWARDED_PROTO headers.
```json
"UseHttpXForwardedProto": true
```
--------------------------------
### Register Custom Services with DI
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/guide-to-creating-a-page-containing-a-reporting-table-of-datatables.md
Implement the INopStartup interface to register custom services in the dependency injection container. This is done within the ConfigureServices method.
```csharp
///
/// Represents object for the configuring services on application startup
///
public class PluginNopStartup : INopStartup
{
///
/// Add and configure any of the middleware
///
/// Collection of service descriptors
/// Configuration of the application
public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
//register custom services
services.AddScoped();
}
///
/// Configure the using of added middleware
///
/// Builder for configuring an application's request pipeline
public void Configure(IApplicationBuilder application)
{
}
///
/// Gets order of this startup configuration implementation
///
public int Order => 3000;
}
```
--------------------------------
### Example Meta Keywords Tag
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/running-your-store/catalog/categories.md
This HTML snippet illustrates the structure of a meta keywords tag, used to list important themes for a webpage.
```html
```
--------------------------------
### Starter CSP Policy
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/csp-headers.md
A foundational CSP policy that allows images, scripts, AJAX, and CSS from the same origin. It restricts other resource types.
```html
default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self'; style-src 'self';
```
--------------------------------
### Get and Set Individual Settings
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/settings.md
Use GetSettingByKeyAsync and SetSettingAsync from ISettingService to load and save individual settings. Ensure ISettingService is available in your scope.
```csharp
var setting = await GetSettingByKeyAsync(key);
...
await _settingService.SetSettingAsync(key, value);
```
--------------------------------
### PluginDescriptor Property Signature
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/description-of-plugin-system.md
This property is used to get or set plugin descriptor information. The 'plugin.json' file is used by nopCommerce to initialize this property.
```cs
PluginDescriptor PluginDescriptor{ get; set; }
```
--------------------------------
### Configure .csproj for nopCommerce Plugin
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/guide-to-expanding-the-functionality-of-the-basic-functions-of-nop-commerce-through-a-plugin.md
Replace the content of your plugin's .csproj file with this configuration. It sets up build outputs, target framework, and references necessary for nopCommerce plugins. Ensure you replace '{PLUGIN_OUTPUT_DIRECTORY}' with your actual plugin project name.
```xml
net9.0
SOME_COPYRIGHT
YOUR_COMPANY
SOME_AUTHORS
PACKAGE_LICENSE_URL
PACKAGE_PROJECT_URL
REPOSITORY_URL
Git
$(SolutionDir)\Presentation\Nop.Web\Plugins\{PLUGIN_OUTPUT_DIRECTORY}
$(OutputPath)
false
enable
```
--------------------------------
### List Docker Images
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/developer/tutorials/docker.md
Displays a list of all Docker images available on the local system, including the newly built nopcommerce image.
```bash
docker images
```
--------------------------------
### Example Meta Description Tag
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/running-your-store/catalog/categories.md
This HTML snippet demonstrates the format of a meta description tag, providing a concise summary of the page's content.
```html
```
--------------------------------
### Example Meta Title Tag
Source: https://github.com/nopsolutions/nopcommerce-docs/blob/master/en/running-your-store/catalog/categories.md
This HTML snippet shows how a meta title tag is structured within the head section of a webpage for SEO purposes.
```html
Creating Title Tags for Search Engine Optimization & Web Usability
```