Develop > Controller layer > Application developer > Order Management subsystem


Customize shipping charges

In some cases you may need to customize the shipping calculation. For example, if an item and its parent product are under different categories and each category has a different shipping calculation code attached, then both shipping calculation codes will be picked up by the runtime, and the final result will be cumulative.

To avoid this, you can customize the code, by overriding CalculationCodeCombineCmdImpl.getIndirectlyAttachedCodes().


Procedure

  1. Create a task command that extends CalculationCodeCombineCmd. For example,

    public interface EGShippingCalculationCodeCombineCmd extends CalculationCodeCombineCmd 
    { 
    public static final String defaultCommandClassName = "com.example.commerce.order.calculation.EGShippingCalculationCodeCombineCmdImpl"; 
    } 
    

  2. Create an implementation of the task command that extends CalculationCodeCombineCmdImpl. For example,

    EGShippingCalculationCodeCombineCmdImpl extends 
    CalculationCodeCombineCmdImpl implements 
    EGShippingCalculationCodeCombineCmd { } 
    

  3. Extend the default behavior of getIndirectlyAttachedCodes(Item) to filter the extraneous shipping calculation codes. For example,

    protected CalculationCodeAccessBean[]
    
    getIndirectlyAttachedCodes(Item iItem) 
    { 
        CalculationCodeAccessBean[] abCodes = super.getIndirectlyAttachedCodes(iItem); 
    
    //if the array contains both the product and item level shipping calculation codes, get rid of the product level one 
    return abCodes; 
    } 
    

  4. Register the task command as a calculation method in the CALMETHOD table. For example,

    INSERT INTO CALMETHOD VALUES (some unique ID, -1, -2, 
    'com.example.commerce.order.calculation.EGShippingCalculationCodeCombineCmd
    
    ', 'EG custom CalculationCodeCombine for shipping', 1, 
    'EGShippingCalculationCodeCombine') 
    

  5. Set the calculation method as the CalculationCodeCombine calculation method for shipping:

    UPDATE STENCALUSG SET ACTCC_CALMETHOD_ID=calculation methodID WHERE 
    STOREENT_ID IN (store ID, -1) AND CALUSAGE_ID=-2
    

    Do not customize CalculationHelper.getProductAndItemIds(nCatalogEntryId).


Related concepts

Ship


Related tasks

Changing shipping codes

Delete shipping codes

Activating and deactivating shipping codes

Define shipping charges

Set up shipping

Related reference

Example of shipping calculations


+

Search Tips   |   Advanced Search