Example #1
0
 /**
  * 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);
     }
 }
Example #2
0
 /**
  * Preserves messages storing them to PHP session.
  */
 public function preserveMessages()
 {
     $this->session->setField(self::NOTICES, array_values(array_filter($this->notices, function ($item) {
         return $item['persistent'];
     })));
     $this->session->setField(self::WARNINGS, array_values(array_filter($this->warnings, function ($item) {
         return $item['persistent'];
     })));
     $this->session->setField(self::ERRORS, array_values(array_filter($this->errors, function ($item) {
         return $item['persistent'];
     })));
 }
Example #3
0
 /**
  * Saves product to database.
  *
  * @param EntityInterface $object Customer to save.
  *
  * @throws Exception
  */
 public function save(EntityInterface $object)
 {
     if (!$object instanceof Entity) {
         throw new Exception('Trying to save not a customer!');
     }
     $fields = $object->getStateToSave();
     if (isset($fields['id']) || isset($fields['name']) || isset($fields['email']) || isset($fields['login'])) {
         // TODO: Do we want to update user data like this?
         //			$this->wp->wpUpdateUser(array(
         //				'ID' => $fields['id'],
         //				'display_name' => $fields['name'],
         //				'user_email' => $fields['email'],
         //			));
         unset($fields['id'], $fields['name'], $fields['email'], $fields['login']);
     }
     if ($object instanceof Entity\Guest) {
         $this->session->setField(Factory::CUSTOMER, $fields);
         return;
     }
     foreach ($fields as $field => $value) {
         $this->wp->updateUserMeta($object->getId(), $field, $value);
     }
 }