eCart has a built in function you can use to move to the last item added:
$CartName->MoveLast();
However, i just found a bug in this. To get the MoveLast function to work, you will need to edit the WA_eCart_Definition_PHP.php file.
change:
function MoveLast() {
if (!$this->IsEmpty()) {
$this->DisplayIndex = sizeof($this->Items.length) - 1;
}
}
to:
function MoveLast() {
if (!$this->IsEmpty()) {
$this->DisplayIndex = sizeof($this->Items) - 1;
}
}
After moving to the end of the cart array, you should reposition to the pointer at the beginning:
<?php $CartName->MoveLast(); echo($CartName->DisplayInfo("Name")); $CartName->MoveFirst()?>
other functions you may find useful:
Move to the first item added to the cart:
$CartName->MoveFirst();
Move to the next Cart item
$CartName->MoveNext();
Move to the previous cart item
$CartName->MovePrevious();
check if you are in the first Cart item
if($CartName->BOF());
check if you are in the last Cart item
if($CartName->EOF());