Why is this session value not incrementing?
This is my buy one, get one for a penny. I get one item for a penny but the next item that is supposed to be a penny, doesn't add it's discount. In other words, the session variable "penny" is not incrementing. What am I doing wrong?
<?php
$BuyOne = array();
$GetOne = array();
$_SESSION["penny"] = 0;
for ($n=0; $n<sizeof($pfgbest->Items); $n++) {
if (floatval($pfgbest->Items[$n]->ItemDiscounts) < 1) {
for ($x=0; $x<intval($pfgbest->Items[$n]->Quantity); $x++) {
$BuyOne[] = floatval($pfgbest->Items[$n]->Price);
}
}
if (floatval($pfgbest->Items[$n]->ItemDiscounts) > 0) {
for ($x=0; $x<intval($pfgbest->Items[$n]->Quantity); $x++) {
$GetOne[] = floatval($pfgbest->Items[$n]->ItemDiscounts);
}
}
}
rsort($BuyOne);
rsort($GetOne);
for ($x=0; $x<sizeof($BuyOne); $x++) {
for ($y=0; $y<sizeof($GetOne); $y++) {
if ($BuyOne[$x] >= $GetOne[$y] && $GetOne[$y] != 0) {
$_SESSION["penny"] += $GetOne[$y];
$GetOne[$y] = 0;
break;
}
}
}
if ($_SESSION["penny"] > 0) {
$_SESSION['discountcode'] = "clearancePenny";
}
?>