M
meltedown
I'm trying to keep track of how many items of each price are sold so if
4 items of the same price are ordered one is free.
for example,
5 items at $17 , and 8 items at $4
In php, I would just make an array:
myarray[$dollars]+=$items;
This would make an array like:
myarray[17]=5
myarray[8]=4
then I would iterate through the array with foreach:
foreach(myarray as $dollars=>$items){
//for every 3 items at this price, add $dollars to $discount
}
$total-=$discount;
I beleive I have made a similar javascript array with
myarray[unit.value]=qty.value;
But how do I iterate through this array ?
4 items of the same price are ordered one is free.
for example,
5 items at $17 , and 8 items at $4
In php, I would just make an array:
myarray[$dollars]+=$items;
This would make an array like:
myarray[17]=5
myarray[8]=4
then I would iterate through the array with foreach:
foreach(myarray as $dollars=>$items){
//for every 3 items at this price, add $dollars to $discount
}
$total-=$discount;
I beleive I have made a similar javascript array with
myarray[unit.value]=qty.value;
But how do I iterate through this array ?