Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Shipping Options

Shipping Options

During the checkout process, customers have the opportunity to select their Shipping Service level. After the shipping address has been selected, the shipping service levels available are determined by the region to which their products are being shipped; available shipping options for different regions are configured in the Commerce Manager. For more information on how that is done, see the Shipping Regions and Shipping Service Levels sections in the Commerce Manager User Guide.

Key Classes and Files

The relevant files and classes can be roughly subdivided into those that deal mostly with displaying the appropriate ShippingServiceLevels and those that deal with the costs associated with those service levels.

Shipping Service Levels

  • CheckoutServiceImpl - retrieveShippingOption(shoppingCart) - Sets the valid shipping levels in the ShoppingCart for display.
  • ShippingServiceLevelServiceImpl - Retrieves valid shipping service levels for a region, gets shipping cost calculations, takes into account shipping-related promotions.
  • ShippingServiceLevel - A shipping option associated with a shipping region.
  • ShoppingCartImpl - Gets the shipping cost based on the selected shipping service level.

Shipping Costs associated with different service levels

  • EpRuleEngine - applies promotion rules that may affect shipping costs.
  • ShippingCostCalculationMethod - calculates shipping costs for a given ShoppingCart, depending on which shipping option was selected, which promotions are in effect, the customer's shipping region, and the shipping cost calculation method selected for use in the Commerce Manager.
  • AbstractShippingCostCalculationMethodImpl - Abstract implementation of a shipping cost calculation.
  • The following classes extend AbstractShippingCostCalculationImpl to implement specific shipping cost calculations.
    • CostPerUnitWeightMethodImpl
    • FixedBaseAndCostPerUnitWeightMethodImpl
    • FixedBaseAndOrderTotalPercentageMethodImpl
    • FixedPriceMethodImpl
    • OrderTotalPercentageMethodImpl

How it works

  1. The CheckoutService then calls ShippingServiceLevelService.retrieveShippingServiceLevel(shoppingCart) to get a list of of valid shipping service levels for the shipping address
    1. It does this by asking the database for all the ShippingServiceLevels in the tshippingservicelevel table, then filtering out the levels that do not apply to the region in which the shipping address is located.
    2. The CheckoutService method then calls the ShoppingCart.setShippingServiceLevelList(), which in turn calls calculateShippingCost(shoppingCart) on each ServiceLevel in the list to force it to calculate its shipping cost based on what's in the shopping cart, and sets the first ShippingLevel as the default selected level in the ShoppingCart.
    3. At this point, it's time to apply the promotion rules. The shopping cart calls EpRuleEngine.fireOrderPromotionrules(shoppingCart).
      1. The Rule Engine loops through all the CartItems in the ShoppingCart, using the drools engine to apply promotions rules. See the Promotion rule engine for information on how these work.
  2. The available service levels are then displayed through the front end.