Error: Fatal error: Call to a member function MoveFirst() on a non-object
I have written a function based on code posted by Jason to get the cheapest price of a product which is at the bottom of my view cart page whilst I am testing
<?php
function i8_buy5get1free($cat,$type) {
$eCart1->MoveFirst(); // this is line 298
$price = $eCart1->DisplayInfo("Price");
while (!$eCart1->EOF()) {
if(($eCart1->DisplayInfo("CatID") == $cat) && ($eCart1->DisplayInfo("TypeID") == $type)) {
if($eCart1->DisplayInfo("Price") < $price) $price = $eCart1->DisplayInfo("Price");
}
$eCart1->MoveNext();
}
$eCart1->MoveFirst();
return $price;
}
?>
which I am using in my discount tab as the attached screenshot
But when I hit the view cart page I get this error Fatal error: Call to a member function MoveFirst() on a non-object in /Volumes/Western Digital/Sites/tshirt-town/view-basket.php on line 298
what am I doing wrong ?