I am injecting HTML and Javascript into every SuiteCommerce page, because SuiteCommerce does not seem to provide a better way to alter functionality and display in the way we need.
In particular, we need to get the internalid of the logged-in user's Customer record and send that with requests to two suitelets to calculate things like unit of measure conversions and freight cost (using full truckload carriers rather than parcels, which is also not supported by NetSuite), so these can give the user an accurate display of what they're buying before they complete checkout.
I got this to work by forcing the page to repeat this instruction:
loadJSON('https://bevsource-sandbox.dev-eidebailly.com/scs/services/ShoppingUserEnvironment.Service.ss?lang=en_US&cur=null&X-SC-Touchpoint=shopping'+googletagmanager_cookie,"shoppingUserEnvironment").done(function(e){merge(SC,e),SC.PROFILE_PROMISE && SC.PROFILE_PROMISE.resolve(SC.ENVIRONMENT.PROFILE)});
and then getting the logged-in user's ID from SC.ENVIRONMENT.PROFILE.internalid
but doing this causes errors to be thrown when the user is NOT logged in to SuiteCommerce, so I need to wrap this in a conditional based on whether they are logged in.
I have been unable to find a reliable variable that shows whether they are logged in. I tried selecting elements from the page that either exist or not when the user is logged in, but that is also not reliable. Sometimes the user has to refresh the page before these elements appear.
I would also rather use something more reliable than the HTML elements being present or absent in the view, in case those change over time.
This is in SuiteCommerce Standard.
I am using an Extension I created in order to inject the HTML and javascript needed onto all SuiteCommerce pages.
The Suitelets are being requested using the logged-in user's credentials (a customer center role) and are not Available Externally.