Kevin Carpenter
03/02/2022, 12:52 AMCustomer Segments
with the Theme Dev Tools? Or is it limited to only Extensions / methods?
https://system.netsuite.com/help/helpcenter/en_US/APIs/SuiteCommerce/Extensibility/Frontend/UserProfile.html#getCustomerSegmentseminero
03/02/2022, 3:28 AMaddContextDefinition
method from the Layout component. You can pass a single property or an object.Kevin Carpenter
03/04/2022, 7:24 PMeminero
03/04/2022, 8:53 PMKevin Carpenter
03/06/2022, 8:51 PMdefine("FWC.Extension", ["underscore", "Utils"], function (_, Utils) {
{
"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', 'FWCExtras', 'object', function (context) {
//console.log("Context console log for Header Logo View: " + JSON.stringify(context));
return {
alternateLogo
};
})
}
}
}
});
eminero
03/07/2022, 1:14 AMKevin Carpenter
03/07/2022, 2:31 AMeminero
03/07/2022, 1:43 PMalternateLogo
inside the addToViewContextDefinition, if not you will always return false. I do not think there is docs for that, it is more understanding that you have a promise that will not be resolved by the time you return your value.Kevin Carpenter
03/08/2022, 6:04 PMmountToApp: function (container) {
var Layout = container.getComponent("Layout");
if (Layout) {
Layout.addToViewContextDefinition(
"Header.Logo.View",
"FWCExtras",
"object",
function (context) {
//console.log("Context console log for Header Logo View: " + JSON.stringify(context));
var fwc,
alternateLogo = false,
userProfile = container.getComponent('UserProfile');
if (userProfile) {
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;
}
}
});
fwc = {
alternateLogo
}
return fwc;
}
return {};
}
);
}
}Kevin Carpenter
03/08/2022, 6:05 PM