Create a custom shipping provider field

Create the template

Create a SampleSettingsField.ascx file and add the following markup:

The SampleSettingsField.ascx file contains the markup for the properties displayed to a user who is configuring your shipping provider in the Shipping method area.  The sample SampleSettingsField.ascx file has the following default fields:

 Field Description 
 serviceSettings   Checkbox list which defines what kind of services does the current provider offer
 url  Url where the shipping providers web service is located
 password  apssword for the provider
 license key  License key parameter (if needed by the provider). Please note that this is not mandatory for all providers. We are just providing an example implementation
 Service name  Name of the service that is in the chackbox list of the provider service settings
 Service code  Unique code of the service that is supposed to be saved for the card order
 Service description  Description for the service
 Service surchange
Service weight
Sort order
 Additional fields that may be used by the service. Please note that you can change these to whatever needs you have

Create the class

Create SampleSettingsField.cs class that inherits FieldControl and add the following code:

Create the client component

Add SampleSettingsField.js file and add the following content:

In the code above the javascript validates the controls and sends Sitefinity CMS rhe serialized data that has to be saved in the database. The code also controls the popup that is displayed for each service in the shipping provider.

You need to change the SampleSettingsField.ascx and SampleSettingsField.js files to be Embedded Resources. In your Visual Studio solution, in the cintext menu of  the file, click PropertiesChange the Build Action property to Embedded Resource.

If you add or remove any fields from the markup file, you will need to modify the code behind file SampleSettingsField.cs and the JavaScript file SampleSettingsField.js.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?