I'm trying to pull a list of items from a shopping cart (a table) and drop it into a WP email form. This code (almost) works - that is, I can see all of the items in the log console. But only the last item shows up in the text area of the form. So, if there's 1 item in the shopping cart, it drops into the textarea box. However if there are 2 items, the second item shows up and the first item doesn't. But I can see both items in the console log.
I'm completely lost by what's happening with the array(s). I've tried, join, concat, and converting the 'allProducts' variable to a string. Nothing changes the output. It seems like it should be simple.
I can't figure out how to combine the output so that everything drops into the textarea field of the form.
Can anyone tell me what I'm missing?
function confirmProducts() {
var product = Array.prototype.slice.call(document.getElementById("cart").getElementsByClassName("cartLink"));
var quantity = Array.prototype.slice.call(document.getElementById("cart").getElementsByClaseName("iquantity"));
for (var i in product, quantity){
var products = product[i].innerHTML;
var quantities = quantity[i].value;
var allProducts = quantities + " " + products;
document.SUPPLY_PURCHASE.yourorder.value = allProducts ;
console.log(allProducts);
}
}