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 Properties. Change 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
.