Filtering order item level shipping modes

Sometimes a shipping mode might not be applicable to all products. If you choose not to associate a shipping mode with a product, then no shipping charge is applied to that product. You can use the OrderItemShippingModeListDataBean to filter the applicable shipping modes of an order item or an array of order items. By using the data bean, you can provide estimated shipping charges and optional shipping adjustments for each shipping mode.

About this task

The filtering of applicable shipping modes is based on the estimated shipping charge. When a specific shipping mode results in a null shipping charge for an order item, that shipping mode is ignored. The estimated shipping charge for the shipping mode of each order item assumes that the shipping charge can be determined by itself. The estimate charge also assumes that the shipping mode for each order item is not affected by the other order items within the same order. For example, if there is an order-level shipping charge configuration, such as $10.00 for an order, the shipping charge for each order item in ShippingMethod is $10.00. The shipping charge for the entire order in the Order Summary page is $10.00. The data bean considers each order item to be a stand-alone order and estimates the shipping charges for the order items.

The following instructions describe how to customize the storefront shopping flow. They do not describe how to customize order creation in the WebSphere Commerce Accelerator.

Procedure

  1. Refer to the com.ibm.commerce.fulfillment.beans.OrderShippingModeListDataBean data bean. The following table shows the input parameters for this data bean.
    Name Description
    orderItemId

    Use this parameter to set 1 order item to the data bean.

    orderItemIds

    Use this parameter to set a list of order items to the data bean.

    allowableShippingModeIds

    If this parameter is set to true, the data bean filters a list of the applicable shipping modes. If this parameter is set to false, the data bean returns the intersection of the shipping modes that are allowed for each order item. If the allowableShippingModeIds parameter is not set, the OrderItemShippingModeListDataBean retrieves the shipping modes that are supported by the contracts.

    calculateShippingCharge If this parameter is set to true, the data bean filters the shipping modes that are not applicable and estimate the charge for each shipping mode. If this parameter is set to false, the data bean returns the intersection of the shipping modes that are allowed for each order item.
    CalculateShippingAdjustment This parameter takes effect when the calculateShippingCharge parameter is set to true. If this parameter is set to true, the data bean adds the shipping adjustment of the shipping promotion result while it calculates the shipping charge.
    resolveFulfillmentCenter This parameter takes effect when the calculateShippingCharge parameter is set to true. When this parameter is set to true, the data bean resolves the fulfillment centers of the items in the order before it calculates the shipping charge. This behavior occurs because some shipping charge configurations are related to the fulfillment center. Typically, you can set the value for this flag to true since shipping configuration almost always relates to the fulfillment center.
    checkAppliedItems

    By default, this parameter is set to true. In previous releases, STENCALUSG.USAGEFLAGS must be set to 3 to filter shipping modes.

  2. Change the store flow or function to support multiple shipping methods:
    • Change the store function with the Store Management tool in Management Center:
      1. Open the Store Management tool.
      2. In the explorer view filter, click Stores.
      3. From the list of available stores, right-click the store that includes the shipping methods that you want to change. Click Open.
      4. Click the Checkout tab.
      5. Select the Multiple shipments check box.
      6. Click Save.
  3. Customize the JSP file to use the OrderItemShippingModeListDataBean to select the shipping mode.
    <c:remove var="orderItemShippingModeList"/>
    	<wcbase:useBean id="orderItemShippingModeList" classname="com.ibm.commerce.fulfillment.beans.OrderItemShippingModeListDataBean">
     	<c:set target="${orderItemShippingModeList}" property="orderItemId" value="${orderItem}"/>
     		<c:set target="${orderItemShippingModeList}" property="resolveFulfillmentCenter" value="true"/>
    		<c:set target="${orderItemShippingModeList}" property="calculateShippingCharge" value="true"/>
          	<c:set target="${orderItemShippingModeList}" property="calculateShippingAdjustment" value="true"/>
          </wcbase:useBean>
     	
     	</pre>
     	<table>
     		<tr>
                    <th><pre>Shipping Mode ID:</pre></th>
     		    <th><pre>Shipping Mode Description:</pre></th>
     		    <th><pre>Shipping Charge:</th>
     		</tr> 		
     		<c:forEach items="${orderItemShippingModeList.shippingModes}" var="shippingMode" varStatus="status">
     		<tr>
     		<td><c:out value="${shippingMode.shippingModeId}"/></td>
     		<td><c:out value="${shippingMode.description.description}"/></td>
     		<td><c:out value="${orderItemShippingModeList.shippingCharges[status.index]}"/></td>
     		</tr> 
     	</c:forEach> 		
     	</table>
    For the Aurora store, change the ShippingMethodDetails.jsp file. Customize the JSP file for selecting shipping mode as shown in the following code snippet:
    <select class="drop_down_shipping" name="MS_ShippingMode_<c:out value='${orderItemId}'/>" id="MS_ShippingMode_<c:out  value='${orderItemId}'/>" onchange="JavaScript:setCurrentId(this.id);
    CheckoutHelperJS.updateShipModeForThisItem(this,'<c:out  value="${orderItemId}"/>'); TealeafWCJS.rebind(this.id);">  
    <c:remove var="orderItemShippingModeList"/>
    <wcbase:useBean id="orderItemShippingModeList" classname="com.ibm.commerce.fulfillment.beans.OrderItemShippingModeListDataBean">
    <c:set target="${orderItemShippingModeList}" property="orderItemId" value="${orderItemId}"/>     
    <c:set target="${orderItemShippingModeList}" property="resolveFulfillmentCenter" value="true"/>    
    <c:set target="${orderItemShippingModeList}" property="calculateShippingCharge" value="true"/>         
    <c:set target="${orderItemShippingModeList}" property="calculateShippingAdjustment" value="true"/>   
    </wcbase:useBean>
    <c:forEach var="shippingMode" items="${orderItemShippingModeList.shippingModes}">
    <c:if test="${shippingMode.code != 'PickupInStore'}">     
    <%-- Show all the shipping options available except for pickUp in Store --%>      
    <%-- This block is to select the shipMode Id in the drop down  box. If this shipMode is selected then set selected = true --%>     
    <option shipModeCode="${shippingMode.code}"       
    <c:if test="${(shippingMode.shippingModeId eq selectedShipModeId)}">      
    <c:set var="selectedShippingMode" value="${shippingMode.code}"/>selected="selected"</c:if>
    value="<c:out value='${shippingMode.shippingModeId}'/>">      
    <c:choose>
    <c:when test="${!empty shippingMode.description.description}">        
    <c:out value="${shippingMode.description.description}"/>       
    </c:when>
    <c:otherwise>        
    <c:out value="${shippingMode.code}"/>       
    </c:otherwise>
    </c:choose>     
    </option>          
    </c:if>   
    </c:forEach>  
    </select>