Jane, где-то нашел это
$scope.calculateCart = function()
{
var count = 0;
var total = 0;
var totalNoDiscount = 0;
var positions = [];
angular.forEach($scope.limits, function(lim, key) {
lim.qnt = 0;
});
angular.forEach($scope.sections, function(section, key) {
angular.forEach(section.positions, function( item, key) {
if(item.quantity > 0)
{
count += item.quantity*1;
var price = item.quantity * item.price;
totalNoDiscount += price;
if(item.is_discount == 1 && $scope.cart.discount)
price = (price - price * $scope.cart.discount.value / 100);
if(item.type == 1)
$scope.cart.bonus_id = item.id;
item.price_discount = price;
total += price.toFixed(2) * 1;
angular.forEach($scope.limits, function(lim, key) {
if(lim.ids.indexOf(item.id*1) != -1)
lim.qnt += item.quantity*1;
});
}
});
});
$scope.checkLimits();
$scope.cart.count = count;
$scope.cart.total = total;
$scope.cart.totalNoDiscount = totalNoDiscount;
}