Hey all, I am trying to iterate through the custom...
# suitecommerce
k
Hey all, I am trying to iterate through the customer segments and if it is equal to a specific ID, then show a different logo in the header. I am getting different behavior on this extension between local/production and the homepage/account pages. Am I going about this correctly? I sometimes see errors for unable to map objects in
getCustomerSegments
but it isn't consistent.
Copy code
{
    "use strict";
    return {
      mountToApp: function (container) {
        var Layout = container.getComponent("Layout");
        var userProfile = container.getComponent('UserProfile');
        var alternateLogo = false;
        if (userProfile.length) {
          userProfile.getCustomerSegments().then(function (customerSegments) {
          for (i = 0; i < customerSegments.length; i++) {
            console.log("Customer Segment ID: " + customerSegments[i].id);
            if (customerSegments[i].id == '1338793') {
              console.log("Cutomer segment is equal to 1338793, setting alternateLogo boolean to true");
              alternateLogo = true;
            }
          }
        });
        }
        Layout.addToViewContextDefinition('Header.Logo.View', 'CustomModule', 'object', function (context) {
          //console.log("Context console log for Header Logo View: " + JSON.stringify(context));
          return {
            alternateLogo
          };
        })
      }
    }
  }
s
So I am aware of a particular bug with the user profile component where it doesn't update if the user logs in and doesn't refresh or cross a touchpoint. Are you finding this scenario where the user logs in at checkout and then stays in the checkout?
😅 1
k
This could be part of what is going on... I still get mixed results after a refresh however.
I have been testing on the homepage, and product pages
s
Well, one diagnostic we had for tracking down this issue was to compare results to what was returned by the UserProfile component and what was returned by Profile.Model.getInstance()
While the component does remap/rename some properties and values, they should roughly 'match'
But if you get something very obviously wrong, then you're probably hitting the same bug
👍 1
k
I have created a ticket.