Skip to content

Commit

Permalink
Update Cart.php
Browse files Browse the repository at this point in the history
Fix. An error occurred during the second remove. Check if the item still exists before removing
  • Loading branch information
xujiongze authored Oct 10, 2024
1 parent 4168fc8 commit 20fbb0d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Models/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ public function removeItem(CartItemContract $item): void
public function removeProduct(Buyable $product): void
{
$item = $this->items()->ofCart($this)->byProduct($product)->first();

$this->removeItem($item);

if($item){
$this->removeItem($item);
}
}

/**
Expand Down

0 comments on commit 20fbb0d

Please sign in to comment.