mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-18 05:25:04 +00:00
Added a method to erase stored cart
This commit is contained in:
23
src/Cart.php
23
src/Cart.php
@@ -628,6 +628,29 @@ class Cart
|
||||
->where('identifier', $identifier)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Erase the cart with the given identifier.
|
||||
*
|
||||
* @param mixed $identifier
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function erase($identifier)
|
||||
{
|
||||
if ($identifier instanceof InstanceIdentifier) {
|
||||
$identifier = $identifier->getInstanceIdentifier();
|
||||
}
|
||||
|
||||
if (!$this->storedCartWithIdentifierExists($identifier)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->getConnection()->table($this->getTableName())
|
||||
->where('identifier', $identifier)->delete();
|
||||
|
||||
$this->events->dispatch('cart.erased');
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges the contents of another cart into this cart.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user