Show the total value of increase and decrease amount of added cart and should be upadate also

51
August 24, 2019, at 09:50 AM

Im doing e-commerce cart application in php laravel, i want to add products to cart completely in ajax and jquery. problem is total amount of products is not adding to cart. i tried my best after adding cart i wanna write rest api post to database

This is for a new Linux server, running MySQL 5, PHP 5 and Apache 2

// var cartButtons = $('.body').find('button');
$('body').on("click",".count",function(e) {
    e.preventDefault();
    var count=$(this).parent().find('input').val()
    if ($(this).data('mode')=='add') {
        count=parseInt(count)+1;
    }
    else {
        count=parseInt(count)-1;
    }
    if (count>=0) {
        $(this).parent().find('input').val(count)
    }
});
$('body').on('click','.add_to_cart',function () {
    var id=$(this).data('id');
    var count=$(this).parents('.grid-item').find('input[name=quantity]').val();
    if (count>0) {
        value = ("id",count);
        console.log(id,value);
    }
    var total = 0;
    $('.body ',value).each( function(){
        total += total+value;
        console.log("aaaaaa");
    });
    $('#cartcount').html(value);
});

i want to add total number of items but it will add only one value

READ ALSO
How to empty a value from the first option of a select box option using javascript or jquery?

How to empty a value from the first option of a select box option using javascript or jquery?

Here's my codeIs it possible to empty the value of the first option using jquery/javascript ?

37
How can I disable button and change the button text on this code?

How can I disable button and change the button text on this code?

I dont know very well jquery/javascript and I am having problems with the code below

26
Getting values from data attribute into an array [duplicate]

Getting values from data attribute into an array [duplicate]

This question already has an answer here:

23