wojodesign / simplecart-js

A simple javascript shopping cart that easily integrates with your current website.
simplecartjs.org
1.79k stars 489 forks source link

increment quantity #537

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hi guys, i trying increment quantity by

var item = simpleCart.find({ id: id })
item.quantity(10)

by console log i see that item was searched correctly, but i got item.quantity is not a function, when try to update this some my other code for be more correct:

simpleCart({
    cartColumns: [
        { view: function(item, column){ return `<img src="${item.get('img')}" alt="" class="order-img">` } , attr: "img", label: false},
        {attr: "name", label: "Наименование"},
        {view: "decrement", label: "-", text: `<img src="img/icons/minus.svg" alt="" class="calc-ico">`},
        { view: function(item, column){ 
            var price = item.quantity()
            var id = item.get('id')
            return `<div contenteditable="true" onkeyup="myFunction(this)" id="${id}" class="total-element">${price}</div>`
        } , attr: "custom", label: false},,
        {view: "increment", label: "+", text: `<img src="img/icons/plus.svg" alt="" class="calc-ico">`},
        { attr: "total" , label: "SubTotal", view: 'currency' },
        {view: "remove", label: "X", text: `<img src="img/icons/reset.svg" alt="" class="reset">`}
    ],
    cartStyle: "div"
});
function myFunction(q){
 var id = q.id
 var number = $('#' + id).text()
 var item = simpleCart.find({ id: id })
item.quantity(number)
}

And what i'm exactly whant? i want just editable quantity of item What i'm doing wrong?