Skip to content

Instantly share code, notes, and snippets.

@Raistlfiren
Created December 8, 2015 23:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Raistlfiren/9d7f54d76260f9e08ac9 to your computer and use it in GitHub Desktop.
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