I've only added a bit of the code. The cart_items contains more elements, that is the reason why I've taken it as an array. I've also tried to use multiple methods to select the elements, I've commented out because none of them worked and I wish to stick with the getElementByClassName method. The console log shows empty whenever I run this code. No value for price is shown.
function updateCartTotal() {
var cartItemContainer = document.getElementsByClassName('cart_items')[0]
var cartRows= cartItemContainer.getElementsByClassName('cart_item item_list d-flex flex-lg-row flex-column align-items-lg-center align-items-start justify-content-lg-end justify-content-start')
//var cartRows = cartItemContainer.getElementsByTagName('LI')
//var cartRows = cartItemContainer.getElementsByClassName('cart_item_list')
//console.log(cartItemContainer)
for (var i = 0; i < cartRows.length; i++) {
var cartRow = cartRows[i]
var priceElement = cartRow.getElementsByClassName('product_price product_text')[0]
var price = priceElement.innerText
console.log(price)
}
}
<div class="cart_items">
<ul class="cart_items_list">
<!-- Cart Item -->
<li class="cart_item item_list d-flex flex-lg-row flex-column align-items-lg-center align-items-start justify-content-lg-end justify-content-start">
<div class="product d-flex flex-lg-row flex-column align-items-lg-center align-items-start justify-content-start mr-auto">
<div>
<div class="product_number">1</div>
</div>
<div>
<div class="product_image"><img src="images/cart_item_1.jpg" alt=""></div>
</div>
<div class="product_name_container">
<div class="product_name"><a href="product.html">Cool Flufy Clothing without Stripes</a></div>
<div class="product_text">Second line for additional info</div>
</div>
</div>
<div class="product_price product_text btn btn-danger">Remove</div>
<div class="product_color product_text"><span>Color: </span>beige</div>
<div class="product_size product_text"><span>Size: </span>L</div>
<div class="product_price product_text"><span>Price: </span>$3.99</div>
<div class="product_total product_text"><span>Total: </span>$3.99</div>
</li>
</ul>
</div>