Нужно передать значение total_price в data: {items: items, total: total_price, подскажите как?
$(document).on('change', 'input.itemsInv', function(){
var price = parseFloat($(this).data('item-price'));
var total_price = parseFloat($(".Q131bgfh4vn").text());
if($(this).prop('checked') == true)
total_price = total_price + price;
else
total_price = total_price - price;
$(".Q131bgfh4vn").text(total_price.toFixed(2));
});
$("#sendTradeOfferForPay").on('click', function(){
var str;
var items = [];
$(".itemsInv:checked").each(function(index,item){
items.push({classid:$(item).data('item-class'), price: $(item).data('item-price'), assetid: $(item).data('item-id')});
});
if(!items.length)
return false;
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: "/api/pay",
type: 'POST',
dataType: 'json',
data: {items: items, total: total_price, steamid: $("#itemsContainer").data('steamid'), token: $("#itemsContainer").data('token') },
success: function(data) {
$("#itemsContainer").find(".modalText").html('<span style="font-size: 18px;color: rgb(192, 255, 0);border-bottom-width: 1px;border-bottom-style: dashed;border-bottom-color: rgb(192, 255, 0);cursor: pointer;display:none;" class="tradeOfferResponse"><br><a href="#" style="color: rgb(192, 255, 0);text-decoration: none;" target="_blank">>>> SEND SKINS <<<</a></span><div id="timevalue"><div class="sk-spinner sk-spinner-double-bounce"><div class="sk-double-bounce1"></div><div class="sk-double-bounce2"></div></div><br>Create trade, please wait...</div>');
}
});
});