Esempio n. 1
0
 /**
  * Create a new, empty cart object, and assign it to the current customer, if any.
  *
  * @param CartCreateEvent $cartCreateEvent
  */
 public function createEmptyCart(CartCreateEvent $cartCreateEvent)
 {
     $cart = new CartModel();
     $cart->setCurrency($this->session->getCurrency(true));
     if (null !== ($customer = $this->session->getCustomerUser())) {
         $cart->setCustomer(CustomerQuery::create()->findPk($customer->getId()));
     }
     $this->session->setSessionCart($cart);
     if (ConfigQuery::read("cart.use_persistent_cookie", 1) == 1) {
         // set cart_use_cookie to "" to remove the cart cookie
         // see Thelia\Core\EventListener\ResponseListener
         $this->session->set("cart_use_cookie", "");
     }
     $cartCreateEvent->setCart($cart);
 }
Esempio n. 2
0
 /**
  * Create a new, empty cart object, and assign it to the current customer, if any.
  *
  * @param CartCreateEvent $cartCreateEvent
  */
 public function createEmptyCart(CartCreateEvent $cartCreateEvent)
 {
     $cart = new CartModel();
     $cart->setCurrency($this->session->getCurrency(true));
     if (null !== ($customer = $this->session->getCustomerUser())) {
         $cart->setCustomer(CustomerQuery::create()->findPk($customer->getId()));
     }
     $cartCreateEvent->setCart($cart);
 }
 /**
  * @return mixed|\Thelia\Core\HttpFoundation\Response
  */
 public function customerUpdateAction()
 {
     if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('CustomerFamily'), AccessManager::UPDATE))) {
         return $response;
     }
     $error = "";
     $form = new CustomerCustomerFamilyForm($this->getRequest());
     try {
         $formValidate = $this->validateForm($form);
         $event = new CustomerCustomerFamilyEvent($formValidate->get('customer_id')->getData());
         $event->setCustomerFamilyId($formValidate->get('customer_family_id')->getData())->setSiret($formValidate->get('siret')->getData())->setVat($formValidate->get('vat')->getData());
         $this->dispatch(CustomerFamilyEvents::CUSTOMER_CUSTOMER_FAMILY_UPDATE, $event);
         $this->redirect(URL::getInstance()->absoluteUrl('/admin/customer/update?customer_id=' . $formValidate->get('customer_id')->getData()));
     } catch (\Exception $e) {
         $error = $e->getMessage();
     }
     $form->setErrorMessage($error);
     $this->getParserContext()->addForm($form)->setGeneralError($error);
     //Don't forget to fill the Customer form
     $customerId = $this->getRequest()->request->get('customer_customer_family_form')['customer_id'];
     if (null != ($customer = CustomerQuery::create()->findPk($customerId))) {
         $customerForm = $this->hydrateCustomerForm($customer);
         $this->getParserContext()->addForm($customerForm);
     }
     return $this->render('customer-edit', array('customer_id' => $this->getRequest()->request->get('customer_customer_family_form')['customer_id'], "order_creation_error" => Translator::getInstance()->trans($error, array(), CustomerFamily::MESSAGE_DOMAIN)));
 }