|
|
|
|
|
|
|
|
var pricesArray = product.prices; |
|
|
var pricesArray = product.prices; |
|
|
var unitCoefficient = product.unit_coefficient; |
|
|
var unitCoefficient = product.unit_coefficient; |
|
|
|
|
|
|
|
|
if (theQuantity) { |
|
|
|
|
|
theQuantity = theQuantity / unitCoefficient; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if(pricesArray && unitCoefficient) { |
|
|
|
|
|
if (theQuantity) { |
|
|
|
|
|
theQuantity = theQuantity / unitCoefficient; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
for (var i = 0; i < pricesArray.length; i++) { |
|
|
|
|
|
if(pricesArray[i]) { |
|
|
|
|
|
var price = pricesArray[i].price; |
|
|
|
|
|
var fromQuantity = pricesArray[i].from_quantity; |
|
|
|
|
|
|
|
|
for (var i = 0; i < pricesArray.length; i++) { |
|
|
|
|
|
if(pricesArray[i]) { |
|
|
|
|
|
var price = pricesArray[i].price; |
|
|
|
|
|
var fromQuantity = pricesArray[i].from_quantity; |
|
|
|
|
|
|
|
|
if (price < thePrice && fromQuantity <= theQuantity) { |
|
|
|
|
|
thePrice = price; |
|
|
|
|
|
|
|
|
if (price < thePrice && fromQuantity <= theQuantity) { |
|
|
|
|
|
thePrice = price; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |