WebSphere Commerce EnterpriseWebSphere Commerce Version 7.0.0.0Feature Pack 1

Customizing store page JSP files to display the list price

If your store displays the list price to customers, you must make changes to any JSP files that contain code related to the list price. These changes ensure that the store is using both the new list price list and the new List price rule that the migration utility creates. If your store does not display list prices, you can skip this customization procedure.

Before you begin

Make sure you have completed all of the previous steps in Task flow: Setting up an existing store to use Management Center price rules and price lists.

About this task

This task applies to:
  • Single stores (stores that are not extended site stores)
  • Extended sites: Complete this task only on the storefront asset store.
This procedure applies to the following WebSphere Commerce starter stores, if you published the starter store before you installed WebSphere Commerce Version 7 Feature Pack 2:
  • Madisons
  • Elite
  • Brazil
  • MayUJoy
If you have customized one of these starter stores, your customization might affect how you apply this JSP migration procedure. For example, if you have excluded certain starter store files that are affected by the migration, then you can skip the related steps.

Procedure

  1. Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
  2. Add a new variable to the JSTLEnvironmentSetup.jspf file:
    1. Open the file at this path:
      • WebSphere Commerce DeveloperWCDE_installdir/workspace/Stores/WebContent/storedir/include/JSTLEnvironmentSetup.jspf
    2. Add the following line of code to the bottom of the file:
      <c:set var="defaultDisplayPriceRuleName" value="List price rule"/>
      This line of code configures the store to use a default price rule called List price rule to set the list price for catalog entries on the storefront. The migration utility creates the List price rule for the store when the utility runs (for single stores, extended site stores, and storefront asset stores). The List price rule gets the price from the List price list that the migration utility creates.
    3. Save and close the file.
  3. Add a new GetCatalogEntryDisplayPrice.jspf file to your store directory:
    1. Create an empty file called GetCatalogEntryDisplayPrice.jspf at the following path:
      • WebSphere Commerce DeveloperWCDE_installdir/workspace/Stores/WebContent/storedir/Snippets/ReusableObjects/
    2. Paste the following content into the empty GetCatalogEntryDisplayPrice.jspf file:
      <%--
      /*
       *-------------------------------------------------------------------
       * Licensed Materials - Property of IBM
       *
       * WebSphere Commerce
       *
       * (c) Copyright International Business Machines Corporation. 2009
       *     All rights reserved.
       *
       * US Government Users Restricted Rights - Use, duplication or
       * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
       *
       *-------------------------------------------------------------------
       */
      --%>
      <%-- 
        *****
        * This JSP is an extension point for price list&rule solution.
        * This page will call priceFacadeClient to fetch list price based on display price rule and list price list.
        *****
      --%>
      
      <%@ taglib uri="http://commerce.ibm.com/foundation" prefix="wcf" %>
      <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
      <c:set var="displayPriceAmount" scope="page"/>
      <c:set var="displayPriceCurrency" scope="page"/>
      <c:set var="listPriced" value="false"/>
      <wcf:getData type="com.ibm.commerce.price.facade.datatypes.DisplayPriceType" var="displayPriceType" expressionBuilder="getDisplayPriceByCatalogEntryIdandPriceRuleName">
      	<wcf:contextData name="storeId" data="${param.storeId}"/>
          <wcf:param name="catEntryId" value="${catalogEntryIdForPriceRule}" />
      	<wcf:param name="priceRuleName" value="${defaultDisplayPriceRuleName}" />
      </wcf:getData>
      <c:if test="${null!=displayPriceType}">
      	<c:forEach var="aUnitPrice" items="${displayPriceType.unitPrice}">
      		<c:set var="listPriced" value="true"/>
      		<c:set var="displayPriceAmount" value="${aUnitPrice.price.value}"/>
      		<c:set var="displayPriceCurrency" value="${aUnitPrice.price.currency}"/>
      	</c:forEach>
      </c:if>
      <%
      java.math.BigDecimal anAmount = (java.math.BigDecimal)(pageContext.getAttribute("displayPriceAmount"));
      String aCurrency = (String)(pageContext.getAttribute("displayPriceCurrency"));
      com.ibm.commerce.price.beans.PriceDataBean priceDB = null;
      if(null!=anAmount&&null!=aCurrency){
      com.ibm.commerce.price.utils.MonetaryAmount amount = new com.ibm.commerce.price.utils.MonetaryAmount(anAmount,aCurrency);
      Integer languageId = (Integer)(pageContext.getAttribute("langId"));
      
      	priceDB = new com.ibm.commerce.price.beans.PriceDataBean(amount,sdb,languageId);
      }
      %>
      <c:set var="displayPrice" value="<%=priceDB%>"/>
      <c:remove var="displayPriceAmount" scope="page"/>
      <c:remove var="displayPriceCurrency" scope="page"/>
    3. Save and close the file.
  4. Update the CatalogEntryPriceDisplay.jspf file:
    1. Open the file at the following path:
      • WebSphere Commerce DeveloperWCDE_installdir/workspace/Stores/WebContent/storedir/Snippets/ReusableObjects/CatalogEntryPriceDisplay.jspf

      Notice that this file is an existing file that is different from the new file you created in step 3, even though the names are similar.

    2. Include the GetCatalogEntryDisplayPrice.jspf file by adding the following two lines of code at a location before any of the list price logic is called:
      <c:set var="catalogEntryIdForPriceRule" value="${apendId}"/>
      <%@ include file="GetCatalogEntryDisplayPrice.jspf"%>

      For example, if your existing store is based on a WebSphere Commerce starter store (Madisons or Elite), add the two lines below the following line of code in the existing file:

      <%@ include file="CatalogEntryPriceDisplayExt.jspf"%>
    3. Search and replace the following strings in the CatalogEntryPriceDisplay.jsp file:
      Search for Replace with
      catalogEntryDB.listPriced listPriced
      catalogEntryDB.listPrice.amount displayPrice.amount
    4. Save and close the file
  5. Update the DiscountDetailsDisplay.jsp file:
    1. Open the file at this path:
      • WebSphere Commerce DeveloperWCDE_installdir/workspace/Stores/WebContent/storedir/ShoppingArea/DiscountSection/DiscountDetailsDisplay.jsp
    2. Include the GetCatalogEntryDisplayPrice.jspf file at a location in the code before any of the list price logic is called. The following code snippet from the existing DiscountDetailsDisplay.jsp file shows where you might include the GetCatalogEntryDisplayPrice.jspf file; you must add the last two lines of code marked 1 and 2:
      <%--
      ***
      * Start: discountCatalogEntryDB.productDataBean Price
      * The 1st choose block below determines the way to show the discountCatalogEntryDB.productDataBean contract price: a) no price available, b) the minimum price, c) the price range.
      * The 2nd choose block determines whether to show the list price.
      * List price is only displayed if it is greater than the discountCatalogEntryDB.productDataBean price and if the discountCatalogEntryDB.productDataBean does not have price range (i.e. min price == max price)
      ***
      --%>
      <c:choose>
        <c:when test="${catalogEntry.product}">
          <c:set var="type" value="product"/>
          <c:set var="catalogEntryDB" value="${catalogEntry.productDataBean}"/>
          <%@ include file="../../Snippets/ReusableObjects/CatalogEntryPriceDisplay.jspf"%>
        </c:when>
      <c:otherwise>
        <c:set var="discountItemDB" value="${catalogEntry}"/>
        <c:set var="catalogEntryIdForPriceRule" value="${catalogEntry.catalogEntryID}"/>1
        <%@ include file="../../Snippets/ReusableObjects/GetCatalogEntryDisplayPrice.jspf"%>2
    3. Search and replace the following strings in the DiscountDetailsDisplay.jsp file:
      Search for Replace with
      discountItemDB.listPriced listPriced
      discountItemDB.listPrice displayPrice
    4. Save and close the file.
  6. If your store contains other JSP pages with customized code related to displaying the list price, you must update those pages as well:
    1. Include the GetCatalogEntryDisplayPrice.jspf file in the customized file or its parent JSP at a location before any of the list price logic is called.
    2. Above the line that includes the GetCatalogEntryDisplayPrice.jspf file, set the proper value for the following variable:
      catalogEntryIdForPriceRule

      The value must be the ID of the catalog entry to get the list price for. To find the variable identifier, look in the JSP file that contains the include line. For example:

      • For the CatalogEntryPriceDisplay.jspf file, the variable identifier is:
        <c:set var="catalogEntryIdForPriceRule" value="${apendId}"/>
      • For the DiscountDetailsDisplay.jsp file, the variable identifier is:
        <c:set var="catalogEntryIdForPriceRule" value="${catalogEntry.catalogEntryID}"/>
    3. Search and replace the following strings to update the code related to list price:
      Search for Replace with
      your_customized_variable.listPriced listPriced
      your_customized_variable.listPrice displayPrice
      your_customized_variable.isListPriced() pageContext.getAttribute("listPriced")
      your_customized_variable.getListPrice() displayPrice

Results

After completing this procedure, any store pages that display the list price will now use the new List price rule and List price list for pricing.