/** * Removes cart. * * @param \Jigoshop\Entity\Cart $cart Cart to remove. */ public function remove(Cart $cart) { $session = $this->session->getField(self::CART); if (isset($session[$cart->getId()])) { unset($session[$cart->getId()]); $this->session->setField(self::CART, $session); } }
/** * Fetches customer from database. * * @param $user \WP_User User object to fetch customer for. * * @return \Jigoshop\Entity\Customer */ public function fetch($user) { $state = array(); if ($user->ID == 0) { $customer = new Entity\Guest(); if ($this->session->getField(self::CUSTOMER)) { $customer->restoreState($this->session->getField(self::CUSTOMER)); } } else { $customer = new Entity(); $meta = $this->wp->getUserMeta($user->ID); if (is_array($meta)) { $state = array_map(function ($item) { return $item[0]; }, $meta); } $state['id'] = $user->ID; $state['login'] = $user->get('login'); $state['email'] = $user->get('user_email'); $state['name'] = $user->get('display_name'); $customer->restoreState($state); } return $this->wp->applyFilters('jigoshop\\find\\customer', $customer, $state); }
public function __construct(Wordpress $wp, SessionServiceInterface $sessionService) { $this->session = $sessionService->get($sessionService->getCurrentKey()); if ($this->session->getField(self::NOTICES)) { $this->notices = $this->session->getField(self::NOTICES); } if ($this->session->getField(self::WARNINGS)) { $this->warnings = $this->session->getField(self::WARNINGS); } if ($this->session->getField(self::ERRORS)) { $this->errors = $this->session->getField(self::ERRORS); } $wp->addAction('shutdown', array($this, 'preserveMessages'), 9); }