Loading...
Area: Episerver Commerce
Applies to versions: 10 and higher
Other versions:

Multi-shipment examples

Recommendations [hide]

This topic describes how to use Episerver Commerce APIs to work with multi-shipment, also known as split shipment, which supports shipment to multiple address. For example, a customer buys two items, and each is shipped to a different address. During checkout, a customer can create a new address, or select from existing addresses.

How it works

If a customer purchases two or more items, the Ship to multiple addresses button appears during checkout.

Multi shipment 1

During checkout, the information for each split shipping part is added. The number of split shipments is equal to the number of items in the cart, so the customer can add/select a shipping address for each item.

Multi shipment 2

Upon completing the information for each split shipment, the order process moves to next step. Here, choosing a shipping delivery option, billing address, and payment is required.

Multi shipment 3

Code examples

Example: Creating multiple shipment for Cart base on cart's LineItem

var orderRepository = ServiceLocator.Current.GetInstance();
var currentMarket = ServiceLocator.Current.GetInstance();
var cart = orderRepository.LoadCart(CustomerContext.Current.CurrentContactId, DefaultCartName, currentMarket);
var form = cart.GetFirstForm();
var cartLineItems = cart.GetAllLineItems().ToList();

// Clean up line item in shipment
foreach (var shipment in form.Shipments)
  {
    shipment.LineItems.Clear();
  }
// Clean up shipments
form.Shipments.Clear();

// Adding shipment for each cart line item
foreach (var item in cartLineItems)
  {
    var shipment = cart.CreateShipment(_orderGroupFactory);
    var lineItem = cart.CreateLineItem(item.Code, _orderGroupFactory);
    lineItem.IsGift = item.IsGift;
    lineItem.Quantity = item.Quantity;
    shipment.LineItems.Add(lineItem);
    form.Shipments.Add(shipment);
  }

orderRepository.Save(cart);
Do you find this information helpful? Please log in to provide feedback.

Last updated: Oct 24, 2016

Recommendations [hide]