Im trying to replace the Logo in a custom extensio...
# suitecommerce
k
Im trying to replace the Logo in a custom extension using the PCV and user segments. It seems to work fine on my local, but when I deploy and activate the extension, the SC config settings page is unreachable. Deactivating the extension restores access to the settings so I know it's a problem with the extension, however no error messages. Any thoughts as to what might be wrong with the code below? It's pretty simply so im not sure why it would be failing or where:
Copy code
define("FWC.Extension", ["underscore", "Utils", "FWCLogo.View"], function (_, Utils, FWCLogoView) {
  {
    "use strict";
    return {
      mountToApp: function (container) {
        var Layout = container.getComponent("Layout");
        var UserProfile = container.getComponent('UserProfile');

        if (Layout) {
          Layout.removeChildView('Header.View', 'Header.Logo', 'Header.Logo');
          Layout.addChildView('Header.Logo', function(){
            return new FWCLogoView({application:container})
          })
        }
      }
    }
  }
});
Copy code
define('FWCLogo.View', [
    'SCView',
    'header_logo.tpl'
], function (
    SCViewModule,
    header_logo_tpl
) {
    'use strict';

    var SCView = SCViewModule.SCView;

    function FWCView(options) {
        SCView.call(this, options);

        this.template = header_logo_tpl;
        var self = this;
        this.application = options.application;
        var UserProfile = this.application.getComponent('UserProfile')
        this.useAlternateLogo = false;

        UserProfile.getCustomerSegments().then(function (segments) {
            var customerSegments = segments;
            for (i = 0; i < customerSegments.length; i++) {
                if (customerSegments[i].id == 1338793) {
                    self.useAlternateLogo = true;
                }
            }
            self.trigger('CustomerSegmentsLoaded');
        });

        this.on('CustomerSegmentsLoaded', this.render)
    }

    FWCView.prototype = Object.create(SCView.prototype);
    FWCView.prototype.constructor = FWCView;

    FWCView.prototype.render = function () {
        SCView.prototype.render.call(this)
    }

    FWCView.prototype.getContext = function () {
        return {
            alternateLogo :  this.useAlternateLogo
        }
    }

    return FWCView
})
s
Just so I understand, you mean the SuiteCommerce > Websites > Configuration page? This JavaScript is unlikely to affect that. Are you also including configuration JSON in your extension?
k
Yes
I think its an issue with my manifest
s
That was going to be my second guess
k
Ok that is fixed. The customer segments work fine on Shopping pages, but My Account and Checkout, they do not.
It duplicates the logo for some reason.
s
Can I ask why you're removing the entire logo view and replacing it, and not just rewriting the image's URL?
k
I tried that but was running into the issues mentioned above, so I thought rehydrating a new view completely would resolve this bug.
Figured it was an issue with the PCV or customer segments method
s
There probably is an execution order challenge, but I would have thought you could have told it to re-render once available.
Anyway, I am not here to solutionise (word?) I can't answer your specific question. I have seen an issue where UserProfile is not updated if a customer does not cross a touchpoint / refreshes the page
When in MA/checkout, if you refresh after logging in, does it work?
k
Nope. It actually displays the original logo only instead now and does not duplicate them.
Just shows the old/original logo in My Account
Any thoughts? @Steve Goldberg
s
Nope, sorry