Four51 / CustomSolutions

Custom Solutions
7 stars 15 forks source link

Add to Cart Preview - dependency on spec that may not be available #21

Closed mmoebeck closed 9 years ago

mmoebeck commented 9 years ago

On line 374 in var _add fn, we are calling a "Color" spec that may not be included in the product.

mmoebeck commented 9 years ago

Here is the fix:

   var _add = function (item, list, success) {
    if (item.Product.IsVBOSS) {
        item.UnitPrice = item.LineTotal / item.Quantity;
        angular.forEach(item.Specs, function(i){
            angular.forEach(i.Options, function (option) {
                if (i.Value === option.Value) {
                    if (option.Markup > 0) {
                        item.Markup = option.Markup;
                    }
                    else {
                        item.Markup = false;
                    }
                }
            });
        });

        item.LineTotal = item.UnitPrice * item.Quantity;
    }
    else {
        priceBreak(item);
    }
    var i = {};
    angular.copy(item, i);
    i.ItemID = randomString();
    list.push(i);
    _then(success, list)
    };