Thank you for contacting Telerik Support!
In the Ecommerce module there are shipping carriers, which expose shipping services, and shipping methods. The shipping carriers are third parties, like FedEx, UPS, etc. The shipping methods are created from the backend under Ecommerce -> Shipping methods.
To get the shipping methods that you have created in the backend, you can use the following code:
ShippingManager manager = ShippingManager.GetManager();
List<ShippingMethod> shippingMethods = manager.GetShippingMethods().Where(m => m.IsActive).ToList();
This code will return a list of all active shipping methods created by you under Ecommerce -> Shipping methods. You can iterate through them and find the one that corresponds to the desired country, weight, time frame, etc. The ShippingMethod
class exposes properties for the specifics of the method, like price, area, countries, etc. If you have any questions about working with the ShippingMethod
class and API, don't hesitate to ask.
If you want to get the rates of the carrier services of the shipping carriers that are suitable for the provided country, ZIP code and weight, you can use the following code:
ShippingManager shippingManager = ShippingManager.GetManager();
List<IShippingResponse> availableShippingServices =
//Get the shipping carriers and iterate through them.
Config.Get<ShippingConfig>().ShippingCarrierProviders.Values.Where(x => x.IsActive))
//Get an instance of the shipping carrier provider.
var carrierProvider = shippingManager.GetShippingCarrierProvider(shippingCarrier.Name);
//Get the shipping service that corresponds to the countries you want to ship between, and to the weight.
//The ShippingResponseContext contains the available services for the specified locations and weight.
//Note that you have to pass the appropriate country codes according to the shipping carriers. You can find them on the carriers' sites.
ShippingResponseContext shippingContext = carrierProvider.GetServiceRates(CreateShippingRequest(
//Each shipping response object has a property representing the rate of the service.
GenericShippingRequest request =
GenericShippingRequest(shipFromCountry, shipFromZip, shipToCountry, shipToZip, totalWeight);
In this case, the method will return all of the services of each carrier, that are suitable for the specified locations and weight. Note that this creation of the shipping request is just for the sample. You can implement it as it is most comfortable for you.
I hope that with these two code snippets I managed to cover you scenario. If not, please share more details on it. Any additional information will be much appreciated!
Thank you kindly in advance!
All the best,
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking
system and vote to affect the priority of the items