Try our conversational search powered by Generative AI!

Loading...
ARCHIVED This content is retired and no longer maintained. See the latest version here.

Recommended reading 

This topic describes how to use the ECF API to work with multi-shipment, also known as split shipments. The multi-shipment feature let purchased items be shipped to multiple address. For example, when a customer buys two items (A and B), each item is shipped to a different address. A customer can create an address during checkout, or select from existing addresses.

How it works

When a customer purchases two or more items, the Multi-shipment checkout option appears during checkout.

Page Types

During checkout, the information for each split shipping part is added. The number of split shipments is equivalent to the number of items in the cart, and the customer can add individual shipment addresses for each item.

Page Types

Upon completing the information for each split shipment part, the page is reloaded to update the summary for each shipment, and the total summary.

The customer can create new addresses in each split shipment part that can be used for both billing and shipping.

Page Types

Code examples

Example: Getting the billing address

C#
var Cart = new CartHelper(Mediachase.Commerce.Orders.Cart.DefaultName);
var billingAddressId = Cart.OrderForms[0].BillingAddressId;
var billingAddress = Cart.OrderAddresses.ToArray().FirstOrDefault(x =>
x.Name.Equals(billingAddressId));

Example: Creating split shipment parts based on line items

C#
var lineItems = Cart.OrderForms[0].LineItems;
foreach (LineItem lineItem in lineItems)
{
        Shipment shipment = new Shipment();
        shipment.CreatorId = SecurityContext.Current.CurrentUserId.ToString();
        shipment.Created = DateTime.UtcNow;
shipment.AddLineItemIndex(lineItems.IndexOf(lineItem), lineItem.Quantity);
        Cart.OrderForms[0].Shipments.Add(shipment);
}
Cart.AcceptChanges();

Example: Adding a shipping address to a cart

C#
Shipment shipment = Cart.OrderForms[0].Shipments.ToArray().FirstOrDefault();
if (shipment == null)
{
    shipment = new Shipment();
     shipment.CreatorId = SecurityContext.Current.CurrentUserId.ToString();
    shipment.Created = DateTime.UtcNow;
}

shipment.ShippingAddressId = address.Name;

if (Cart.OrderForms[0].Shipments.Count < 1)
{
    Cart.OrderForms[0].Shipments.Add(shipment);
}
Example: Adding a shipment method to a cart
C#
/Shipment ship = Cart.OrderForms[0].Shipments.ToArray().Where(s => s.Id ==      this.SplitShipment.Id).FirstOrDefault();
ship.ShippingMethodId = new Guid(shippingMethodId);
ship.ShippingMethodName = ((GlobalRadioButton)sender).Text;

//Calculate shipping, disocunts, totals, etc    
OrderGroupWorkflowManager.RunWorkflow(Cart,                                                     
OrderGroupWorkflowManager.CartPrepareWorkflowName);
Cart.AcceptChanges()
;
Do you find this information helpful? Please log in to provide feedback.

Last updated: Oct 12, 2015

Recommended reading