Shopping cart tag

The HCL Commerce shopping cart tag collects details about the items a customer has in the shopping cart.

This tag collects the following data to pass to an external analytics system:

  • Product part number
  • Product name
  • Quantity
  • Base price
  • Product category in the catalog the customer is browsing
  • Product category in the master catalog
  • Currency
  • Store identifier

This tag can also pass extra parameters for tag customization.

Parameters

The following is a list of required and optional parameters for the shopping cart tag.

Note for IBM Digital Analytics: The following parameters are for the HCL Commerce <cm:cart /> tag. This tag generates the IBM Digital Analytics cmCreateShopAction5Tag data tag.

To pass the shopping cart data that is listed at the beginning of this topic to an external analytics system, use one of the following parameters:
databean
Use this parameter if your shopping cart page JSP file already contains an order data bean. This parameter is a populated instance of the com.ibm.commerce.order.beans.OrderDataBean.

Using the databean parameter provides better performance than the orderId parameter because the shopping cart tag does not have to use other resources to generate the data bean from the orderId.

orderType
Use this parameter if your store uses web services for order runtime functions. This parameter is a populated instance of the com.ibm.commerce.order.facade.datatypes.OrderType object.

Using the orderType parameter provides better performance than the orderId parameter because the shopping cart tag does not have to use other resources to generate the orderType data from the orderId.

orderId
If neither of the previous two parameters applies, use the orderId parameter. This parameter is the order ID of the order. The shopping cart tag automatically creates an order data bean to get the information that the external analytics system requires.

This parameter is ignored if you use the databean parameter or the orderType parameter.

To send tax-related data to the external analytics system, use the following additional parameter:

includeTaxInUnitPrice
An optional parameter that is used to conditionally exclude or include the tax along with the unit price sent to the external analytics system. The default value is false. If set to true, the unit price that is sent to the external analytics system is the sum of the unit price and the tax that is calculated for the particular product.

To send more information to the external analytics system, use these parameters:

extraparms
An optional parameter that you can use to send additional information that applies to all catalog entries in the order to the external analytics system. This parameter is provided for cases in which you might have negotiated `with the external analytics vendor to generate some custom report that requires additional information.

Note for : Use the extraparms parameter to pass either Explore attributes, or data for custom reports, or both. See Passing extra data to IBM Digital Analytics with the extraparms parameter.

There are multiple ways to pass values using the extraparms parameter:
Description Example
Specify explicit values as properly escaped JavaScript. To pass more than one value, separate values with a comma. extraparms="\"value1\", \"value2\""
Specify explicit values without escaping the values. To pass more than one value, separate values with a comma. extraparms="value1, value2"
Specify dynamic content by calling a method name. Any parameter using extraparms starting and ending with the $ symbol, for example, $getMethod$, is assumed to be a method name of the object that is passed using either of the parameters databean or orderType. The only restriction on the method name is that it must take no arguments and the object that is returned must implement the toString() method. extraparms="$getMethod$"
extraparmsMap
An optional parameter that you can use to send additional information that applies to specific catalog entries in the order to the external analytics system. This parameter is an alternative to the extraparms parameter when you want to attach different extra parameter values to each order item in the shopping cart instead of attaching the same extra parameter value to every item in the shopping cart.

Note for : Use the extraparmsMap parameter to pass either Explore attributes, or data for custom reports, or both. See Comparison of extra parameters for IBM Digital Analytics tags.

The input to this parameter is a java.util.Map type object in which the key for each entry in the map is the orderItemId The value for a particular key is the extra parameter that is passed along with the catalog entry associated with the order item. The value for each orderItemId is appended to the argument list for the analytics tag output of that particular order item.

The following is sample code to create a java.util.HashMap object to pass as the value for the extraparmsMap parameter:

<wcf:getData type="com.ibm.commerce.order.facade.datatypes.OrderType" 
var="orderForAn" expressionBuilder="findByOrderId" scope="request">
<wcf:param name="accessProfile" value="IBM_Details" />
<wcf:param name="orderId" value="${WCParam.orderId}" />
</wcf:getData>

<%
java.util.HashMap map = new java.util.HashMap();
com.ibm.commerce.order.facade.datatypes.OrderType 
ord = (com.ibm.commerce.order.facade.datatypes.OrderType) 
pageContext.getAttribute

("orderForAn",PageContext.REQUEST_SCOPE);
java.util.List orderItemList = ord.getOrderItem();
java.util.Iterator itr = orderItemList.iterator();
int i = 1;
while (itr.hasNext()) {
com.ibm.commerce.order.facade.datatypes.OrderItemType 
orderItemObj = (com.ibm.commerce.order.facade.datatypes.OrderItemType) itr.next();
String id = orderItemObj.getOrderItemIdentifier().getUniqueID();
map.put(id, "value" + i+ ".0-_-value" + i+ ".1");
i++;
}
pageContext.setAttribute("eMap",map);
%> 

Tag versions

HCL Commerce provides two versions of the shopping cart tag:

  1. An abstract base tag implementation class: com.ibm.commerce.bi.taglib.CartBaseTagcom.ibm.commerce.store.bi.taglib.CartJSONBaseTag. Analytics vendors who want to provide a shopping cart tag in their web analytics JSP tag library can extend this base tag class to get the shopping cart data and implement their own logic to generate the vendor-specific shopping cart tagging APIs.
  2. A default implementation of the shopping cart tag (<cm:cart />) for IBM Digital Analytics. This implementation automatically generates the IBM Digital Analytics cmCreateShopAction5Tag data tag.