Troubleshooting: Adding a product to a wishlist

After migrating from WebSphere Commerce Version 7 to HCL Commerce Version 9.0 or HCL Commerce Version 9.1, wishlist functionality does not function as expected.

Problem

Registered users cannot add products to a wishlist on a storefront environment that was migrated from WebSphere Commerce Version 7 to HCL Commerce Version 9.0 or HCL Commerce Version 9.1.

Solution

Modify the following files to correct this issue.
    1. Open the workspace/Stores_v7/WebContent/AuroraStorefrontAssetStore/javascript/Widgets/ShoppingList/ShoppingList.js javascript file for editing.
    2. Locate the following method, this.redirectToSignOn = function ():
      this.redirectToSignOn = function() {
      var href = document.location.href;
      var index = href.lastIndexOf("s", 4);
      if (index != -1){
      var newHref = href;
      }else{
      // Loaded with HTTP
      var newHref = href.substring(0,4) + "s" + (href.substring(4));
      }
      if (newHref.indexOf("?") > -1){
      var reloadURL = newHref + "&";
      }else{
      var reloadURL = newHref + "?";
      }
      
      dojo.cookie("WC_DisplaySignInPanel_"+WCParamJS.storeId, "true" , {path:'/'});
      
      var currentURL = location.href;
      if(true==isGuest){
      currentURL = getAbsoluteURL() + "RESTMoveOrderItem?continue=1&createIfEmpty=1&updatePrices=0&deleteIfEmpty=*&fromOrderId=*&toOrderId=.&page=&calculationUsageId=-1&URL="+encodeURIComponent("RESTOrderCalculate?URL="+encodeURIComponent(currentURL));
      }
      
      document.location.href = reloadURL + "myAcctMain=1&storeId="
      + this.storeParams.storeId + "&catalogId=" + this.storeParams.catalogId
      + "&langId=" + this.storeParams.langId + "&URL=" + encodeURIComponent(currentURL);
      
    3. Replace this method with the following:
      this.redirectToSignOn = function() {
      // 3 scenario's are possible
      /* 
      *   Scenario 1 - Current Page Loaded with HTTP
      *                In this case, the page will be reloaded with HTTPS and globalLogIn panel is opened up.
      *                GlobalLoginJS.updateGlobalLoginSignInContent does this work and uses WC_RedirectToPage_xxx cookie to
      *                identify the page to display after logIn.
      *   Scenario 2 - Current page is loaded with HTTPS and signIn panel is already loaded.
      *                In this case, before displayiong signIn panel, update the URL field value of the signIn panel form.
      *   Scenario 3 - Current page is laoded with HTTPS, but signIn panel is NOT yet loaded.
      *                Ajax call is made to load the panel. Send reload URL as part of the ajax call, based on WC_RedirectToPage_xxx cookie value.
      */
      var currentURL = document.location.href; 
      var widgetId = 'Header_GlobalLogin'; // This widgetId is defined in Header_UI.jspf / GlobalLoginActions.js / UserTimeoutView.jsp 
      dojo.cookie("WC_RedirectToPage_"+WCParamJS.storeId, currentURL , {path:'/'}); 
      GlobalLoginJS.InitHTTPSecure(widgetId);
      };
      
    4. Save and close the file.
    1. Open the workspace/Stores_v7/WebContent/Widgets_701/Common/ShoppingList/ShoppingList_UI.jspf Java server page fragment file for editing.
    2. Locate the following block of code:
      <div role="menuitem" id="<c:out value="${param.parentPage}"/>ShoppingList_0" class="created_list" 
      onfocus="javascript:shoppingListJS<c:out value="${param.parentPage}"/>.focusList(0);"
      onblur="javascript: this.className = 'created_list';"
      onclick="shoppingListJS<c:out value="${param.parentPage}"/>.redirectToSignOn();">
      <a class="tlignore" id="<c:out value="${param.parentPage}"/>ShoppingListLink_0" href="javascript:shoppingListJS<c:out value="${param.parentPage}"/>.redirectToSignOn();"
      onfocus="javascript:shoppingListJS<c:out value="${param.parentPage}"/>.focusListLink(0);"
      role="menuitem" title="<fmt:message key='SL_SIGN_IN_OR_REGISTER_TO_ACCESS_LIST' bundle='${widgetText}' />"><fmt:message key="SL_SIGN_IN_OR_REGISTER" bundle="${widgetText}" /></a>
      </div>
      
    3. Replace it with the following:
      <div role="menuitem" id="<c:out value="${param.parentPage}"/>ShoppingList_0" class="created_list"
      onfocus="javascript:shoppingListJS<c:out value="${param.parentPage}"/>.focusList(0);"
      onblur="javascript: this.className = 'created_list';">
      <a class="tlignore" id="<c:out value="${param.parentPage}"/>ShoppingListLink_0" onClick="javascript:shoppingListJS<c:out value="${param.parentPage}"/>.redirectToSignOn();"
      onfocus="javascript:shoppingListJS<c:out value="${param.parentPage}"/>.focusListLink(0);"
      role="menuitem" title="<fmt:message key='SL_SIGN_IN_OR_REGISTER_TO_ACCESS_LIST' bundle='${widgetText}' />"><fmt:message key="SL_SIGN_IN_OR_REGISTER" bundle="${widgetText}" /></a>
      </div>
      
    4. Save and close the file.
    1. Open the workspace/Stores_v7/WebContent/Widgets_701/com.ibm.commerce.store.widgets.GlobalLogin/javascript/GlobalLogin.js javascript file for editing.
    2. Locate the method displayPanel:function(widgetId):
      displayPanel:function(widgetId){
              //check if the sign in panel is loaded. if loaded, toggle the dropdown. Else, trigger a refresh.
              var domAttr = require("dojo/dom-attr");
              var widgetNode = dojo.byId(widgetId);
              if(widgetNode != null){
                      var panelLoaded = domAttr.get(widgetId, "panel-loaded");
                      if(panelLoaded != null && panelLoaded){
                              this.togglePanel(widgetNode);
                      } else {
                              if(!submitRequest()){
                                     return;
                              }
                              cursor_wait();
                              wc.render.updateContext("GlobalLogin_context",{"displayContract":"false", "widgetId" : widgetId});
                      }
              }
      },
      
    3. Replace the method with the following:
      displayPanel:function(widgetId){
              var redirectToPageName = dojo.cookie("WC_RedirectToPage_" + WCParamJS.storeId);
              //check if the sign in panel is loaded. if loaded, toggle the dropdown. Else, trigger a refresh.
              var domAttr = require("dojo/dom-attr");
              var widgetNode = dojo.byId(widgetId);
              if (widgetNode != null) {
              var panelLoaded = domAttr.get(widgetId, "panel-loaded");
              if (panelLoaded != null && panelLoaded) {
                // Change the URL to display after successfull logOn.
              if (redirectToPageName != null && typeof redirectToPageName != "undefined") {
                var globalLogInForm = document.getElementById(widgetId + "_GlobalLogon");
               if (globalLogInForm != null && typeof globalLogInForm != "undefined") {
               globalLogInForm.URL.value = redirectToPageName;
              dojo.cookie("WC_RedirectToPage_" + WCParamJS.storeId, null, {expires: -1, path: "/"});
              }
               }
              this.togglePanel(widgetNode);
              } else if (typeof isOnPasswordUpdateForm === "undefined" || isOnPasswordUpdateForm == false) {
               if (!submitRequest()) { return; }
              cursor_wait();
              wc.render.updateContext("GlobalLogin_context", { displayContract: "false",  widgetId: widgetId, redirectToPageName: redirectToPageName });
               }
              }
      },
      
    4. Save and close the file.
    1. Open the workspace/Stores_v7/WebContent/Widgets_701/com.ibm.commerce.store.widgets.GlobalLogin/javascript/GlobalLoginControllers.js javascript file for editing.
    2. Locate the first instance line of the code:
      GlobalLoginJS.displayPanel(dojo.byId(widget.id));
    3. Replace the line with following:
      GlobalLoginJS.displayPanel(widget.id);
    4. Save and close the file.
    1. Open the workspace/Stores_v7/WebContent/Widgets_701/Common/ShoppingList/ShoppingList_Data.jspf Java server page fragment file for editing.
    2. Locate the following block of code:

      <c:set var="search01" value="'"/>
      <c:set var="search02" value='"'/>
      <c:set var="replaceStr01" value="\\\\'"/>
      <c:set var="replaceStr02" value='\\\\"'/>
      
      <c:set var="escapedSingleQuote" value="\\\\'"/>
      
    3. Replace it with following block of code:
      <c:set var="search01" value="'"/>
      <c:set var="search02" value='"'/>
      <c:set var="replaceStr01" value="\\\\'"/>
      <c:set var="replaceStr02" value='\\\\"'/>
      <c:set var="replaceStr001" value="&#039;"/>
      <c:set var="escapedSingleQuote" value="\\\\'"/>
      
    4. Locate the following line of code:
      <c:set var="catEntryParams" value="{id: '${uniqueID}', name: '${fn:replace(catalogEntryView.name, search01, replaceStr01)}', image: '${fn:replace(shoppingListImage, search01, replaceStr01)}', type: '${type}', components: {${componentItems}}, skus: [${skus}]}"/>
    5. Replace the line with following code:
      <c:set var="catEntryParams" value="{id: '${uniqueID}', name: '${fn:replace(catalogEntryView.name, search01, replaceStr001)}', image: '${fn:replace(shoppingListImage, search01, replaceStr01)}', type: '${type}', components: {${componentItems}}, skus: [${skus}]}"/>
    6. Save and close the file.
  1. Restart the Transaction server.