<commit_before>'use strict';

angular.module('mean.products').service('shoppingCart', ['$resource', 'Items',
  function($resource, Items) {
  	var cart = {
  		loaded: false,
  		items: [],
  		count: function(){
  			var $this = this;
  			var count = 0;
  			for(var i in $this.items){
  				var item = $this.items[i];
  				if(item && item.quantity){
  					count += item.quantity;
  				}
  			}
  			return count;
  		},
  		total: function(){
  			var total = 0;
  			var $this = this;
  			$this.loadItems();
  			angular.forEach($this.items, function(item, key){
  				if(item && item.quantity){
	  				total += (item.price_in_cents * item.quantity)/100;
  				}
  			});
  			return total;
  		},
	  	addItem: function(product){
	  		var $this = this;
  			var item = $this.findItem(product._id);

  			if(item){
	  			console.log('addItem');
		  		console.log(item.quantity);
  				item.quantity += 1;
  				console.log(item.quantity);

  				item.$update();
  			}else{
  				console.log('adddddItem......');
	  			item = new Items({
	  				product: product._id,
	  				quantity: 1<commit_msg>fix bug price<commit_after>'use strict';

angular.module('mean.products').service('shoppingCart', ['$resource', 'Items',
  function($resource, Items) {
  	var cart = {
  		loaded: false,
  		items: [],
  		count: function(){
  			var $this = this;
  			var count = 0;
  			for(var i in $this.items){
  				var item = $this.items[i];
  				if(item && item.quantity){
  					count += item.quantity;
  				}
  			}
  			return count;
  		},
  		total: function(){
  			var total = 0;
  			var $this = this;
  			$this.loadItems();
  			angular.forEach($this.items, function(item, key){
  				if(item && item.quantity){
	  				total += (item.product.price_in_cents * item.quantity)/100;
  				}
  			});
  			return total;
  		},
	  	addItem: function(product){
	  		var $this = this;
  			var item = $this.findItem(product._id);

  			if(item){
	  			console.log('addItem');
		  		console.log(item.quantity);
  				item.quantity += 1;
  				console.log(item.quantity);

  				item.$update();
  			}else{
  				console.log('adddddItem......');
	  			item = new Items({
	  				product: product._id,
	  				quantity: 1
{'fraction_non_alphanumeric': 0.1638086642599278, 'fraction_numerical': 0.00631768953068592, 'mean_word_length': 2.2317784256559765, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '920577', 'n_tokens_mistral': 987, 'n_tokens_neox': 844, 'n_words': 153}