Copy of sample for cart

  • ×
  • $scope.itemData = <? php echo json_encode($item_array); ?> ; $scope.cart = []; $scope.deleteItem = function (item) { var cart = $scope.cart; var match = getMatchedCartItem(item); if (match.count > 0) { cart.splice(cart.indexOf(item)); return; } } $scope.addItem = function (item) { var match = getMatchedCartItem(item); if (match) { match.count += 1; return; } var itemToAdd = angular.copy(item); itemToAdd.count = 1; $scope.cart.push(itemToAdd); } $scope.incQty = function (item) { var match = getMatchedCartItem(item); if (match) { match.count += 1; return; } } $scope.decQty = function (item) { var cart = $scope.cart; var match = getMatchedCartItem(item); if (match.count > 1) { match.count -= 1; return; } cart.splice(cart.indexOf(item), 1); }