Enabling interim fixes JR41022 and JR46449

Interim fix JR41022 and JR46449 enhance marketing code to include the order ID in the name-value pairs when an email template JSP is used. The following steps illustrate how to set up the environment and use the order ID name-value pair.

For example, a Marketing Manager wants to implement the following dialog activity scenario: A number of weeks after a customer places an order, send the customer an email to request feedback on the purchased products. The email needs to include the details of the order that was placed.

Before you begin

Install the cumulative interim fix for Fix Pack 7, JR53048.fp.

Procedure

  1. Run the following SQL to update the 'Customer Places Order' trigger to a new definition.
    insert into dmeletemplate (dmeletemplate_id, DMELEMENTTYPE_ID, name, storeent_id, implxml, behaviorxml) 
    values (-121, 1, 'purchases', 0, '<Trigger type="Purchases"></Trigger>', 
    '<BehaviorRule command="OrderProcessFromOrderSubmission" action="send" processOnlyFromService="true" 
    allowMultipleActivities="true"><Variable name="orderId" value="*" comparison="any" type="NVP"/></BehaviorRule>');
  2. Create and register an email template JSP file. The email template JSP file can use the ${orderId} variable to look up details of the order.
    1. Create a JSP file with the email contents. The orderId parameter has the ID of the placed order. The following JSP snippet (EmailOrderFollowUp.jsp) is an example that includes the list of items in the order and provides a link back to the store product display page. Change the email contents as necessary.
      <%-- 
        This e-mail template JSP is used to display to a customer the items they had placed in a previous order.
        The e-mail will look like the following:
      
        Subject: Hello FirstName LastName. We would like your feedback on a past order.
      
        Thank you for your previous purchase as madisons.com.
        We would like to get your feedback on the items you purchased
        in order <c:out value="${orderId}" />.
      
         Executive Six-Drawer Desk 
      
         Two-Drawer Coffee Table 
      
         Brushed Steel Lamp 
      --%>
      
      <%-- Start - JSP File Name: EmailOrderFollowUp.jsp --%>
      <%@page import="com.ibm.commerce.command.CommandContext" %>
      <%@page import="com.ibm.commerce.server.ECConstants" %>
      <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
      <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
      <%@ taglib uri="http://commerce.ibm.com/base" prefix="wcbase" %>
      <%@ taglib uri="http://commerce.ibm.com/foundation" prefix="wcf" %>
      <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
      <%@ taglib uri="flow.tld" prefix="flow" %>
      <%@ include file="JSTLEnvironmentSetup.jspf" %>
      
      <c:set var="recipientId" value="${param.recipientId}"/>	
      <c:set var="returnSubjectValue" value="${param.returnSubject}"/>	
      <c:set var="orderId" value="${param.orderId}"/>	
      	
      <jsp:useBean id="bnRegister" class="com.ibm.commerce.user.beans.UserRegistrationDataBean" scope="page">
         <c:set target="${bnRegister}" property="userId" value="${recipientId}"/>
         <% bnRegister.populate(); %> 
      </jsp:useBean>
      	
      <c:if test="${returnSubjectValue != null && returnSubjectValue == 'true'}">
       	
          Hello <c:out value="${bnRegister.firstName}" /> <c:out value="${bnRegister.lastName}" />. 
      	We would like your feedback on a past order.
       	
      </c:if>
      
      <c:if test="${returnSubjectValue == null || returnSubjectValue != 'true'}">	
      	<c:set var="hostPath" value="${pageContext.request.scheme}://${pageContext.request.serverName}" />
      	<c:set var="serverPath" value="${hostPath}/webapp/wcs/stores/servlet" />	
      	<wcbase:useBean id="sdb" classname="com.ibm.commerce.common.beans.StoreDataBean" scope="request" />		
      	<c:set var="catalogId" value="${WCParam.catalogId}" />
      	<c:if test="${empty catalogId}">
      		<c:set value="${sdb.masterCatalogDataBean.catalogId}" var="catalogId" />
      	</c:if>
      	<c:set var="preferedlanguageId" value="${bnRegister.preferredLanguageId}" />
      	<c:if test="${preferedlanguageId == null || preferedlanguageId == ''}">	
       		<c:set var = "preferedlanguageId" value="-1" />
      	</c:if>
      	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
      	<html>
      	<body marginheight="10" marginwidth="0">
      	<br />
      	<br />
      	<img src="<c:out value="${hostPath}/wcsstore/Madisons/images/madisons_header.gif"/>" border="0"/>
      	<br />
      	Thank you for your previous purchase as madisons.com.
      	We would like to get your feedback on the items you purchased
      	in order <c:out value="${orderId}" />.
      	<br />								
      	<wcf:getData type="com.ibm.commerce.order.facade.datatypes.OrderType"
                   var="orderInCart" expressionBuilder="findByOrderId" 
                   varShowVerb="ShowVerbCart" 
                   maxItems="${maxOrderItemsToInspect}" recordSetStartNumber="0" recordSetReferenceId="headerorder" 
                   scope="request">
      		<wcf:param name="accessProfile" value="IBM_Details" />	 
      		<wcf:param name="orderId" value="${orderId}" />
      	</wcf:getData>
      	<c:if test="${!empty orderInCart.orderItem }" >
      		<c:forEach var="orderItem" items="${orderInCart.orderItem}" varStatus="status">
      			<wcbase:useBean id="catEntry" classname="com.ibm.commerce.catalog.beans.CatalogEntryDataBean" scope="request">
      				<c:set property="catalogEntryID" value="${orderItem.catalogEntryIdentifier.uniqueID}" target="${catEntry}" />
      				<c:set property="commandContext" value="${CommandContext}" target="${catEntry}" />
      			</wcbase:useBean>									
      			<wcf:url var="catEntryDisplayUrl" value="${serverPath}/Product1">
      				<wcf:param name="catalogId" value="${catalogId}"/>
      				<wcf:param name="storeId" value="${WCParam.storeId}"/>
      				<wcf:param name="productId" value="${orderItem.catalogEntryIdentifier.uniqueID}"/>
      				<wcf:param name="langId" value="${preferedlanguageId}"/>
      			</wcf:url>								
      			<img src="<c:out value="${hostPath}${catEntry.objectPath}${catEntry.description.thumbNail}"/>" 
      					alt="<c:out value="${fn:replace(catEntry.description.name, search, replaceStr)} 
      						${displayPriceString}" escapeXml="false"/>" 
      					border="0"/>
      			<a href="${catEntryDisplayUrl}" class="order_link" id="WC_product_link_1_${status.count}">
      				<c:out value="${catEntry.description.name}"/>
      			</a>								
      			<br />
      			<br />
      			<c:remove var="catEntry"/>
      		</c:forEach>
      	</c:if>
      	</body>
      	</html>
      </c:if> 
    2. Save the JSP file to the WC_eardir/Stores.war/storedir/include directory. Replace storedir with the name of your store directory that is on the file system.
  3. Configure the email in the database. Replace YOUR_STORE_ID with the STOREENT_ID of your store. The number 12 is used as an example unique identifier for the email template. Change the number as necessary. 'EmailOrderFollowUp' is used as an example of the name of the email template. Change the name as necessary.
    Run the following SQL statement
    insert into emlmsg values (12, 'EmailOrderFollowUp' ,' ', 'EmailOrderFollowUp', null, YOUR_STORE_ID, 0, 1, 0);
  4. Configure the email in the struts configuration file.
    1. Open the WC_eardir/Stores.war/WEB-INF/struts-config-ext.xml file.
    2. Add the following code to the global-forwards section. Replace YOUR_STORE_ID with the STOREENT_ID of your store. EmailOrderFollowUp is used as an example of the name of the email template, and the name of the email template JSP on the file system. Change as necessary.
      <forward className="com.ibm.commerce.struts.ECActionForward" name="EmailOrderFollowUp/YOUR_STORE_ID/-3" path="/include/EmailOrderFollowUp.jsp">
              <set-property property="interfaceName" value="com.ibm.commerce.messaging.viewcommands.MessagingViewCommand"/>
              <set-property property="implClassName" value="com.ibm.commerce.messaging.viewcommands.MessagingViewCommandImpl"/>
          </forward>
  5. If you are testing the dialog activity, you can set the Wait trigger to be a shorter time.
    For example, if you want the Wait trigger to be 2 minutes, then add the following configuration to the WC_eardirxml/config/com.ibm.commerce.marketing/wc-admin-component.xml file to make all Wait triggers to be 2 minutes.
    <_config:property name="timedEventTest" value="true"/>
    <_config:property name="timedEventTestInterval" value="2"/>
  6. Restart the WebSphere Commerce server.
  7. Configure the inbound and outbound settings for email activities for the store in the Administration Console.
  8. Create and activate a dialog activity: Customer Places Order trigger > Wait trigger > Send Message action.
    • Select Repeatable so that the dialog is run for every order that is placed.
    • Customer Places Order: Wait until customer places an order
    • Wait: Wait 7 weeks (or any time interval)
    • You must select "Send immediately" on the Send Message action. The scenario does not work if "Send immediately" is not selected.
    • Send Message: Message type: email, email template: EmailOrderFollowUp, Send immediately (EmailOrderFollowUp is used as an example of the name of the email template.)
  9. Test the scenario:
    1. Register a customer in the store and provide an email address and opt-in for marketing email.
    2. Place an order.
    3. Run the RaiseECEvent scheduled job in the Administration Console, or wait 5 minutes for the next scheduled job to run.
    4. Wait the amount of time that is configured in the timedEventTestInterval parameter.
    5. Run the SendMarketingTriggers scheduled job in the Administration Console, or wait 20 minutes for the next scheduled job to run.
    6. Verify the contents of the email.