javascript - Check if property quantity is > 1 then push price * quantity -


the function below loops through properties of objects in var input example

[{     name: 'nagellack 15 ml 2 2',     id: '1057290002',     price: '1.9',     brand: 'a.o.n.',     quantity: 1 }, {     name: 'ceramic nail lacquer 6 ml coral reef coral reef',     id: '1027410001',     price: '6.9',     brand: 'artdeco',     quantity: 1 }] 

and pushes new objects into

products_list [] 

i'm trying set condition checks when quantity of object > 1 , multiplies price quantity. issue here is, price of 1 product although there quantity of 2.

i don't know best place in code set condition.

function() {     var input = {{dl_purchase_products}};     var products_list = [];         for(i=0;i<input.length;i++){         products_list.push({             id: input[i].id.slice(0,6),             price: input[i].price,  <---- should price 2              quantity: input[i].quantity         });         }     return products_list; } 

thanks lot!

best regards, anton

multiply price quantity.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -