Hello,
I'm actually a fairly experienced programmer with PHP but I do have one problem. When the shopping cart has been submitted and the funds captured, I "empty the cart" like this:
unset($HTTP_SESSION_VARS['shopCart']);
So far so good right? Now if I go "back" to the first page, which iterates through the cart and gets a total, I get this message:
Warning: Invalid argument supplied for foreach() in /home.... etc.
Yet I'm "guarding" the foreach() by making sure it's got an element first, why am I getting this warning?
Here is the code that produces the error:
if(sizeof($HTTP_SESSION_VARS['shopCart'])>0){
/* the size is showing as 1, i.e. one item */
foreach($HTTP_SESSION_VARS['shopCart'] as $q=>$r){ //this is the line that produces the warning -- I have no idea why.
if($HTTP_SESSION_VARS['Login']=='guest'){
$multiplier=$r['WholesalePrice'];
}else{
$multiplier=$r['RetailPrice'];
}
if($r[1]>0){$currentOrder += $r[1] * $multiplier;}
}}
Any suggestions? Thank you, Sam Fullman