Skip to content

addItem() does not add? #103

@lrkwz

Description

@lrkwz

Since https://github.com/snapjay/ngCart/blob/1.0.0/src/ngCart.js#L47 passes relative = false in inCart.setQuantity()

        this.addItem = function (id, name, price, quantity, data) {

            var inCart = this.getItemById(id);

            if (typeof inCart === 'object'){
                //Update quantity of an item if it's already in the cart
                inCart.setQuantity(quantity, false); // <- shoudn't this be TRUE instead?!
            } else {
                var newItem = new ngCartItem(id, name, price, quantity, data);
                this.$cart.items.push(newItem);
                $rootScope.$broadcast('ngCart:itemAdded', newItem);
            }

            $rootScope.$broadcast('ngCart:change', {});
        };

I strongly believe that quantity never get updated when calling ngCart.addItem() twice for the same item.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions