To customize the shipping functionality of the Kentico E-commerce Solution, use the following approach
- Implement a custom shipping carrier provider.
- Register the carrier in the administration interface.
- Create shipping options that use the services of the custom carrier.
By creating a custom shipping carrier provider, you gain full control over the shipping costs and availability of the related shipping options. For example, you can:
- Calculate shipping costs based on variables, such as the country in the delivery address, the package weight, etc.
- Retrieve shipping costs using the external API of a shipping company (FedEx, USPS, Australia Post, etc.).
- Set conditions that determine exactly when shipping options are available (based on the properties of individual orders or any other variables).
If you wish to define custom discounts that apply to shipping costs, see Customizing discounts.
The E-commerce API uses the following additional interfaces to connect the functionality of shipping carrier providers with the overall shopping cart and order calculation logic (see Customizing the shopping cart calculation to learn more).
- IDeliveryBuilder – prepares the Delivery objects required by the GetPrice and CanDeliver methods of shipping carrier providers, based on shopping cart calculation data. When registering IDeliveryBuilder implementations using the RegisterImplementation assembly attribute, set the Lifestyle property to Lifestyle.Transient.
- IShippingPriceService – calculates the final shipping price for shopping carts or orders. The default IShippingPriceService implementation calculates the base shipping price using the IDeliveryBuilder and the shipping carrier provider of the order's shipping option, and then applies shipping discounts provided by the registered IShippingtDiscountSource.
Customization of these interfaces is not required or recommended in typical scenarios.