|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
oneProductOrdered: function() { |
|
|
oneProductOrdered: function() { |
|
|
for(var key in this.products) { |
|
|
for(var key in this.products) { |
|
|
if(this.products[key].quantity_form > 0) { |
|
|
|
|
|
|
|
|
if(this.isProductAvailable(this.products[key]) |
|
|
|
|
|
&& this.products[key].quantity_form > 0) { |
|
|
return true ; |
|
|
return true ; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
countProductOrdered: function() { |
|
|
countProductOrdered: function() { |
|
|
var count = 0 ; |
|
|
var count = 0 ; |
|
|
for(var key in this.products) { |
|
|
for(var key in this.products) { |
|
|
if(this.products[key].quantity_form > 0) { |
|
|
|
|
|
|
|
|
if(this.isProductAvailable(this.products[key]) |
|
|
|
|
|
&& this.products[key].quantity_form > 0) { |
|
|
if(this.products[key].unit != 'piece') { |
|
|
if(this.products[key].unit != 'piece') { |
|
|
count ++ ; |
|
|
count ++ ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var price = 0 ; |
|
|
var price = 0 ; |
|
|
for(var key in this.products) { |
|
|
for(var key in this.products) { |
|
|
var quantity = this.products[key].quantity_form; |
|
|
var quantity = this.products[key].quantity_form; |
|
|
if(quantity > 0) { |
|
|
|
|
|
|
|
|
if(this.isProductAvailable(this.products[key]) && quantity > 0) { |
|
|
price += (quantity / this.products[key].unit_coefficient) * this.getBestProductPrice(this.products[key].id, this.products[key].quantity_form); |
|
|
price += (quantity / this.products[key].unit_coefficient) * this.getBestProductPrice(this.products[key].id, this.products[key].quantity_form); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
getProductsArray: function() { |
|
|
getProductsArray: function() { |
|
|
var productsArray = {} ; |
|
|
var productsArray = {} ; |
|
|
for(var key in this.products) { |
|
|
for(var key in this.products) { |
|
|
if( this.products[key].quantity_form != null && |
|
|
|
|
|
this.products[key].quantity_form > 0) { |
|
|
|
|
|
|
|
|
if( this.isProductAvailable(this.products[key]) |
|
|
|
|
|
&& this.products[key].quantity_form != null |
|
|
|
|
|
&& this.products[key].quantity_form > 0) { |
|
|
|
|
|
|
|
|
productsArray[this.products[key].id] = this.products[key].quantity_form ; |
|
|
productsArray[this.products[key].id] = this.products[key].quantity_form ; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |