the promote rule:
if buy one each price is $100, if buy >= 2 each price is $90. if buy >=5 each price is $80. if buy >=8 each price is 70…
the json data is dynamic, namely which elements is 1 or 2 or 3 or another: so you don’t know what the value of the price_qty will be.
[{"price_id":"1","website_id":"0","price_qty":2,"price":"90.0000"},
{"price_id":"2","website_id":"0","price_qty":5,"price":"80.0000"},
{"price_id":"3","website_id":"0","price_qty":8,"price":"70.0000"}]
supporsed there is a variable named result, which has the quantity of the product that the visitor will buy.
var result.
now, i want to do: compare the result with the json data (price_qty), then output the whole price. eg: if(result >2) { write the qty is +result, the price is + price.}. how to write the code?
once i used :
var myObject= the json data,
jQuery.each(myObject, function(_index, _item){
var objectInArray = _item;
if(objectInArray.price_qty result)
…
then i don’t know how to do the left.