getElementsByClassName
возвращает массив.
Попробуйте следующее:
leftSection = document.getElementsByClassName('js-detail-product')[0],
leftSectionTop = leftSection.getBoundingClientRect().top,
rightSection = document.getElementsByClassName('js-product-info-main')[0],
rightSectionHeight = rightSection.getBoundingClientRect().height;
Или, возможно, для большей безопасности:
document.addEventListener("DOMContentLoaded", function () {
allLeftSections = document.getElementsByClassName('js-detail-product');
if(allLeftSections.length > 0) {
leftSection = allLeftSections[0],
leftSectionTop = leftSection.getBoundingClientRect().top,
}
allRightSection = document.getElementsByClassName('js-product-info-main');
if(allRightSection.length > 0) {
rightSection = allRightSection[0],
rightSectionHeight = rightSection.getBoundingClientRect().height;
}
});