Skip to content

Commit

Permalink
Merge pull request #2 from sheetalbalpathak/master
Browse files Browse the repository at this point in the history
Added removeData function to allow user to remove data if he wants
  • Loading branch information
treehousetim authored Jan 25, 2022
2 parents c8c9e48 + bc72d54 commit 9c1bf09
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ public function removeItem( cartItem $item ) : self
return $this;
}
//------------------------------------------------------------------------
public function removeDataByType( string $type ) : self
{
if( ! $this->hasCartDataType( $type ) )
{
throw new Exception( 'Invalid cart data type: ' . $type, Exception::invalidDataTypeErrorCode );
}

unset( $this->data[ $type ] );

return $this;
}
//------------------------------------------------------------------------
public function addProduct( product $product, $qty ) : self
{
if( $this->hasItemForProductId( $product->getId() ) )
Expand Down

0 comments on commit 9c1bf09

Please sign in to comment.