g

Split Shipping


How does split shipping work;

Split Shipping extends Split Orders functionality. Please refer to Split Orders documentation to enable it. Once Split Orders are enabled, you will see an additional switch Enable Split Shipping.

Unlike splitting of orders which occurs after checkout process has been completed, Split Shipping splits cart contents into multiple batches ("sub-carts') based on shipping class of the products in the cart. Each batch needs to have its own shipping method selected on the Shipping Details page. The same delivery and shipping address will be used for all batches, but each batch will show its own selection of shipping options. The total cost of shipping of the order will be the sum of all selected shipping options for all batches.

Upon completion completion of checkout, a Split Order will be created. The parent order will list all the shipping rates selected, along with the individual rate price. The split order will only show it's selected shipping rate. Once enabled and split orders around found, it is required to select a shipping rate per batch during checkout.

Shipping Classes;

When using Split Shipping, all products must be assigned to a Shipping Class. A Shipping Class must be supported by a Shipping Company in order for this company's rates to appear on the Shipping Details page. 

Shipping classes are defined in Cog wheel → Catalogue Configuration → Shipping → Classes tab.

Once the Shipping Classes have been defined, they need to be assigned to the Shipping Companies. One Shipping Company can support multiple Shipping Classes. Please note, a company needs the be created first, and then you will be able to assign Shipping Classes on the Company Details tab of the Edit Company dialogue.

It is important to ensure that a shipping class is selected for each product. Navigate to Commerce and Edit a Product, Click the Shipping tab and you will see the shipping class selection. Only one Shipping Class can be configured for each product.

You now will have a Split Shipping checkout once you add two products with different shipping classes (no shipping class counts also)

Integrating Split Shipping;

When Split Shipping is enabled, every page will have a variable called $carts assigned. If this variable is false, then no batches are available. You can use these carts just like any other cart3 object. They have their own items and totals, so the existing code for cart3 will work. 

Each batch (sub-cart) will have a batch id, this is used to identify each sub-cart in this order and what is ultimately used to separate them into orders (split order 1, split order 2 etc.). When the customers address is entered into shipping checkout, the cart preview function will be called to calculate each carts shipping rates. This is returned in the following manner:

You can see that we now return the key subCarts, expanded above. Each index is the Batch Id of this sub-cart. The Batch Id always begins with 1. Under each cart, you have all available shipping rates for this cart and the currently selected shipping rate. You can use this information to list the shipping rates per cart. 

Sample contents of "subCarts" key Expand source

Once a selection has been made and the user is submitting the form, the POST data needs to have subCartShippingRates[$batchIdvariable with shipping rate Id for each cart.

<input type="hidden" name="subCartShippingRates[1]" value="81" />
<input type="hidden" name="subCartShippingRates[2]" value="28" />