Spree Commerce

Try It Now

Shipping Framework

Posted on November 11, 2008 by Sean Schofield

Spree now includes a complete shipping framework that allow you to configure shipping for your exact needs. Shipping is implemented through a combination of zones and calculators. The core shipping extension in Spree adds several columns to the variant table to assist in shipping. Each product variant has a weight, height, width and depth field. There is an assumption of an implicit common unit of measurment for each of these fields.

The core shipping extension also adds a shipping_category field to the Product model. Products can be assigned to zero or one shipping category. The shipping_category field is entirely optional. Shipping calculators can be designed to take advantage of this category information or ignore it entirely.

Each of the shipping methods relies on a calculator to determine the actual shipping costs. Calculators contain a calculate_shipping method to which you pass an Order object. The order contains an Address which is the shipping address as well as LineItems which contain references to the Variants and their quantities.

It is our experience that most applications require very specific
logic for their shipping needs. Most open source platforms fall into the
trap of trying to integrate a shipping solution that attempts to meet
everyone’s needs. Spree takes a different approach. Spree comes with a simple flat rate shipping option as well as the ability to turn off shipping all together (just remove the shipping extension.) It is expected that you will either develop your own shipping extension or use an existing third party extension. Spree puts an emphasis on making it easier to customize the piece that always ends up needing to be customized anyways.

Please see the shipping chapter of the user’s guide for more details. Also, be sure to checkout the extensions listing for more information on all of the shipping and other Spree extensions.