Added total price
This commit is contained in:
parent
a47127b4fb
commit
aa921cc88d
2 changed files with 14 additions and 8 deletions
|
|
@ -72,7 +72,11 @@
|
|||
|
||||
</div>
|
||||
|
||||
<button class="button is-success">Cash</button>
|
||||
<p id="totalprice">€ 0</p>
|
||||
|
||||
<button class="button is-success"><i><svg width="90" height="90">
|
||||
<image class="product_image" xlink:href="http://127.0.0.1:8000/icons/cart" width="50" height="50"/>
|
||||
</svg></i></button>
|
||||
<button class="button is-success">Card</button>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ const api_url = "http://127.0.0.1:8000"
|
|||
|
||||
var to_fill_product_index = 0
|
||||
|
||||
var total_price = 0
|
||||
|
||||
async function makeAPIRequest(request) {
|
||||
try {
|
||||
const response = await fetch(request);
|
||||
|
|
@ -38,15 +40,15 @@ async function loadProducts() {
|
|||
|
||||
const product_placeholders = document.getElementsByClassName('product_placeholder')
|
||||
const chosen_product_placeholder = product_placeholders[to_fill_product_index]
|
||||
var image_product = chosen_product_placeholder.getElementsByClassName('product_image')[0]
|
||||
var price_product = chosen_product_placeholder.getElementsByClassName('product_price')[0]
|
||||
const image_product = chosen_product_placeholder.getElementsByClassName('product_image')[0]
|
||||
const price_product = chosen_product_placeholder.getElementsByClassName('product_price')[0]
|
||||
const total_price_holder = document.getElementById("totalprice")
|
||||
|
||||
console.log(chosen_product_placeholder)
|
||||
console.log(image_product)
|
||||
console.log(price_product)
|
||||
total_price += chosen_product.price
|
||||
|
||||
image_product.setAttribute('href', api_url + "/icons/" + chosen_product.image_filename);
|
||||
price_product.textContent = "\u20AC " + chosen_product.price
|
||||
total_price_holder.textContent = "\u20AC " + total_price
|
||||
|
||||
to_fill_product_index += 1
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue