Goedemorgen allen,
Ik wil graag de waarde total_price opslaan in databasetabel order, kolom total_price.
Hoe kan ik dat doen?
<script type="text/javascript">
$(document).ready(function() {
$('.order_count').on('input', function() {
$('#total_price').html(0);
$('.order_count').each(function( index ) {
var current_value = $(this).val();
var cost_price = $(this).attr('data-cost-price');
var unit = $(this).attr('data-unit');
var stripped_cost_price = cost_price.replace(/\u20ac/g, '');
var stripped_cost_price = stripped_cost_price.replace(',-', ',00');
var stripped_cost_price = stripped_cost_price.replace(',', '.');
unit = unit > 0 ? unit : 1;
if(current_value != "" && current_value > 0)
{
var sub_total = (parseFloat(current_value) * parseFloat(stripped_cost_price)) * unit;
var current_total = $('#total_price').html();
var current_total = current_total.replace(/\u20ac/g, '');
var current_total = current_total.replace(',-', ',00');
var current_total = current_total.replace(',', '.');
if(current_total != "" && current_total > 0)
{
var current_total_float = parseFloat(current_total);
var sub_total_float = parseFloat(sub_total);
var sub_total = current_total_float + sub_total_float;
var current_total = $('#total_price').html(parseFloat(sub_total));
}
else
{
var current_total = $('#total_price').html(parseFloat(sub_total));
}
}
});
var rounded_total = $('#total_price').html();
var float_total = parseFloat(rounded_total).toFixed(2);
$('#total_price').html('€ '+float_total);
if(rounded_total > 200)
{
$('#shipment_message').html('U heeft het minimum bedrag voor franco levering bereikt!')
}
else{
$('#shipment_message').html('Franco levering vanaf €200,00');
}
});
$(window).keydown(function(event){
if(event.keyCode == 13) {
event.preventDefault();
return false;
}
});
});
</script>
PS: hoe zorg ik ervoor dat bovenstaande netjes wordt weergegeven?
Alvast bedankt!
2.432 views