Shipping


To provide the user with a list of available shipping methods, We use atg/commerce/pricing/AvailableShippingMethods servlet bean.

AvailableShippingMethods servlet bean queries the ShippingPricingEngine to determine all the available shipping methods for a particular ShippingGroup.

The ShippingPricingEngine iterates over its registered shipping calculators and includes the returned shipping method of each one.


There are three steps to setting up the various shipping methods: 


  • configuring the specific calculator instances, 
  • adding these calculator instances to our ShippingPricingEngine, and 
  • displaying these shipping methods to the customer via AvailableShippingMethods.


 For Example : We used the

  • atg.commerce.pricing.FixedPriceShippingCalculator for the Ground and Two Day shipping methods and
  • atg.commerce.pricing.PriceRangeShippingCalculator for Next Day shipping. 


We need to create properties files to generate instances of these calculators.

For example, for the Ground shipping method, we created the Ground.properties file with the following configuration:

/atg/commerce/pricing/shipping/Ground.properties

# Define a Ground shipping method
$class=atg.commerce.pricing.FixedPriceShippingCalculator

# name of shipping method
shippingMethod=Ground

# cost of shipping method
amount=5.0


/atg/commerce/pricing/shipping/TwoDay.properties

# Define a Two day shipping method
$class=atg.commerce.pricing.FixedPriceShippingCalculator

# name of this shipping method
shippingMethod=Two Day

# cost of shipping method
amount=20.0


/atg/commerce/pricing/shipping/NextDay.properties

# Define a Next Day shipping method
$class=atg.commerce.pricing.PriceRangeShippingCalculator

# name of shipping method
shippingMethod=Next Day

# range of costs
ranges=00.00:10.00:10.00,\
        10.01:30.00:15.00,\
        30.01:50.00:20.00,\
        50.01:70.00:25.00,\
        70.01:100.00:30.00,\
        100.01:MAX_VALUE:40.00

Range Property : 00.00:10.00:10.00 : If the cost is between $0 and $10, set the price to $10.
                            10.01:30.00:15.00 : If the price is between $10.01 and $30 set the price to $15.

Adding Calculators to Pricing Engine


# Calculators that ShippingPricingEngine will use to determine shipping
preCalculators=shipping/Ground,\
        shipping/NextDay,\
        shipping/TwoDay


Enabling Customers to Choose Shipping Methods


<droplet bean="AvailableShippingMethods">

  <param name="shippingGroup" value="bean:ShoppingCartModifier.shippingGroup">
  <param name="pricingModels" value="bean:UserPricingModels.shippingPricingModels">
  <param name="profile" value="bean:Profile">

  <oparam name="output">
    <select bean="ShoppingCartModifier.shippingGroup.shippingMethod">
    <droplet bean="ForEach">
          <param name="array" value="param:availableShippingMethods">
          <param name="elementName" value="method">
          <oparam name="output">
              <option value="param:method"><valueof param="method"></valueof>
          </oparam>
    </droplet>
    </select>
  </oparam>
</droplet>

No comments :