chore: bump to v2.0.0 with PHP 8.3+ support and invalid item cleanup

This commit is contained in:
Joel Male
2026-03-23 16:28:53 +10:00
parent 4c02310bf7
commit a3161888aa
3 changed files with 30 additions and 8 deletions
+22
View File
@@ -165,9 +165,31 @@ public function add(
$this->currentItemId = $id;
// clean up any incomplete items
$this->removeInvalidItems();
return $this;
}
/**
* Remove any incomplete items
*/
public function removeInvalidItems(): bool
{
$carts = $this->getContent();
foreach ($carts as $index => $cart) {
if (! (isset($cart['id'], $cart['name'], $cart['quantity']))) {
// remove item
$this->remove($index);
}
}
return true;
}
/**
* Update a cart item with whatever data is passed in
*/