Install the custom shipping carrier provider

Before installing your provider, build your project and make sure there are no errors. It is important to build first, because your new provider class must be successfully compiled into the project. If your provider is in a separate assembly, first add a reference to that assembly in your Sitefinity CMS application project.

To install the provider you must perform the following:

  1. Log in to Sitefinity CMS backend.
  2. In the main menu in the upper part of the screen, click Administration » Settings.
  3. Go to the Advanced settings by clicking the Advanced link.
  4. In the treeview on the left, click Shipping » ShippingCarrierProviders.
  5. To add a new shipping carrier provider, click Create New.
  6. Populate the fields of the provider.
    At minimum you must populate the Name, Title, Code and ProviderType fields. The ProviderType field must be populated with the CLR type of your custom shipping provider’s class. Be sure to check the “IsActive” checkbox so that your provider will be called when customers request shipping rates.
    The fields Url, Timeout, Username, Password, LicenseKey, MeterId, ClassificationCode and AccountNumber are provided to you in case you need this information to call an external shipping service from within your custom provider. Currently these are the only fields available to your custom provider. You may re-purpose the fields for your own use as needed. For example, your provider requires field data called “AccountID”. You can populate this data in the AccountNumber, the MeterId, or the LicenseKey field and access the data in your provider class. If you need more data than the number of fields allow, consider concatenating multiple data items into one field with a delimiter and then parsing the data values in your provider class.
    You can use the Username and Password field values as credentials for accessing your provider. Validating the request against these credentials and not returning shipping data results is a reasonable step in protecting your site against invalid external requests to your provider.
  7. Click Save changes.

Your shipping carrier provider is now registered in the Ecommerce provider.

Troubleshooting

In your storefront, put a product in your shopping cart and navigate to the Checkout “Shipping options” page. Your custom provider’s shipping rates should now be presented to the customer. If your shipping rates are not visible, run your project in Debug mode and put a breakpoint on the first line of your CustomShippingProvider.GetServiceRates method. If the breakpoint is not reached, make sure:

  1. Your custom provider’s IsActive setting is true (checked).
  2. The ProviderType value is correct (i.e. is the full path, assembly.namespace.classname). If you put your custom provider code in a separate project, make sure the assembly is copied to the Sitefinity CMS bin folder and that a reference is added to it in the project.

If your breakpoint is reached then check the following:

  1. Step through the code and look for any runtime errors that are causing your code to terminate abnormally.
  2. Check that you have retrieved the correct carrier settings.
  3. Check the shippingData parameter and make sure it contains the expected values (including the cart items in the shippingData.CartOrder.Details).
  4. It may be possible that the shippingData.CartOrder.Details object is empty if you left the cart for a long period of time and the cart has timed out (generally around 20 minutes). If this is the case, add new products to the cart and hit the shipping options page again.

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

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to 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?