03.12.2015 Views

laravel4cookbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

E-Commerce 262<br />

28<br />

29 var next = products[i];<br />

30<br />

31 if (next.id == product.id) {<br />

32 products.splice(i, 1);<br />

33 }<br />

34<br />

35 }<br />

36<br />

37 this.store();<br />

38<br />

39 },<br />

40<br />

41 "update": function() {<br />

42<br />

43 for (var i = 0; i < products.length; i++) {<br />

44<br />

45 var product = products[i];<br />

46 var raw = product.quantity * product.price;<br />

47<br />

48 product.total = Math.round(raw * 100) / 100;<br />

49<br />

50 }<br />

51<br />

52 this.store();<br />

53<br />

54 },<br />

55<br />

56 "store" : function() {<br />

57 $cookies.products = JSON.stringify(products);<br />

58 },<br />

59<br />

60 "clear" : function() {<br />

61 products.length = 0;<br />

62 this.store();<br />

63 }<br />

64<br />

65 };<br />

66<br />

67 });

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!