Gustavo Luigi 2022-09-01 16:49:45 +02:00
parent 5321304dde
commit f15af3bae0
1 changed files with 14 additions and 10 deletions

View File

@ -5,7 +5,6 @@
@stop @stop
@section('content') @section('content')
<div class="container"> <div class="container">
<<<<<<< HEAD
@if(true) @if(true)
<div class="row"> <div class="row">


@ -75,7 +74,6 @@
</div> </div>
<!-- Calendly inline widget end --> <!-- Calendly inline widget end -->
</div> </div>
=======
<div style="display: none;" class="col-12 text-center" id="no-products-in-checkout"> <div style="display: none;" class="col-12 text-center" id="no-products-in-checkout">
<br> <br>
<br> <br>
@ -94,9 +92,8 @@
<br> <br>
<div class="alert alert-success">{{session()->get('success')}}</div> <div class="alert alert-success">{{session()->get('success')}}</div>
<br> <br>
>>>>>>> 34c1696f24b5a829bac5e7a90220349835cf2765
@else @else
<section> <section id="form-section" style="display: none;">
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<h1 class="mb-5">Angebot anfragen</h1> <h1 class="mb-5">Angebot anfragen</h1>
@ -250,7 +247,7 @@
} }
function initialize() { function initialize() {
let input = document.getElementById('field_location'); let input = document.getElementById('field_location');
let options = { let options = {
types: ['address'], types: ['address'],
componentRestrictions: { country: "de" } componentRestrictions: { country: "de" }
}; };
@ -306,8 +303,9 @@
}, },
utilsScript: "{{storage('assets/libs/intl-tel-input/js/utils.min.js')}}", utilsScript: "{{storage('assets/libs/intl-tel-input/js/utils.min.js')}}",
}); });
$(window).on('load', function(){
function updateProducts(){
$('#list-products').html('');
if(objProducts.length > 0) { if(objProducts.length > 0) {
let ids = objProducts.map(obj => obj.id); let ids = objProducts.map(obj => obj.id);
$.get($('meta[name="get-contents"]').attr('content')+"/"+ids.join(","), function(response, status){ $.get($('meta[name="get-contents"]').attr('content')+"/"+ids.join(","), function(response, status){
@ -328,30 +326,36 @@
if(objProductInfo.quantity == i) elementProduct += `<option selected value="${i}">Anzahl: ${i}</option>`; if(objProductInfo.quantity == i) elementProduct += `<option selected value="${i}">Anzahl: ${i}</option>`;
else elementProduct += `<option value="${i}">Anzahl: ${i}</option>`; else elementProduct += `<option value="${i}">Anzahl: ${i}</option>`;
} }
totalPrice += item.data_fields.preis*objProductInfo.quantity;
elementProduct += ` elementProduct += `
</select> </select>
<button data-id="${item.id}" class="btn-remove-product text-muted small text-decoration-none" style="padding: 0; border: none; background: transparen;">Löschen</button> <button data-id="${item.id}" class="btn-remove-product text-muted small text-decoration-none" style="padding: 0; border: none; background: transparen;">Löschen</button>
</td> </td>
<td class="align-middle text-end">${formatter.format(item.data_fields.preis)}</td> <td class="align-middle text-end">${formatter.format(item.data_fields.preis)}</td>
</tr>`; </tr>`;
$('#list-products-in-bag').append(elementProduct); $('#list-products').append(elementProduct);
}); });
$('#total-price').text(formatter.format(totalPrice)); $('#total-checkout-price').text(formatter.format(totalPrice));
}); });
$('#form-section').show();
$('#list-products').parent().parent().parent().parent().parent().find('.modal-footer').show(); $('#list-products').parent().parent().parent().parent().parent().find('.modal-footer').show();
$('#total-checkout-price').parent().parent().parent().show(); $('#total-checkout-price').parent().parent().parent().show();
$('#no-products-in-checkout').hide(); $('#no-products-in-checkout').hide();
}else { }else {
$('#form-section').hide();
$('#list-products').parent().parent().parent().parent().parent().find('.modal-footer').hide(); $('#list-products').parent().parent().parent().parent().parent().find('.modal-footer').hide();
$('#total-checkout-price').parent().parent().parent().hide(); $('#total-checkout-price').parent().parent().parent().hide();
$('#no-products-in-checkout').show(); $('#no-products-in-checkout').show();
} }
}


$(window).on('load', function(){
updateProducts();
$('#anfrage').submit(function(){ $('#anfrage').submit(function(){
objProducts = []; objProducts = [];
updateProductsInLocalStorage(); updateProductsInLocalStorage();
}); });
$(document).on('click', '.btn-remove-product', function(){ updateProducts(); });
$(document).on('change', '.select-quantity', function(){ updateProducts(); });
}); });
</script> </script>
@stop @stop