I’m trying to keep the cart contents alive when a user is logging out. I have Persistant Cart disabled, since I do NOT want to store it in their account. I only want the user to logout from the current cart, and then just keep the cart contents alive when a user is logged out.
I’m trying to observe through customer_logout. But not sure what steps I should take next.
<event name="customer_logout">
<observer name="[vendor]_preservecartlogout" instance="[vendor][name]ObserverPreserveCartOnLogout" />
</event>
Here is the Observer I’m starting with, but not sure what actions next to take.
class PreserveCartOnLogout implements ObserverInterface
{
protected $cartHelper;
protected $quoteRepository;
protected $quoteItemRepository;
protected $checkoutSession;
public function __construct(
Session $checkoutSession,
CartRepositoryInterface $quoteRepository,
CartItemRepositoryInterface $quoteItemRepository
) {
$this->checkoutSession = $checkoutSession;
$this->quoteRepository = $quoteRepository;
$this->quoteItemRepository = $quoteItemRepository;
}
public function execute(Observer $observer)
{
$currentQuote = $observer->getQuote();
$quoteId = $currentQuote->getId();
// not sure what to do next..
}
}