Created
July 31, 2014 13:55
-
-
Save orlaqp/ff1af1b523efc2dffff5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function editExistingVarient() { | |
var variantIdentifier = $scope._getVariantIdentifiersBase(); | |
//no product exists with this combination of varient, lets add it to the array. | |
var productIdCounter = 1; | |
var productSku = 0; | |
var barcode = 0; | |
var barcode2 = 0; | |
var counter = 1; | |
var skuCounter = 100; | |
var barcodeCounter1 = 100; | |
var barcodeCounter2 = 101; | |
var variantValues = variantIdentifier; | |
_.forEach(variantIdentifier, function(variant) { | |
var productWithVariant = _.find($scope.product.products, function(product) { | |
return product.variants[0] == variant[0] && product.variants[1] == variant[1]; | |
}); | |
if (!productWithVariant) { | |
$scope.product.products.push(_createProductVariant(variant)); | |
} else { | |
//product is found in the combination so lets not remove it | |
productWithVariant.removeFlag = true; | |
} | |
}); | |
//remove any item that was added or found to be in the combination | |
$scope.product.products = _.remove($scope.product.products, function(product) {return product.removeFlag;}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment