Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cart Handler
<?php
public function storeInSession()
{
if (! $this->session->isStarted()) {
$this->session->start();
$this->initializeCart($this->session);
} else {
if (! $this->session->has('cart')) {
$this->initializeCart($this->session);
}
}
/** @var Cart $cart */
$cart = unserialize($this->session->get('cart'));
$cart = $this->addSessionItem($cart);
$cart = serialize($cart);
$this->session->set('cart', $cart);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment