I'm trying to get the field items(array)
of all my documents Orders
, but I can only get one of my documents field at a time. I want it to show the whole Order
detail as well.
Here is the code I have:
function receiptData() {
document.getElementById("pro").innerHTML = "";
firebase
.firestore()
.collection("orders")
.get()
.then((querySnapshot) => {
querySnapshot.forEach((doc) => {
console.log(doc.id, " => ", doc.data());
var data = doc.id;
for (let i = 0; i < doc.id.length; i++) {
let row = `<tr>
<td><a>${(doc.data().items[i]["productname"])}</a></td>
<td><a>${(doc.data().items[i]["cart_quantity"])}</a></td>
<td class="text-danger"> <a>${doc.data().total_amount}</a> <i class="mdi mdi-arrow-down"></i>
</td>
<td>
<label class="badge badge-danger"><a></a></label>
</td>
</tr>`;
document.getElementById("pro").innerHTML += row;
}
});
});
}