ATG Shipping Groups, methods and calculators

Adding shipping information to shopping carts involves the following sub-processes:
1) Creating a list of shipping groups for potential use in the current order
2) Specifying the shipping groups to use with the current order
3) Selecting the shipping methods, such as Ground or Next Day, for the order’s shipping groups 


What is Shipping Group?
A ShippingGroup contains information on the shipping address and delivery method for a group of commerce items. 

By default, a new Order has one defaultShippingGroup. As items are added to the Order, these items automatically become part of the default ShippingGroup. Once a second ShippingGroup is added to theOrder, all the items in the Order are removed from the default ShippingGroup and must be explicitly added to one of two shipping groups. 
 
How to create new Shipping Groups?
You can create a list of shipping groups for potential use in an Order in one of two ways:
  • from information gathered from the user via forms

  • from information stored in the user’s profile
 Below two form handlers allow user to add new shipping groups  
  • /atg/commerce/order/purchase/CreateHardgoodShippingGroupFormHandler
  • /atg/commerce/order/purchase/CreateElectronicShippingGroupFormHandler
 Both extends PurchaseProcessFormHandler 

How to add Shipping Group to an Order?
Steps:
1) Create Shipping Group
2) Make any changes to the Shipping Group, such as setting the address
3) Add the Shipping Group to the Order


 Here is the code snippet:
// Get a reference to the OrderManager 
OrderManager orderManager = (OrderManager)   request.resolveName("/atg/commerce/order/OrderManager");  
// Create the ShippingGroup 
ShippingGroup shippingGroup shippingGroupManager.createShippingGroup(); 
// Add the ShippingGroup to the Order shippingGroup.addShippingGroupToOrder(pOrder, shippingGroup);

How to find available Shipping methods for a particular Shipping Group?
Use droplet  /atg/commerce/pricing/AvailableShippingMethods


How to initiate Shipping group from Profile?
Use droplet /atg/commerce/order/purchase/ShippingGroupDroplet
 
What is Shipping method? 
Each Shipping method is represented by ShippingCalculator component class.

Shipping methods examples are:
  • Ground
  • 2 day delivery
  • Overnight
  • Calculate Shipping price based on couriers web service
  • etc...
Different types of Shipping calculators are:
  • FixedPriceShippingCalculator - Flat rate for shipping
            Ex: Ground shipping is always $15
  • PriceRangeShippingCalculator - Define shipping price based price range
             Ex: $0 - $50  ($5)
                   $51 - $100  ($10)
                   $101 - $1000  (FREE)
  • WeightRangeShippingCalculator - Weight Property added at SKU level and price set based on weight
  • PropertyRangeShippingCalculator - Shipping price decided Based on SKU property
          Ex: Volume
    How to Filter Shipping methods?
    In few scenarios, All shipping methods should not be available. To limit shipping methods developer can sub-class Shipping calculator and override the getAvailableMethods().

    Ex: Courier shipping not allowed for PO boxes

    How to write custom shipping calculator?
    Here are the steps:
    1. Create a new custom calculator component 
    /com/commerce/shipping/FixedPriceServiceCaclulator.properties 
    $class=com.xxx.commerce.pricing.calculators.FixedPriceShippingCalculator
    # name of shipping method
    shippingMethod=DEMO
    # costs 
    amount=10.0

    2. Create a custom Java class and this should extends the shippingCalculatorImpl class
    ShippingCalculatorImpl class have two method for override.
    1.getAmount()  - calculate the shipping price

    2.getAvailableMethods()  - Used to restrict your custom shipping method

    public class FixedPriceShippingCalculator extends ShippingCalculatorImpl { 

    protected double getAmount(Order order, ShippingPriceInfo priceQuote, ShippingGroup shippingGroup, RepositoryItem pricingModel, Locale locale, RepositoryItem profile, Map extraParameters) throws PricingException { }

    public void getAvailableMethods(List pMethods, ShippingGroup pShippingGroup, RepositoryItem pPricingModel, Locale pLocale, RepositoryItem pProfile, Map pExtraParameters) throws PricingException {
    }
    }
    3. Add the shipping calculator to Shipping Engine
    /atg/commerce/pricing/ShippingPricingEngine.properties 
    preCalculators+=/com/commerce/shipping/FixedPriceServiceCaclulator

    9 comments:

    1. good
      https://shipexusa.com
      https://cronvideo.com
      https://videoud.com

      ReplyDelete
    2. The customers usually experience fast delivery when they get the packages through Courier Company instead of a postal service. The biggest advantage is that the package is sent out to your door step so there is no need to collect the package on your own. We also recently sent some confidential documents via same day courier service and the package was dispatched very safely to our client.

      ReplyDelete
    3. Very useful content been imparted by you. I like your strategy and the way you organize things in an informative way. Thanks for putting your time to explain the things to us.Tutor services are also provided by TheTuitionTeacher in Delhi.
      Home Tutors in Delhi | Home Tutors Delhi

      ReplyDelete
    4. Sometime it becomes very hard to find a well written and well established bog which give you correct and useful information. However, I found this blog and got some relevant information which are really helpful for me.
      dhl ราคา

      ReplyDelete
    5. Most of the blogs pretend themselves as most usable and updated blogs with new information but sometime truth might different. I want to share some facts related to this subject which will help people to enhance their skills.
      ส่ง เอกสาร

      ReplyDelete
    6. I am completely inspired with the accurate change aptitude of creator utilized for changing his contemplations and exhibited here. Inspired with profound importance of this article. Shipping Management Software UAE

      ReplyDelete
    7. Extraordinary things you've generally imparted to us. Simply continue written work this sort of posts.The time which was squandered in going for educational cost now it can be utilized for studies.Thanks shipping

      ReplyDelete
    8. Thanks for providing recent updates regarding the concern, I look forward to read more.
      Cute Compression Socks

      ReplyDelete