Hi,
The problem is, that the function for a shipping calculation is only the one and it is compiled to the
dll file so you have to overload it with your own
CalculateShipping method, in which you can check what kind of shipping your user chose or you can get also the shipping charge of that shipping and multiply it according to the total weight. Here are two approaches, how to use custom ecommerce providers:
1)
http://devnet.kentico.com/docs/5_5r2/ecommerceguide/index.html?using_custom_providers.htm2) If you are using Kentico CMS version 5.5 or higher, you can apply following approach:
- Copy all
.cs files from the Kentico installation folder ->
C:\Program Files\KenticoCMS\5.5R2\CodeSamples\CustomECommerceProvider to your project into the
~\App_Code\ECP\ directory
- Open
web.config file and add two new keys into it:
<add key="CMSUseCustomEcommerceProviders" value="true" />
<add key="CMSCustomEcommerceProviderAssembly" value="App_Code" />
- Open the
CMSCustom.cs file in the
~\App_Code\Global\CMS\ directory and please update the
GetCustomClass function with the code below:
public static object GetCustomClass(string className)
{
// Provide your custom classes
switch (className)
{
// Custom E-commerce provider
case "App_Code.CustomAddressInfoProvider":
return new CMS.CustomECommerceProvider.CustomAddressInfoProvider();
case "App_Code.CustomCreditEventInfoProvider":
return new CMS.CustomECommerceProvider.CustomCreditEventInfoProvider();
case "App_Code.CustomCurrencyInfoProvider":
return new CMS.CustomECommerceProvider.CustomCurrencyInfoProvider();
case "App_Code.CustomCustomerInfoProvider":
return new CMS.CustomECommerceProvider.CustomCustomerInfoProvider();
case "App_Code.CustomDepartmentInfoProvider":
return new CMS.CustomECommerceProvider.CustomDepartmentInfoProvider();
case "App_Code.CustomDiscountCouponInfoProvider":
return new CMS.CustomECommerceProvider.CustomDiscountCouponInfoProvider();
case "App_Code.CustomDiscountLevelInfoProvider":
return new CMS.CustomECommerceProvider.CustomDiscountLevelInfoProvider();
case "App_Code.CustomExchangeRateInfoProvider":
return new CMS.CustomECommerceProvider.CustomExchangeRateInfoProvider();
case "App_Code.CustomExchangeTableInfoProvider":
return new CMS.CustomECommerceProvider.CustomExchangeTableInfoProvider();
case "App_Code.CustomInternalStatusInfoProvider":
return new CMS.CustomECommerceProvider.CustomInternalStatusInfoProvider();
case "App_Code.CustomManufacturerInfoProvider":
return new CMS.CustomECommerceProvider.CustomManufacturerInfoProvider();
case "App_Code.CustomOptionCategoryInfoProvider":
return new CMS.CustomECommerceProvider.CustomOptionCategoryInfoProvider();
case "App_Code.CustomOrderInfoProvider":
return new CMS.CustomECommerceProvider.CustomOrderInfoProvider();
case "App_Code.CustomOrderItemInfoProvider":
return new CMS.CustomECommerceProvider.CustomOrderItemInfoProvider();
case "App_Code.CustomOrderStatusInfoProvider":
return new CMS.CustomECommerceProvider.CustomOrderStatusInfoProvider();
case "App_Code.CustomOrderStatusUserInfoProvider":
return new CMS.CustomECommerceProvider.CustomOrderStatusUserInfoProvider();
case "App_Code.CustomPaymentOptionInfoProvider":
return new CMS.CustomECommerceProvider.CustomPaymentOptionInfoProvider();
case "App_Code.CustomPublicStatusInfoProvider":
return new CMS.CustomECommerceProvider.CustomPublicStatusInfoProvider();
case "App_Code.CustomShippingOptionInfoProvider":
return new CMS.CustomECommerceProvider.CustomShippingOptionInfoProvider();
case "App_Code.CustomShoppingCartInfoProvider":
return new CMS.CustomECommerceProvider.CustomShoppingCartInfoProvider();
case "App_Code.CustomShoppingCartItemInfoProvider":
return new CMS.CustomECommerceProvider.CustomShoppingCartItemInfoProvider();
case "App_Code.CustomSKUInfoProvider":
return new CMS.CustomECommerceProvider.CustomSKUInfoProvider();
case "App_Code.CustomSupplierInfoProvider":
return new CMS.CustomECommerceProvider.CustomSupplierInfoProvider();
case "App_Code.CustomTaxClassInfoProvider":
return new CMS.CustomECommerceProvider.CustomTaxClassInfoProvider();
case "App_Code.CustomVolumeDiscountInfoProvider":
return new CMS.CustomECommerceProvider.CustomVolumeDiscountInfoProvider();
}
return null;
}
Now you might be able to write your own
CalculateShipping function in the
CustomShippingOptionInfoProvider.cs file.
JH