e commerce - MEAN stack - aggregating quantity -


i building simple ecommerce website , want improve 1 section. problem here once user adds 1 particular product cart twice, basket not display product quantity 2, rather displaying in separate rows, quantity 1 each. can me part has fixed?

for example, duplicate rows of same product

below flow of code.

from html,

<div class="add-to-basket">     <select ng-model="qty">         <option value="">qty</option>         <option data-ng-repeat="i in [1,2,3,4,5,6,7,8,9,10]" ng-selected="$first">         {{i}}</option>     </select>     <input type="submit" value="add basket" ng-click="addtobasket(product)"/>               </div> 

from controller,

$scope.addtobasket = function(product) {         basketitems.addone(product._id, $scope.qty, product.title, product.price, function(err, data) {             $scope.$emit('basketupdate');             if (err) {                 alert(err);                 return;             }         });     }; 

from service,

basketservice.addone = function(id, qty, title, price, callback) {             caller = this;             $http({                 method: 'post',                 url: '/api/cart/add/',                 data: {                     id : id,                     qty : parseint(qty),                     title : title,                     price : price                 }             }).success(function(data) {                 //setitemcount(10);                 caller.itemcount = data.itemcount;                 caller.broadcastitemcount();                 console.log(data)                 callback(null, data);             }).error(function(err) {                 callback(err);             });         };         return basketservice; 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -