If you need to load a SuiteCommerce dependency based on the users current SSP application, read on.
Occasionally I create an extension crosses the boundaries between the shopping, checkout, and myaccount SSP applications and also needs to be careful about which dependencies load based on the which application the user is working in.
For example, I have a couple of view that are universal to all three applications (shopping, checkout, and myaccount). Packaged along with these view is a special view that applies only to the checkout application.
I can never remember which configuration property to check in order to conditionally load a view. Here is a snippet so I don’t forget in the future.
This snippet will check to make sure you’re in the correct application before attempting to load MyCustomView
.
if (SC.ENVIRONMENT.SCTouchpoint === 'checkout' ||
SC.ENVIRONMENT.SCTouchpoint === 'myaccount') {
var MyCustomView = require('My.Custom.View');
// do your MyCustomView stuff here...
}