Added a method to erase stored cart

This commit is contained in:
Cristian
2019-10-31 13:14:22 +01:00
committed by sartoric
parent fe5fe942c2
commit bb59a2e2dd
3 changed files with 54 additions and 0 deletions

View File

@@ -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.
*