Clearing the Cart
To clear the entire cart, effectively emptying it, you can use either Cart::clear()
or cart()->clear()
.
Method Signatures
php
Cart::clear();
Cart::clear();
or
php
cart()->clear();
cart()->clear();
Example
Using Cart::clear()
:
php
use RealRashid\Cart\Facades\Cart;
// Simulate clearing the cart
Cart::clear();
use RealRashid\Cart\Facades\Cart;
// Simulate clearing the cart
Cart::clear();
Using cart()->clear()
:
php
// Simulate clearing the cart
cart()->clear();
// Simulate clearing the cart
cart()->clear();
In both examples, the entire contents of the cart will be removed.
That's it! You're now equipped to clear your shopping cart using the Cart package.