Shipping service provider

Version: 10.3

Service providers are wrapper objects designed to make it easier to interact with Connect pipelines. The providers implement no logic other than calling Connect pipelines. All of the business logic is implemented in the pipeline processors.

For each method in the provider there is a corresponding Request and Result object used, for example, GetCarts takes a GetCartsRequest object and returns a GetCartsResult object. In some cases the response objects are re-used when returning the same data.

Customized versions of the default request and result arguments can be used by calling the overloaded generics-based versions of the methods.

The shipping service provider contains the following methods for interacting with payment data.

GetShippingOptions method

The GetShippingOptions method is used to query shipping option data against the external commerce system and returns a collection of shipping options.

Name:

GetShippingOptions

Description:

Gets the shipping options for a cart. Calls the GetShippingOptions pipeline.

Usage:

Called when a list of shipping options is needed.

Examples include:

  • Getting all available shipping options.

  • Getting the shipping options for the contents of a user’s cart.

Signature:

GetShippingOptionsResult GetShippingOptions(GetShippingOptionsRequest request)

Input:

Cart – Optional. Figure out the shipping options available for a specific cart.

Output:

ReadOnlyCollection<ShippingOptions> – A collection of shipping options for the requested scenario.

ReadOnlyCollection<LineShippingOption> - The shipping options available for different line items in the cart.

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var shippingService = new ShippingServiceProvider();
var request = new GetShippingOptionsRequest();
var result = shippingService.GetShippingOptions(request);

GetShippingMethod method

TheGetShippingMethod method is used to get the full details for a shipping method from the ECS.

Name:

GetShippingtMethod

Description:

Gets the full details for a shipping method that match the specified criteria. Calls the GetShippingMethodpipeline.

Usage:

Called when the full details of a shipping method are needed.

Signature:

GetShippingMethodResult GetShippingMethod(GetShippingMethodRequest request)

Input:

ShopNameOptional – The name of the current shop.

ExternalIdMandatory – The ID of the shipping method in the ECS.

Output:

ShippingMethod – The requested shipping method.

ShippingMethodPerItem -

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var provider = (ShippingServiceProvider)Factory.CreateObject("shippingServiceProvider", true);
var request = new GetShippingMethodRequest("Next Day");
var result = provider.GetShippingMethod(request);

GetShippingMethods method

The GetShippingMethods method is used to query shipping data against the external commerce system to retrieve all of the shipping methods for a particular payment option.

Name:

GetShippingMethods

Description:

Gets the shipping methods that match the specified criteria. Calls the GetShippingMethods pipeline.

Usage:

Called when a list of shipping methods is needed.

Examples include:

  • Getting the shipping methods for a particular shipping option.

  • Getting the shipping methods for a particular shipping option and party.

Signature:

GetShippingMethodsResult GetShippingMethods(GetShippingMethodsRequest request)

Input:

ShippingOption – The shipping option to retrieve shipping methods for.

Party – Optional – Limit the options based on a party.

Output:

ReadOnlyCollection<ShippingMethod> – A collection of shipping methods for the requested option.

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var shippingService = new ShippingServiceProvider();
var shippingOption = new ShippingOption
{
    Description = "Super Fast Shipping", 
    Name = "SuperFast", 
    ShippingOptionType = new ShippingOptionType(1, "Courier"), 
    ShopName = "webShop"
};
var request = new GetShippingMethodsRequest(shippingOption);
var result = shippingService.GetShippingMethods(request);

GetPricesForShipments method

The GetPricesForShipments method is used to get a list of possible shipping prices for all items in a cart.

Name:

GetPricesForShipments

Description:

Gets the shipping costs that match the specified criteria. Calls the GetPricesForShipments pipeline.

Usage:

Called when a list of shipping costs is needed.

Signature:

GetPricesForShipmentsResult GetPricesForShipments(GetPricesForShipmentsRequest request)

Input:

ShopName - MandatoryThe name of the current shop.

ShippingLookup – Mandatory – The combination of shipping method and options to look up.

Cart – Mandatory – The cart containing the line items to look up.

Output:

ReadOnlyCollection<ShippingPrice> – A collection of shipping prices mapped to items in the cart.

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var shippingLookupList = new List<ShippingLookup>
{
    new ShippingLookup
    {
        LineItemIds = new List<string> { "1", "2" }.AsReadOnly()
    }
};
var cartProvider = (CartServiceProvider)Factory.CreateObject("cartServiceProvider", true);
var cartRequest = new LoadCartRequest("StarterKit", "cartid");
var cartResult = cartProvider.LoadCart(cartRequest);
var cart = cartResult.Cart;
var provider = (ShippingServiceProvider)Factory.CreateObject("shippingServiceProvider", true);
var request = new GetPricesForShipmentsRequest("StarterKit", shippingLookupList, cart);
var result = provider.GetPricesForShipments(request);
if (result.Success && result.ShippingPrices != null)
{
    foreach (var shippingPrice in result.ShippingPrices)
    {
        // handle shipping prices
    }
}

Do you have some feedback for us?

If you have suggestions for improving this article,