Discussions

Ask a Question
Back to All

Error with Ecwid.OnPageLoaded.add(function(page)

I'm trying to insert a custom javascript to my starter site, but the logs keep showing the following error:
"TypeError: Cannot read properties of undefined (reading 'add')"

Ecwid.OnPageLoaded.add(function(page){
  if (page.type === 'PRODUCT' && page.name && page.name.toLowerCase().includes("CONDITION")) {
    console.log("This is a CONDITION product page.");
    window.ec = window.ec || {};
    window.ec.storefront = window.ec.storefront || {};
    window.ec.storefront.product_details_layout = "TWO_COLUMNS_SIDEBAR_ON_THE_LEFT";
    Ecwid.refreshConfig();
  }
});

What am I doing wrong?