There are a few different situations you may encounter where you will need to wait for a SuiteCommerce page to finish loading before running your code. Reasons could include:
Various parts of the site implement “afterShowContent” functions and listeners. See the examples below for which may work best for your use case. This code should almost always be written in an entry point file or function run in an entry point file.
define('Example.EntryPoint',
[],
function (){
'use strict';
return {
mountToApp: function mountToApp (container) {
//Wait for the PDP to load to ensure you have access to the item data
const PDP = container.getComponent('PDP');
PDP.on('afterShowContent',function() {
let itemInfo = PDP.getItemInfo();
});
//Similar logic applies to the PLP
const PLP = container.getComponent('PLP');
PLP.on('afterShowContent',function() {
let items = PDP.getItemsInfo();
});
//The general site layout components can be used to run
//code after any page site wide has finished loading
const Layout = container.getComponent('Layout');
Layout.on('afterShowContent',function(viewName) {
//do someting here
});
}
};
});We like to update our blogs and articles to make sure they help resolve any troubleshooting difficulties you are having. Sometimes, there is a related feature to enable or a field to fill out that we miss during the instructions. If this article didn't resolve the issue, please use the chat and let us know so that we can update this article!
If you have questions about how our team can support your business as you implement NetSuite or SuiteCommerce, feel free to contact us anytime. Anchor Group is a certified Oracle NetSuite Alliance Partner and Commerce Partner equipped to handle all kinds of NetSuite and SuiteCommerce projects, large or small!

Related Articles:
Tagged with Training