diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 2e18872f6..464f7cf20 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -60,6 +60,27 @@ class Customer extends BaseAction implements EventSubscriberInterface } + public function updateProfil(CustomerCreateOrUpdateEvent $event) + { + + $customer = $event->getCustomer(); + + $customer->setDispatcher($this->getDispatcher()); + + $customer + ->setTitleId($event->getTitle()) + ->setFirstname($event->getFirstname()) + ->setLastname($event->getLastname()) + ->setEmail($event->getEmail(), true) + ->setPassword($event->getPassword()) + ->setReseller($event->getReseller()) + ->setSponsor($event->getSponsor()) + ->setDiscount($event->getDiscount()) + ->save(); + + $event->setCustomer($customer); + } + public function delete(CustomerEvent $event) { $customer = $event->getCustomer(); @@ -110,11 +131,6 @@ class Customer extends BaseAction implements EventSubscriberInterface $this->getSecurityContext()->clearCustomerUser(); } - public function changePassword(ActionEvent $event) - { - // TODO - } - /** * Return the security context * @@ -150,6 +166,7 @@ class Customer extends BaseAction implements EventSubscriberInterface return array( TheliaEvents::CUSTOMER_CREATEACCOUNT => array('create', 128), TheliaEvents::CUSTOMER_UPDATEACCOUNT => array('modify', 128), + TheliaEvents::CUSTOMER_UPDATEPROFIL => array('updateProfil', 128), TheliaEvents::CUSTOMER_LOGOUT => array('logout', 128), TheliaEvents::CUSTOMER_LOGIN => array('login', 128), TheliaEvents::CUSTOMER_DELETEACCOUNT => array('delete', 128), diff --git a/core/lib/Thelia/Action/Newsletter.php b/core/lib/Thelia/Action/Newsletter.php index fa2e54f09..fe489e120 100644 --- a/core/lib/Thelia/Action/Newsletter.php +++ b/core/lib/Thelia/Action/Newsletter.php @@ -26,6 +26,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\Newsletter\NewsletterEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Action\BaseAction; +use Thelia\Model\NewsletterQuery; use Thelia\Model\Newsletter as NewsletterModel; @@ -49,6 +50,24 @@ class Newsletter extends BaseAction implements EventSubscriberInterface ->save(); } + public function unsubscribe(NewsletterEvent $event) + { + if(null !== $nl = NewsletterQuery::create()->findPk($event->getId())) { + $nl->delete(); + } + } + + public function update(NewsletterEvent $event) + { + if(null !== $nl = NewsletterQuery::create()->findPk($event->getId())) { + $nl->setEmail($event->getEmail()) + ->setFirstname($event->getFirstname()) + ->setLastname($event->getLastname()) + ->setLocale($event->getLocale()) + ->save(); + } + } + /** * Returns an array of event names this subscriber wants to listen to. * @@ -72,7 +91,9 @@ class Newsletter extends BaseAction implements EventSubscriberInterface public static function getSubscribedEvents() { return array( - TheliaEvents::NEWSLETTER_SUBSCRIBE => array('subscribe', 128) + TheliaEvents::NEWSLETTER_SUBSCRIBE => array('subscribe', 128), + TheliaEvents::NEWSLETTER_UPDATE => array('update', 128), + TheliaEvents::NEWSLETTER_UNSUBSCRIBE => array('unsubscribe', 128) ); } } \ No newline at end of file diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 4e019a55f..6f635df9c 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -55,18 +55,27 @@ + +
+ + + + + + + + + + - - - - - - - - + + + + + @@ -75,6 +84,7 @@ + @@ -152,10 +162,6 @@ - - - - diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index 69127d6fc..981e8130f 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -4,56 +4,40 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> - + Thelia\Controller\Front\DefaultController::noAction - index + includes/mini-cart + + + Thelia\Controller\Front\DefaultController::noAction + includes/addedToCart - - - Thelia\Controller\Front\DefaultController::noAction - search - - - - Thelia\Controller\Front\DefaultController::noAction - view_all - - - + Thelia\Controller\Front\CustomerController::createAction register - - Thelia\Controller\Front\DefaultController::noAction - register - - - + Thelia\Controller\Front\CustomerController::loginAction login - - Thelia\Controller\Front\DefaultController::noAction - login + + + Thelia\Controller\Front\CustomerController::newPasswordAction + password - + Thelia\Controller\Front\CustomerController::logoutAction - - - Thelia\Controller\Front\DefaultController::noAction - account - - + Thelia\Controller\Front\CustomerController::viewAction account-update @@ -65,16 +49,15 @@ - - Thelia\Controller\Front\CustomerController::newPasswordAction + + Thelia\Controller\Front\CustomerController::updatePasswordAction account-password - + Thelia\Controller\Front\DefaultController::noAction account-password - @@ -112,11 +95,6 @@ - - Thelia\Controller\Front\DefaultController::noAction - cart - - Thelia\Controller\Front\CartController::addItem @@ -130,7 +108,6 @@ Thelia\Controller\Front\CartController::changeItem cart - @@ -174,11 +151,6 @@ - - Thelia\Controller\Front\DefaultController::noAction - contact - - Thelia\Controller\Front\ContactController::sendAction contact @@ -191,21 +163,17 @@ - - - Thelia\Controller\Front\DefaultController::noAction - newsletter - - Thelia\Controller\Front\NewsletterController::subscribeAction newsletter + - + + Thelia\Controller\Front\DefaultController::noAction - newsletter-success + index + ^(?!admin)[^/]+ - diff --git a/core/lib/Thelia/Controller/Front/CartController.php b/core/lib/Thelia/Controller/Front/CartController.php index 1b0d96003..5ba8fed48 100755 --- a/core/lib/Thelia/Controller/Front/CartController.php +++ b/core/lib/Thelia/Controller/Front/CartController.php @@ -61,6 +61,13 @@ class CartController extends BaseFrontController $message = $e->getMessage(); } + // If Ajax Request + if ($this->getRequest()->isXmlHttpRequest()) { + $request = $this->getRequest(); + $request->attributes->set('_view', "includes/mini-cart"); + } + + if ($message) { $cartAdd->setErrorMessage($message); $this->getParserContext()->addForm($cartAdd); diff --git a/core/lib/Thelia/Controller/Front/ContactController.php b/core/lib/Thelia/Controller/Front/ContactController.php index 543d65c71..da8c7efc2 100644 --- a/core/lib/Thelia/Controller/Front/ContactController.php +++ b/core/lib/Thelia/Controller/Front/ContactController.php @@ -46,7 +46,7 @@ class ContactController extends BaseFrontController $form = $this->validateForm($contactForm); $message = \Swift_Message::newInstance($form->get('subject')->getData()) - ->addFrom($form->get('email')->getData(), $form->get('firstname')->getData().' '.$form->get('lastname')->getData()) + ->addFrom($form->get('email')->getData(), $form->get('name')->getData()) ->addTo(ConfigQuery::read('contact_email'), ConfigQuery::read('company_name')) ->setBody($form->get('message')->getData()) ; diff --git a/core/lib/Thelia/Controller/Front/CustomerController.php b/core/lib/Thelia/Controller/Front/CustomerController.php index 857666a37..5611675e8 100755 --- a/core/lib/Thelia/Controller/Front/CustomerController.php +++ b/core/lib/Thelia/Controller/Front/CustomerController.php @@ -25,17 +25,19 @@ namespace Thelia\Controller\Front; use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent; use Thelia\Core\Event\Customer\CustomerLoginEvent; use Thelia\Core\Event\LostPasswordEvent; +use Thelia\Core\Event\Newsletter\NewsletterEvent; use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator; use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\UsernameNotFoundException; -use Thelia\Form\CustomerCreation; +use Thelia\Form\CustomerCreateForm; use Thelia\Form\CustomerLogin; use Thelia\Form\CustomerLostPasswordForm; -use Thelia\Form\CustomerUpdateForm; +use Thelia\Form\CustomerPasswordUpdateForm; +use Thelia\Form\CustomerProfilUpdateForm; use Thelia\Form\Exception\FormValidationException; use Thelia\Model\Customer; use Thelia\Core\Event\TheliaEvents; -use Thelia\Model\CustomerQuery; +use Thelia\Model\NewsletterQuery; use Thelia\Tools\URL; use Thelia\Log\Tlog; use Thelia\Core\Security\Exception\WrongPasswordException; @@ -49,6 +51,7 @@ class CustomerController extends BaseFrontController { use \Thelia\Cart\CartTrait; + public function newPasswordAction() { if (! $this->getSecurityContext()->hasCustomerUser()) { @@ -93,7 +96,7 @@ class CustomerController extends BaseFrontController $message = false; - $customerCreation = new CustomerCreation($this->getRequest()); + $customerCreation = new CustomerCreateForm($this->getRequest()); try { $form = $this->validateForm($customerCreation, "post"); @@ -129,12 +132,6 @@ class CustomerController extends BaseFrontController } } - protected function getExistingCustomer($customer_id) - { - return CustomerQuery::create() - ->findOneById($customer_id); - } - /** * Update customer data. On success, redirect to success_url if exists. * Otherwise, display the same view again. @@ -150,12 +147,51 @@ class CustomerController extends BaseFrontController 'firstname' => $customer->getFirstName(), 'lastname' => $customer->getLastName(), 'email' => $customer->getEmail(), + 'newsletter' => null !== NewsletterQuery::create()->findOneByEmail($customer->getEmail()), ); - $customerUpdateForm = new CustomerUpdateForm($this->getRequest(), 'form', $data); + $customerProfilUpdateForm = new CustomerProfilUpdateForm($this->getRequest(), 'form', $data); // Pass it to the parser - $this->getParserContext()->addForm($customerUpdateForm); + $this->getParserContext()->addForm($customerProfilUpdateForm); + } + + + public function updatePasswordAction() + { + if ($this->getSecurityContext()->hasCustomerUser()) { + $message = false; + + $customerPasswordUpdateForm = new CustomerPasswordUpdateForm($this->getRequest()); + + try { + $customer = $this->getSecurityContext()->getCustomerUser(); + + $form = $this->validateForm($customerPasswordUpdateForm, "post"); + + $customerChangeEvent = $this->createEventInstance($form->getData()); + $customerChangeEvent->setCustomer($customer); + $this->dispatch(TheliaEvents::CUSTOMER_UPDATEPROFIL, $customerChangeEvent); + + $this->redirectSuccess($customerPasswordUpdateForm); + + } catch (FormValidationException $e) { + $message = sprintf("Please check your input: %s", $e->getMessage()); + } catch (\Exception $e) { + $message = sprintf("Sorry, an error occured: %s", $e->getMessage()); + } + + if ($message !== false) { + Tlog::getInstance()->error(sprintf("Error during customer password modification process : %s.", $message)); + + $customerPasswordUpdateForm->setErrorMessage($message); + + $this->getParserContext() + ->addForm($customerPasswordUpdateForm) + ->setGeneralError($message) + ; + } + } } public function updateAction() @@ -164,21 +200,43 @@ class CustomerController extends BaseFrontController $message = false; - $customerUpdateForm = new CustomerUpdateForm($this->getRequest()); + $customerProfilUpdateForm = new CustomerProfilUpdateForm($this->getRequest()); try { - $customer = $this->getSecurityContext()->getCustomerUser(); + $newsletterOldEmail = $customer->getEmail(); - $form = $this->validateForm($customerUpdateForm, "post"); + $form = $this->validateForm($customerProfilUpdateForm, "post"); $customerChangeEvent = $this->createEventInstance($form->getData()); $customerChangeEvent->setCustomer($customer); - $this->dispatch(TheliaEvents::CUSTOMER_UPDATEACCOUNT, $customerChangeEvent); + $this->dispatch(TheliaEvents::CUSTOMER_UPDATEPROFIL, $customerChangeEvent); - $this->processLogin($customerChangeEvent->getCustomer()); + $updatedCustomer = $customerChangeEvent->getCustomer(); - $this->redirectSuccess($customerUpdateForm); + // Newsletter + if (true === $form->get('newsletter')->getData()) { + $nlEvent = new NewsletterEvent($updatedCustomer->getEmail(), $this->getRequest()->getSession()->getLang()->getLocale()); + $nlEvent->setFirstname($updatedCustomer->getFirstname()); + $nlEvent->setLastname($updatedCustomer->getLastname()); + + if(null !== $newsletter = NewsletterQuery::create()->findOneByEmail($newsletterOldEmail)) { + $nlEvent->setId($newsletter->getId()); + $this->dispatch(TheliaEvents::NEWSLETTER_UPDATE, $nlEvent); + } else { + $this->dispatch(TheliaEvents::NEWSLETTER_SUBSCRIBE, $nlEvent); + } + } else { + if(null !== $newsletter = NewsletterQuery::create()->findOneByEmail($newsletterOldEmail)) { + $nlEvent = new NewsletterEvent($updatedCustomer->getEmail(), $this->getRequest()->getSession()->getLang()->getLocale()); + $nlEvent->setId($newsletter->getId()); + $this->dispatch(TheliaEvents::NEWSLETTER_UNSUBSCRIBE, $nlEvent); + } + } + + $this->processLogin($updatedCustomer); + + $this->redirectSuccess($customerProfilUpdateForm); } catch (FormValidationException $e) { $message = sprintf("Please check your input: %s", $e->getMessage()); @@ -189,10 +247,10 @@ class CustomerController extends BaseFrontController if ($message !== false) { Tlog::getInstance()->error(sprintf("Error during customer modification process : %s.", $message)); - $customerUpdateForm->setErrorMessage($message); + $customerProfilUpdateForm->setErrorMessage($message); $this->getParserContext() - ->addForm($customerUpdateForm) + ->addForm($customerProfilUpdateForm) ->setGeneralError($message) ; } @@ -289,9 +347,9 @@ class CustomerController extends BaseFrontController private function createEventInstance($data) { $customerCreateEvent = new CustomerCreateOrUpdateEvent( - $data["title"], - $data["firstname"], - $data["lastname"], + isset($data["title"])?$data["title"]:null, + isset($data["firstname"])?$data["firstname"]:null, + isset($data["lastname"])?$data["lastname"]:null, isset($data["address1"])?$data["address1"]:null, isset($data["address2"])?$data["address2"]:null, isset($data["address3"])?$data["address3"]:null, diff --git a/core/lib/Thelia/Controller/Front/NewsletterController.php b/core/lib/Thelia/Controller/Front/NewsletterController.php index 636923f5b..0df57cd61 100644 --- a/core/lib/Thelia/Controller/Front/NewsletterController.php +++ b/core/lib/Thelia/Controller/Front/NewsletterController.php @@ -62,17 +62,32 @@ class NewsletterController extends BaseFrontController $error_message = $e->getMessage(); } - if($error_message !== false) { - \Thelia\Log\Tlog::getInstance()->error(sprintf('Error during newsletter subscription : %s', $error_message)); + \Thelia\Log\Tlog::getInstance()->error(sprintf('Error during newsletter subscription : %s', $error_message)); + // If Ajax Request + if ($this->getRequest()->isXmlHttpRequest()) { + if ($error_message) { + $response = $this->jsonResponse(json_encode(array( + "success" => false, + "message" => $error_message + ))); + } else { + $response = $this->jsonResponse(json_encode(array( + "success" => true, + "message" => "Thanks for signing up! We'll keep you posted whenever we have any new updates." + )));; + } + + return $response; + + } else { $newsletterForm->setErrorMessage($error_message); $this->getParserContext() ->addForm($newsletterForm) ->setGeneralError($error_message) ; - } else { - $this->redirectToRoute('newsletter.success'); } + } } \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/Newsletter/NewsletterEvent.php b/core/lib/Thelia/Core/Event/Newsletter/NewsletterEvent.php index fc50980c0..85948a621 100644 --- a/core/lib/Thelia/Core/Event/Newsletter/NewsletterEvent.php +++ b/core/lib/Thelia/Core/Event/Newsletter/NewsletterEvent.php @@ -32,6 +32,11 @@ use Thelia\Core\Event\ActionEvent; */ class NewsletterEvent extends ActionEvent { + /** + * @var string email to save + */ + protected $id; + /** * @var string email to save */ @@ -138,6 +143,22 @@ class NewsletterEvent extends ActionEvent return $this->locale; } + /** + * @param string $id + */ + public function setId($id) + { + $this->id = $id; + } + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index e259f1de9..e6e675c83 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -71,6 +71,11 @@ final class TheliaEvents */ const CUSTOMER_UPDATEACCOUNT = "action.updateCustomer"; + /** + * sent on customer account update profil + */ + const CUSTOMER_UPDATEPROFIL = "action.updateProfilCustomer"; + /** * sent on customer removal */ @@ -695,6 +700,8 @@ final class TheliaEvents * sent for subscribing to the newsletter */ const NEWSLETTER_SUBSCRIBE = 'thelia.newsletter.subscribe'; + const NEWSLETTER_UPDATE = 'thelia.newsletter.update'; + const NEWSLETTER_UNSUBSCRIBE = 'thelia.newsletter.unsubscribe'; /************ LANG MANAGEMENT ****************************/ diff --git a/core/lib/Thelia/Core/Template/Loop/Cart.php b/core/lib/Thelia/Core/Template/Loop/Cart.php index 5dc40218b..be39371ad 100755 --- a/core/lib/Thelia/Core/Template/Loop/Cart.php +++ b/core/lib/Thelia/Core/Template/Loop/Cart.php @@ -12,8 +12,11 @@ namespace Thelia\Core\Template\Loop; use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; +use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Model\CountryQuery; +use Thelia\Type; +use Thelia\Type\TypeCollection; class Cart extends BaseLoop { @@ -40,7 +43,8 @@ class Cart extends BaseLoop protected function getArgDefinitions() { return new ArgumentCollection( - + Argument::createIntTypeArgument('limit'), + Argument::createAnyTypeArgument('position') ); } @@ -74,6 +78,7 @@ class Cart extends BaseLoop { $cart = $this->getCart($this->request); + $cartItems = $cart->getCartItems(); $result = new LoopResult($cartItems); @@ -81,9 +86,32 @@ class Cart extends BaseLoop return $result; } + $limit = $this->getLimit(); + + $countCartItems = count($cartItems); + + if($limit <= 0 || $limit >= $countCartItems){ + $limit = $countCartItems; + } + + $position = $this->getPosition(); + + if(isset($position)){ + if($position == "first"){ + $limit = 1; + $cartItems = array($cartItems[0]); + }else if($position == "last"){ + $limit = 1; + $cartItems = array(end($cartItems)); + } + + // @TODO : if the position is a number + } + $taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic; - foreach ($cartItems as $cartItem) { + for ($i=0; $i<$limit; $i ++) { + $cartItem = $cartItems[$i]; $product = $cartItem->getProduct(); $productSaleElement = $cartItem->getProductSaleElements(); diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php index 6acbf834b..e9b0fef8a 100755 --- a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php +++ b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php @@ -8,6 +8,7 @@ use \Symfony\Component\EventDispatcher\EventDispatcherInterface; use \Smarty; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\HttpException; use Thelia\Core\Template\ParserInterface; use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; @@ -139,7 +140,7 @@ class SmartyParser extends Smarty implements ParserInterface try { $templateFile = $this->getTemplateFilePath(); } catch (\RuntimeException $e) { - return new Response($e->getMessage(), "404"); + return new Response($this->render(\Thelia\Model\ConfigQuery::getPageNotFoundView()), "404"); } return $this->render($templateFile); diff --git a/core/lib/Thelia/Form/AddressCreateForm.php b/core/lib/Thelia/Form/AddressCreateForm.php index 0774f253d..902663f43 100644 --- a/core/lib/Thelia/Form/AddressCreateForm.php +++ b/core/lib/Thelia/Form/AddressCreateForm.php @@ -22,6 +22,8 @@ /*************************************************************************************/ namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\Constraints\NotBlank; use Thelia\Core\Translation\Translator; @@ -57,115 +59,122 @@ class AddressCreateForm extends BaseForm { $this->formBuilder ->add("label", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => Translator::getInstance()->trans("Address label"), - "label_attr" => array( - "for" => "label_create" - ), - "required" => true - )) + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Address label"), + "label_attr" => array( + "for" => "address_label" + ) + )) ->add("title", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => Translator::getInstance()->trans("Title"), - "label_attr" => array( - "for" => "title_create" - ) - )) + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("Title"), + "label_attr" => array( + "for" => "title" + ) + )) ->add("firstname", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => Translator::getInstance()->trans("Firstname"), - "label_attr" => array( - "for" => "firstname_create" - ) - )) + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("First Name"), + "label_attr" => array( + "for" => "firstname" + ) + )) ->add("lastname", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => Translator::getInstance()->trans("Lastname"), - "label_attr" => array( - "for" => "lastname_create" - ) - )) - ->add("address1", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => Translator::getInstance()->trans("Street Address"), - "label_attr" => array( - "for" => "address1_create" - ) - )) - ->add("address2", "text", array( - "label" => Translator::getInstance()->trans("Additional address"), - "label_attr" => array( - "for" => "address2_create" - ) - )) - ->add("address3", "text", array( - "label" => Translator::getInstance()->trans("Additional address"), - "label_attr" => array( - "for" => "address3_create" - ) - )) - ->add("zipcode", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => Translator::getInstance()->trans("Zip code"), - "label_attr" => array( - "for" => "zipcode_create" - ) - )) - ->add("city", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => Translator::getInstance()->trans("City"), - "label_attr" => array( - "for" => "city_create" - ) - )) - ->add("country", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => Translator::getInstance()->trans("Country"), - "label_attr" => array( - "for" => "country_create" - ) - )) - ->add("phone", "text", array( - "label" => Translator::getInstance()->trans("Phone"), - "label_attr" => array( - "for" => "phone_create" - ) - )) - ->add("cellphone", "text", array( - "label" => Translator::getInstance()->trans("Cellphone"), - "label_attr" => array( - "for" => "cellphone_create" - ) - )) + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("Last Name"), + "label_attr" => array( + "for" => "lastname" + ) + )) ->add("company", "text", array( - "label" => Translator::getInstance()->trans("Company"), - "label_attr" => array( - "for" => "company_create" - ) - )) - ->add("is_default", "integer", array( - "label" => Translator::getInstance()->trans("Make this address has my primary address"), - "label_attr" => array( - "for" => "default_address" - ) - )) - ; + "label" => Translator::getInstance()->trans("Company Name"), + "label_attr" => array( + "for" => "company" + ), + "required" => false + )) + ->add("address1", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("Street Address"), + "label_attr" => array( + "for" => "address1" + ) + )) + ->add("address2", "text", array( + "label" => Translator::getInstance()->trans("Address Line 2"), + "label_attr" => array( + "for" => "address2" + ), + "required" => false + )) + ->add("address3", "text", array( + "label" => Translator::getInstance()->trans("Address Line 3"), + "label_attr" => array( + "for" => "address3" + ), + "required" => false + )) + ->add("city", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("City"), + "label_attr" => array( + "for" => "city" + ) + )) + ->add("zipcode", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("Zip code"), + "label_attr" => array( + "for" => "zipcode" + ) + )) + ->add("country", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("Country"), + "label_attr" => array( + "for" => "country" + ) + )) + // Phone + ->add("phone", "text", array( + "label" => Translator::getInstance()->trans("Phone"), + "label_attr" => array( + "for" => "phone" + ), + "required" => false + )) + ->add("cellphone", "text", array( + "label" => Translator::getInstance()->trans("Cellphone"), + "label_attr" => array( + "for" => "cellphone" + ), + "required" => false + )) + // Default address + ->add("is_default", "checkbox", array( + "label" => Translator::getInstance()->trans("Make this address has my primary address"), + "label_attr" => array( + "for" => "default_address" + ), + "required" => false + )) + ; } /** diff --git a/core/lib/Thelia/Form/AddressUpdateForm.php b/core/lib/Thelia/Form/AddressUpdateForm.php index 055b233c9..258fbc357 100644 --- a/core/lib/Thelia/Form/AddressUpdateForm.php +++ b/core/lib/Thelia/Form/AddressUpdateForm.php @@ -22,8 +22,6 @@ /*************************************************************************************/ namespace Thelia\Form; -use Symfony\Component\Validator\Constraints\NotBlank; -use Thelia\Core\Translation\Translator; /** * Class AddressUpdateForm @@ -32,136 +30,11 @@ use Thelia\Core\Translation\Translator; */ class AddressUpdateForm extends AddressCreateForm { - /** - * - * in this function you add all the fields you need for your Form. - * Form this you have to call add method on $this->formBuilder attribute : - * - * $this->formBuilder->add("name", "text") - * ->add("email", "email", array( - * "attr" => array( - * "class" => "field" - * ), - * "label" => "email", - * "constraints" => array( - * new \Symfony\Component\Validator\Constraints\NotBlank() - * ) - * ) - * ) - * ->add('age', 'integer'); - * - * @return null - */ + protected function buildForm() { parent::buildForm(); - $this->formBuilder - ->add("label", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => Translator::getInstance()->trans("Address label *"), - "label_attr" => array( - "for" => "label_update" - ), - "required" => true - )) - ->add("title", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => Translator::getInstance()->trans("Title"), - "label_attr" => array( - "for" => "title_update" - ) - )) - ->add("firstname", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => Translator::getInstance()->trans("Firstname"), - "label_attr" => array( - "for" => "firstname_update" - ) - )) - ->add("lastname", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => Translator::getInstance()->trans("Lastname"), - "label_attr" => array( - "for" => "lastname_update" - ) - )) - ->add("address1", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => Translator::getInstance()->trans("Street Address"), - "label_attr" => array( - "for" => "address1_update" - ) - )) - ->add("address2", "text", array( - "label" => Translator::getInstance()->trans("Additional address"), - "label_attr" => array( - "for" => "address2_update" - ) - )) - ->add("address3", "text", array( - "label" => Translator::getInstance()->trans("Additional address"), - "label_attr" => array( - "for" => "address3_update" - ) - )) - ->add("zipcode", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => Translator::getInstance()->trans("Zip code"), - "label_attr" => array( - "for" => "zipcode_update" - ) - )) - ->add("city", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => Translator::getInstance()->trans("City"), - "label_attr" => array( - "for" => "city_update" - ) - )) - ->add("country", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => Translator::getInstance()->trans("Country"), - "label_attr" => array( - "for" => "country_update" - ) - )) - ->add("phone", "text", array( - "label" => Translator::getInstance()->trans("Phone"), - "label_attr" => array( - "for" => "phone_update" - ) - )) - ->add("cellphone", "text", array( - "label" => Translator::getInstance()->trans("Cellphone"), - "label_attr" => array( - "for" => "cellphone_update" - ) - )) - ->add("company", "text", array( - "label" => Translator::getInstance()->trans("Compagny"), - "label_attr" => array( - "for" => "company_update" - ) - )) - ; - } /** diff --git a/core/lib/Thelia/Form/CartAdd.php b/core/lib/Thelia/Form/CartAdd.php index 53496c513..59d13765d 100755 --- a/core/lib/Thelia/Form/CartAdd.php +++ b/core/lib/Thelia/Form/CartAdd.php @@ -99,8 +99,8 @@ class CartAdd extends BaseForm "for" => "quantity" ) )) - ->add("append", "hidden") - ->add("newness", "hidden") + ->add("append", "integer") + ->add("newness", "integer") ; } diff --git a/core/lib/Thelia/Form/ContactForm.php b/core/lib/Thelia/Form/ContactForm.php index 097e651da..3cc7bc737 100644 --- a/core/lib/Thelia/Form/ContactForm.php +++ b/core/lib/Thelia/Form/ContactForm.php @@ -59,22 +59,13 @@ class ContactForm extends BaseForm protected function buildForm() { $this->formBuilder - ->add('firstname', 'text', array( + ->add('name', 'text', array( 'constraints' => array( new NotBlank() ), - 'label' => Translator::getInstance()->trans('firstname'), + 'label' => Translator::getInstance()->trans('Full Name'), 'label_attr' => array( - 'for' => 'firstname_contact' - ) - )) - ->add('lastname', 'text', array( - 'constraints' => array( - new NotBlank() - ), - 'label' => Translator::getInstance()->trans('lastname'), - 'label_attr' => array( - 'for' => 'lastname_contact' + 'for' => 'name_contact' ) )) ->add('email', 'email', array( @@ -82,7 +73,7 @@ class ContactForm extends BaseForm new NotBlank(), new Email() ), - 'label' => Translator::getInstance()->trans('email'), + 'label' => Translator::getInstance()->trans('Your Email Address'), 'label_attr' => array( 'for' => 'email_contact' ) @@ -91,7 +82,7 @@ class ContactForm extends BaseForm 'constraints' => array( new NotBlank() ), - 'label' => Translator::getInstance()->trans('subject'), + 'label' => Translator::getInstance()->trans('Subject'), 'label_attr' => array( 'for' => 'subject_contact' ) @@ -100,7 +91,7 @@ class ContactForm extends BaseForm 'constraints' => array( new NotBlank() ), - 'label' => Translator::getInstance()->trans('message'), + 'label' => Translator::getInstance()->trans('Your Message'), 'label_attr' => array( 'for' => 'message_contact' ) diff --git a/core/lib/Thelia/Form/CustomerCreateForm.php b/core/lib/Thelia/Form/CustomerCreateForm.php new file mode 100755 index 000000000..38da394cc --- /dev/null +++ b/core/lib/Thelia/Form/CustomerCreateForm.php @@ -0,0 +1,124 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Symfony\Component\Validator\Constraints\NotBlank; +use Symfony\Component\Validator\ExecutionContextInterface; +use Thelia\Model\ConfigQuery; +use Thelia\Model\CustomerQuery; +use Thelia\Core\Translation\Translator; + +/** + * Class CustomerCreateForm + * @package Thelia\Form + * @author Manuel Raynaud + */ +class CustomerCreateForm extends AddressCreateForm +{ + + protected function buildForm() + { + parent::buildForm(); + + $this->formBuilder + // Remove From Address create form + ->remove("label") + ->remove("is_default") + + // Add + ->add("auto_login", "integer") + // Add Email address + ->add("email", "email", array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Email(), + new Constraints\Callback(array( + "methods" => array( + array($this, + "verifyExistingEmail") + ) + )) + ), + "label" => Translator::getInstance()->trans("Email Address"), + "label_attr" => array( + "for" => "email" + ) + )) + // Add Login Information + ->add("password", "password", array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))) + ), + "label" => Translator::getInstance()->trans("Password"), + "label_attr" => array( + "for" => "password" + ) + )) + ->add("password_confirm", "password", array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))), + new Constraints\Callback(array("methods" => array( + array($this, "verifyPasswordField") + ))) + ), + "label" => "Password confirmation", + "label_attr" => array( + "for" => "password_confirmation" + ) + )) + // Add terms & conditions + ->add("agreed", "checkbox", array( + "constraints" => array( + new Constraints\True(array("message" => "Please accept the Terms and conditions in order to register.")) + ), + "label_attr" => array( + "for" => "agreed" + ) + )); + } + + public function verifyPasswordField($value, ExecutionContextInterface $context) + { + $data = $context->getRoot()->getData(); + + if ($data["password"] != $data["password_confirm"]) { + $context->addViolation("password confirmation is not the same as password field."); + } + } + + public function verifyExistingEmail($value, ExecutionContextInterface $context) + { + $customer = CustomerQuery::getCustomerByEmail($value); + if ($customer) { + $context->addViolation("This email already exists."); + } + } + + public function getName() + { + return "thelia_customer_create"; + } +} diff --git a/core/lib/Thelia/Form/CustomerCreation.php b/core/lib/Thelia/Form/CustomerCreation.php deleted file mode 100755 index d728a515d..000000000 --- a/core/lib/Thelia/Form/CustomerCreation.php +++ /dev/null @@ -1,234 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ -namespace Thelia\Form; - -use Symfony\Component\Validator\Constraints; -use Symfony\Component\Validator\ExecutionContextInterface; -use Thelia\Model\ConfigQuery; -use Thelia\Model\CustomerQuery; -use Thelia\Core\Translation\Translator; - -/** - * Class CustomerCreation - * @package Thelia\Form - * @author Manuel Raynaud - */ -class CustomerCreation extends BaseForm -{ - - protected function buildForm() - { - $this->formBuilder - ->add("auto_login", "integer") - // Personal Informations - ->add("title", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label" => Translator::getInstance()->trans("Title"), - "label_attr" => array( - "for" => "title" - ) - )) - ->add("firstname", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label" => Translator::getInstance()->trans("First Name"), - "label_attr" => array( - "for" => "firstname" - ) - )) - ->add("lastname", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label" => Translator::getInstance()->trans("Last Name"), - "label_attr" => array( - "for" => "lastname" - ) - )) - ->add("email", "email", array( - "constraints" => array( - new Constraints\NotBlank(), - new Constraints\Email(), - new Constraints\Callback(array( - "methods" => array( - array($this, - "verifyExistingEmail") - ) - )) - ), - "label" => Translator::getInstance()->trans("Email Address"), - "label_attr" => array( - "for" => "email" - ) - )) -/* ->add("email_confirm", "email", array( - "constraints" => array( - new Constraints\Callback(array( - "methods" => array( - array($this, - "verifyEmailField") - ) - )) - ), - "label" => "email confirmation" - ))*/ - ->add("phone", "text", array( - "label" => Translator::getInstance()->trans("Phone"), - "label_attr" => array( - "for" => "phone" - ), - "required" => false - )) - ->add("cellphone", "text", array( - "label" => Translator::getInstance()->trans("Cellphone"), - "label_attr" => array( - "for" => "cellphone" - ), - "required" => false - )) - // Delivery Informations - ->add("company", "text", array( - "label" => Translator::getInstance()->trans("Company Name"), - "label_attr" => array( - "for" => "company" - ), - "required" => false - )) - ->add("address1", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label" => Translator::getInstance()->trans("Street Address"), - "label_attr" => array( - "for" => "address1" - ) - )) - ->add("address2", "text", array( - "label" => Translator::getInstance()->trans("Address Line 2"), - "label_attr" => array( - "for" => "address2" - ), - "required" => false - )) - ->add("address3", "text", array( - "label" => Translator::getInstance()->trans("Address Line 3"), - "label_attr" => array( - "for" => "address3" - ), - "required" => false - )) - ->add("city", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label" => Translator::getInstance()->trans("City"), - "label_attr" => array( - "for" => "city" - ) - )) - ->add("zipcode", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label" => Translator::getInstance()->trans("Zip code"), - "label_attr" => array( - "for" => "zipcode" - ) - )) - ->add("country", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label" => Translator::getInstance()->trans("Country"), - "label_attr" => array( - "for" => "country" - ) - )) - // Login Information - ->add("password", "password", array( - "constraints" => array( - new Constraints\NotBlank(), - new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))) - ), - "label" => Translator::getInstance()->trans("Password"), - "label_attr" => array( - "for" => "password" - ) - )) - ->add("password_confirm", "password", array( - "constraints" => array( - new Constraints\NotBlank(), - new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))), - new Constraints\Callback(array("methods" => array( - array($this, "verifyPasswordField") - ))) - ), - "label" => "Password confirmation", - "label_attr" => array( - "for" => "password_confirmation" - ) - )) - ->add("agreed", "checkbox", array( - "constraints" => array( - new Constraints\True(array("message" => "Please accept the Terms and conditions in order to register.")) - ), - "label_attr" => array( - "for" => "agreed" - ) - )); - } - - public function verifyPasswordField($value, ExecutionContextInterface $context) - { - $data = $context->getRoot()->getData(); - - if ($data["password"] != $data["password_confirm"]) { - $context->addViolation("password confirmation is not the same as password field"); - } - } - - public function verifyEmailField($value, ExecutionContextInterface $context) - { - $data = $context->getRoot()->getData(); - - if ($data["email"] != $data["email_confirm"]) { - $context->addViolation("email confirmation is not the same as email field"); - } - } - - public function verifyExistingEmail($value, ExecutionContextInterface $context) - { - $customer = CustomerQuery::create()->findOneByEmail($value); - if ($customer) { - $context->addViolation("This email already exists"); - } - } - - public function getName() - { - return "thelia_customer_creation"; - } -} diff --git a/core/lib/Thelia/Form/CustomerLogin.php b/core/lib/Thelia/Form/CustomerLogin.php index 78f4c3d33..66b5c34ef 100755 --- a/core/lib/Thelia/Form/CustomerLogin.php +++ b/core/lib/Thelia/Form/CustomerLogin.php @@ -73,9 +73,11 @@ class CustomerLogin extends BaseForm "data" => 0 )) ->add("password", "password", array( - /*"constraints" => array( - new Constraints\NotBlank() - ),*/ + "constraints" => array( + new Constraints\NotBlank(array( + 'groups' => array('existing_customer'), + )) + ), "label" => Translator::getInstance()->trans("Please enter your password"), "label_attr" => array( "for" => "password" diff --git a/core/lib/Thelia/Form/CustomerModification.php b/core/lib/Thelia/Form/CustomerModification.php deleted file mode 100755 index 4f12c6013..000000000 --- a/core/lib/Thelia/Form/CustomerModification.php +++ /dev/null @@ -1,164 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ - -namespace Thelia\Form; - -use Symfony\Component\Validator\Constraints; -use Thelia\Core\Translation\Translator; - -/** - * Class CustomerModification - * @package Thelia\Form - * @author Manuel Raynaud - */ -class CustomerModification extends BaseForm -{ - /** - * - * in this function you add all the fields you need for your Form. - * Form this you have to call add method on $this->form attribute : - * - * $this->form->add("name", "text") - * ->add("email", "email", array( - * "attr" => array( - * "class" => "field" - * ), - * "label" => "email", - * "constraints" => array( - * new NotBlank() - * ) - * ) - * ) - * ->add('age', 'integer'); - * - * @return null - */ - protected function buildForm() - { - - $this->formBuilder - ->add('update_logged_in_user', 'integer') // In a front office context, update the in-memory logged-in user data - ->add("company", "text", array( - "label" => Translator::getInstance()->trans("Company"), - "label_attr" => array( - "for" => "company" - ) - )) - ->add("firstname", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label" => Translator::getInstance()->trans("First Name"), - "label_attr" => array( - "for" => "firstname" - ) - )) - ->add("lastname", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label" => Translator::getInstance()->trans("Last Name"), - "label_attr" => array( - "for" => "lastname" - ) - )) - ->add("address1", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label_attr" => array( - "for" => "address" - ), - "label" => Translator::getInstance()->trans("Street Address") - )) - ->add("address2", "text", array( - "label" => Translator::getInstance()->trans("Address Line 2"), - "label_attr" => array( - "for" => "address2" - ) - )) - ->add("address3", "text", array( - "label" => Translator::getInstance()->trans("Address Line 3"), - "label_attr" => array( - "for" => "address3" - ) - )) - ->add("phone", "text", array( - "label" => Translator::getInstance()->trans("Phone"), - "label_attr" => array( - "for" => "phone" - ) - )) - ->add("cellphone", "text", array( - "label" => Translator::getInstance()->trans("Cellphone"), - "label_attr" => array( - "for" => "cellphone" - ) - )) - ->add("zipcode", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label" => Translator::getInstance()->trans("Zip code"), - "label_attr" => array( - "for" => "zipcode" - ) - )) - ->add("city", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label" => Translator::getInstance()->trans("City"), - "label_attr" => array( - "for" => "city" - ) - )) - ->add("country", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label" => Translator::getInstance()->trans("Country"), - "label_attr" => array( - "for" => "country" - ) - )) - ->add("title", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label" => Translator::getInstance()->trans("Title"), - "label_attr" => array( - "for" => "title" - ) - )) - ; - } - - /** - * @return string the name of you form. This name must be unique - */ - public function getName() - { - return "thelia_customer_modification"; - } -} diff --git a/core/lib/Thelia/Form/CustomerPasswordUpdateForm.php b/core/lib/Thelia/Form/CustomerPasswordUpdateForm.php new file mode 100755 index 000000000..3b4cfec40 --- /dev/null +++ b/core/lib/Thelia/Form/CustomerPasswordUpdateForm.php @@ -0,0 +1,102 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Symfony\Component\Validator\ExecutionContextInterface; +use Thelia\Model\ConfigQuery; +use Thelia\Core\Translation\Translator; +use Thelia\Model\CustomerQuery; + +/** + * Class CustomerPasswordUpdateForm + * @package Thelia\Form + * @author Christophe Laffont + */ +class CustomerPasswordUpdateForm extends BaseForm +{ + + protected function buildForm() + { + $this->formBuilder + + // Login Information + ->add("password_old", "password", array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Callback(array("methods" => array( + array($this, "verifyCurrentPasswordField") + ))) + ), + "label" => Translator::getInstance()->trans("Current Password"), + "label_attr" => array( + "for" => "password_old" + ) + )) + ->add("password", "password", array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))) + ), + "label" => Translator::getInstance()->trans("New Password"), + "label_attr" => array( + "for" => "password" + ) + )) + ->add("password_confirm", "password", array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))), + new Constraints\Callback(array("methods" => array( + array($this, "verifyPasswordField") + ))) + ), + "label" => "Password confirmation", + "label_attr" => array( + "for" => "password_confirmation" + ) + )); + } + + public function verifyCurrentPasswordField($value, ExecutionContextInterface $context) + { + // Check if value of the old password match the password of the current user + if (!password_verify($value, $this->getRequest()->getSession()->getCustomerUser()->getPassword())) { + $context->addViolation("Your current password does not match."); + } + } + + public function verifyPasswordField($value, ExecutionContextInterface $context) + { + $data = $context->getRoot()->getData(); + + if ($data["password"] != $data["password_confirm"]) { + $context->addViolation("Password confirmation is not the same as password field."); + } + } + + public function getName() + { + return "thelia_customer_password_update"; + } +} diff --git a/core/lib/Thelia/Form/CustomerProfilUpdateForm.php b/core/lib/Thelia/Form/CustomerProfilUpdateForm.php new file mode 100755 index 000000000..210d6edbc --- /dev/null +++ b/core/lib/Thelia/Form/CustomerProfilUpdateForm.php @@ -0,0 +1,90 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Symfony\Component\Validator\ExecutionContextInterface; +use Thelia\Model\CustomerQuery; +use Thelia\Model\ConfigQuery; +use Thelia\Core\Translation\Translator; + +/** + * Class CustomerProfilUpdateForm + * @package Thelia\Form + * @author Christophe Laffont + */ +class CustomerProfilUpdateForm extends CustomerCreateForm +{ + + protected function buildForm() + { + parent::buildForm(); + + $this->formBuilder + ->remove("auto_login") + // Remove From Personal Informations + ->remove("phone") + ->remove("cellphone") + // Remove Delivery Informations + ->remove("company") + ->remove("address1") + ->remove("address2") + ->remove("address3") + ->remove("city") + ->remove("zipcode") + ->remove("country") + // Remove Login Information + ->remove("password") + ->remove("password_confirm") + // Remove Terms & conditions + ->remove("agreed") + + // Add Newsletter + ->add("newsletter", "checkbox", array( + "label" => "I would like to receive the newsletter our the latest news.", + "label_attr" => array( + "for" => "newsletter" + ), + "required" => false + )); + } + + + /** + * @param $value + * @param ExecutionContextInterface $context + */ + public function verifyExistingEmail($value, ExecutionContextInterface $context) + { + $customer = CustomerQuery::getCustomerByEmail($value); + // If there is already a customer for this email address and if the customer is different from the current user, do a violation + if ($customer && $customer->getId() != $this->getRequest()->getSession()->getCustomerUser()->getId()) { + $context->addViolation("This email already exists."); + } + } + + public function getName() + { + return "thelia_customer_profil_update"; + } +} diff --git a/core/lib/Thelia/Form/CustomerUpdateForm.php b/core/lib/Thelia/Form/CustomerUpdateForm.php index b02c7e31e..06e094ec7 100755 --- a/core/lib/Thelia/Form/CustomerUpdateForm.php +++ b/core/lib/Thelia/Form/CustomerUpdateForm.php @@ -1,10 +1,10 @@ . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ + namespace Thelia\Form; use Symfony\Component\Validator\Constraints; -use Thelia\Model\ConfigQuery; use Thelia\Core\Translation\Translator; /** * Class CustomerUpdateForm * @package Thelia\Form - * @author Christophe Laffont + * @author Manuel Raynaud */ -class CustomerUpdateForm extends CustomerCreation +class CustomerUpdateForm extends BaseForm { - + /** + * + * in this function you add all the fields you need for your Form. + * Form this you have to call add method on $this->form attribute : + * + * $this->form->add("name", "text") + * ->add("email", "email", array( + * "attr" => array( + * "class" => "field" + * ), + * "label" => "email", + * "constraints" => array( + * new NotBlank() + * ) + * ) + * ) + * ->add('age', 'integer'); + * + * @return null + */ protected function buildForm() { - parent::buildForm(); - $this->formBuilder - ->remove("auto_login") - // Remove From Personal Informations - ->remove("phone") - ->remove("cellphone") - // Remove Delivery Informations - ->remove("company") - ->remove("address1") - ->remove("address2") - ->remove("address3") - ->remove("city") - ->remove("zipcode") - ->remove("country") - // Remove Login Information - ->remove("password") - ->remove("password_confirm") - // Remove Terms & conditions - ->remove("agreed") - - // Add Newsletter - ->add("newsletter", "checkbox", array( - "label" => "I would like to receive the newsletter our the latest news.", + ->add('update_logged_in_user', 'integer') // In a front office context, update the in-memory logged-in user data + ->add("company", "text", array( + "label" => Translator::getInstance()->trans("Company"), "label_attr" => array( - "for" => "newsletter" + "for" => "company" + ) + )) + ->add("firstname", "text", array( + "constraints" => array( + new Constraints\NotBlank() ), - "required" => false - )); + "label" => Translator::getInstance()->trans("First Name"), + "label_attr" => array( + "for" => "firstname" + ) + )) + ->add("lastname", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("Last Name"), + "label_attr" => array( + "for" => "lastname" + ) + )) + ->add("address1", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label_attr" => array( + "for" => "address" + ), + "label" => Translator::getInstance()->trans("Street Address") + )) + ->add("address2", "text", array( + "label" => Translator::getInstance()->trans("Address Line 2"), + "label_attr" => array( + "for" => "address2" + ) + )) + ->add("address3", "text", array( + "label" => Translator::getInstance()->trans("Address Line 3"), + "label_attr" => array( + "for" => "address3" + ) + )) + ->add("phone", "text", array( + "label" => Translator::getInstance()->trans("Phone"), + "label_attr" => array( + "for" => "phone" + ) + )) + ->add("cellphone", "text", array( + "label" => Translator::getInstance()->trans("Cellphone"), + "label_attr" => array( + "for" => "cellphone" + ) + )) + ->add("zipcode", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("Zip code"), + "label_attr" => array( + "for" => "zipcode" + ) + )) + ->add("city", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("City"), + "label_attr" => array( + "for" => "city" + ) + )) + ->add("country", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("Country"), + "label_attr" => array( + "for" => "country" + ) + )) + ->add("title", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("Title"), + "label_attr" => array( + "for" => "title" + ) + )) + ; } + /** + * @return string the name of you form. This name must be unique + */ public function getName() { return "thelia_customer_update"; diff --git a/core/lib/Thelia/Form/NewsletterForm.php b/core/lib/Thelia/Form/NewsletterForm.php index 7b32ed8df..3772df71d 100644 --- a/core/lib/Thelia/Form/NewsletterForm.php +++ b/core/lib/Thelia/Form/NewsletterForm.php @@ -73,7 +73,7 @@ class NewsletterForm extends BaseForm ) )) ), - 'label' => Translator::getInstance()->trans('email'), + 'label' => Translator::getInstance()->trans('Email address'), 'label_attr' => array( 'for' => 'email_newsletter' ) @@ -84,7 +84,7 @@ class NewsletterForm extends BaseForm { $customer = NewsletterQuery::create()->findOneByEmail($value); if ($customer) { - $context->addViolation("This email already exists"); + $context->addViolation("You are already subscribed!"); } } diff --git a/core/lib/Thelia/Model/CustomerQuery.php b/core/lib/Thelia/Model/CustomerQuery.php index 8cf373af6..359d072bd 100755 --- a/core/lib/Thelia/Model/CustomerQuery.php +++ b/core/lib/Thelia/Model/CustomerQuery.php @@ -17,4 +17,8 @@ use Thelia\Model\Base\CustomerQuery as BaseCustomerQuery; */ class CustomerQuery extends BaseCustomerQuery { + public static function getCustomerByEmail($email) + { + return self::create()->findOneByEmail($email); + } } // CustomerQuery diff --git a/templates/admin/default/ajax/address-update-modal.html b/templates/admin/default/ajax/address-update-modal.html index 39bafccea..687c51b57 100644 --- a/templates/admin/default/ajax/address-update-modal.html +++ b/templates/admin/default/ajax/address-update-modal.html @@ -1,6 +1,6 @@ {* Update an Address *} -{form name="thelia.address.update"} +{form name="thelia.admin.address.update"} {* Capture the dialog body, to pass it to the generic dialog *} {capture "edit_address_dialog"} diff --git a/templates/admin/default/customer-edit.html b/templates/admin/default/customer-edit.html index f3d83aa8b..6fea48aea 100644 --- a/templates/admin/default/customer-edit.html +++ b/templates/admin/default/customer-edit.html @@ -29,7 +29,7 @@
- {form name="thelia.customer.modification"} + {form name="thelia.admin.customer.modification"}
@@ -261,7 +261,7 @@
{* Add an Address *} - {form name="thelia.address.create"} + {form name="thelia.admin.address.create"} {* Capture the dialog body, to pass it to the generic dialog *} {capture "address_creation_dialog"} diff --git a/templates/admin/default/customers.html b/templates/admin/default/customers.html index 8fc937996..7da2815b9 100644 --- a/templates/admin/default/customers.html +++ b/templates/admin/default/customers.html @@ -162,7 +162,7 @@ {* Adding a new Category *} - {form name="thelia.customer.creation"} + {form name="thelia.admin.customer.create"} {* Capture the dialog body, to pass it to the generic dialog *} {capture "customer_creation_dialog"} diff --git a/templates/default/404.html b/templates/default/404.html new file mode 100644 index 000000000..b4ee90792 --- /dev/null +++ b/templates/default/404.html @@ -0,0 +1,42 @@ +{extends file="layout.tpl"} + +{* Body Class *} +{block name="body-class"}page-404{/block} + +{* Breadcrumb *} +{block name='no-return-functions' append} + {$breadcrumbs = [ + ['title' => {intl l="404"}, 'url'=>{url path="/404"}] + ]} +{/block} + +{block name="main-content"} +
+
+ +

+ 404 + {intl l="The page cannot be found"} +

+ + + + {ifloop rel="product_upsell"} + + {/ifloop} + +
+{/block} diff --git a/templates/default/account-password.html b/templates/default/account-password.html new file mode 100644 index 000000000..5b14ac1f6 --- /dev/null +++ b/templates/default/account-password.html @@ -0,0 +1,89 @@ +{extends file="layout.tpl"} + +{* Body Class *} +{block name="body-class"}page-account-password{/block} + +{* Breadcrumb *} +{block name='no-return-functions' append} + {$breadcrumbs = [['title' => {intl l="Account"}, 'url'=>{url path="/account"}]]} + {$breadcrumbs = [ + ['title' => {intl l="Account"}, 'url'=>{url path="/account"}], + ['title' => {intl l="Change Password"}, 'url'=>{url path="/account/password"}] + ]} +{/block} + +{block name="main-content"} + +
+ +
+ +

{intl l="Change Password"}

+ + {form name="thelia.front.customer.password.update"} + + {form_field form=$form field='success_url'} + + {/form_field} + + {form_hidden_fields form=$form} + + {if $form_error}
{$form_error_message}
{/if} + +
+
+ {intl l="Login Information"} +
+ +
+ {form_field form=$form field="password_old"} +
+ +
+ + {if $error } + {$message} + {assign var="error_focus" value="true"} + {/if} +
+
+ {/form_field} + + {form_field form=$form field="password"} +
+ +
+ + {if $error } + {$message} + {assign var="error_focus" value="true"} + {/if} +
+
+ {/form_field} + {form_field form=$form field="password_confirm"} +
+ +
+ + {if $error } + {$message} + {assign var="error_focus" value="true"} + {/if} +
+
+ {/form_field} +
+
+ +
+
+ +
+
+ + {/form} +
+ +
+{/block} \ No newline at end of file diff --git a/templates/default/account-update.html b/templates/default/account-update.html index d14db6681..6fb50162e 100644 --- a/templates/default/account-update.html +++ b/templates/default/account-update.html @@ -19,7 +19,7 @@

{intl l="Update Profil"}

- {form name="thelia.customer.update"} + {form name="thelia.front.customer.profil.update"} {assign var="isPost" value="{$smarty.post|count}"}
{form_field form=$form field='success_url'} @@ -30,7 +30,7 @@ {if $form_error}
{$form_error_message}
{/if} -
+
{intl l="Personal Informations"}
diff --git a/templates/default/address-update.html b/templates/default/address-update.html index b2508610e..710628015 100644 --- a/templates/default/address-update.html +++ b/templates/default/address-update.html @@ -21,7 +21,7 @@

{intl l="Create New Address"}

- {form name="thelia.address.update"} + {form name="thelia.front.address.update"} {loop name="customer.update" type="address" customer="current" id="{$address_id}"} {form_field form=$form field='success_url'} diff --git a/templates/default/address.html b/templates/default/address.html index 98363eb98..376adafa2 100644 --- a/templates/default/address.html +++ b/templates/default/address.html @@ -21,7 +21,7 @@

{intl l="Create New Address"}

- {form name="thelia.address.create"} + {form name="thelia.front.address.create"} {form_field form=$form field='success_url'} {* the url the user is redirected to on login success *} diff --git a/templates/default/assets/js/script.js b/templates/default/assets/js/script.js index cc351f27c..dd55f4cbb 100644 --- a/templates/default/assets/js/script.js +++ b/templates/default/assets/js/script.js @@ -27,9 +27,19 @@ $(this).addClass('open'); }) .on('mouseleave.subnav', '.dropdown', function(){ - if(!$(this).hasClass('open')) + var $this = $(this); + + if(!$this.hasClass('open')) return; - $(this).removeClass('open'); + + //This will check if an input child has focus. If no then remove class open + if ($this.find(":input:focus").length == 0){ + $this.removeClass('open'); + } else { + $this.find(":input:focus").one('blur', function(){ + $this.trigger('mouseleave.subnav'); + }); + } }); // Tooltip @@ -65,7 +75,6 @@ if($category_products.size() > 0){ var $parent = $category_products.parent(); - $parent.on('click.view-mode', '[data-toggle=view]', function(){ if( ($(this).hasClass('btn-grid') && $parent.hasClass('grid')) || ($(this).hasClass('btn-list') && $parent.hasClass('list'))) return; @@ -89,6 +98,32 @@ }).find(':radio:checked').trigger('change.account'); } + // Mini Newsletter Subscription + var $form_newsletter = $('#form-newsletter-mini'); + if($form_newsletter.size() > 0) { + $form_newsletter.on('submit.newsletter', function(){ + + $.ajax({ + url: $(this).attr('action'), + type: $(this).attr('method'), + data: $(this).serialize(), + dataType: 'json', + success: function(json) { + var $msg = ''; + if(json.success){ + $msg = json.message; + }else{ + $msg = json.message; + } + bootbox.alert($msg); + } + }); + + return false; + }); + } + + // Forgot Password /* var $forgot_password = $('.forgot-password', $form_login); @@ -159,6 +194,25 @@ }).filter(':has(:checked)').addClass('active'); }); + // Apply validation + $('#form-contact, #form-register').validate({ + highlight: function(element) { + $(element).closest('.form-group').addClass('has-error'); + }, + unhighlight: function(element) { + $(element).closest('.form-group').removeClass('has-error'); + }, + errorElement: 'span', + errorClass: 'help-block', + errorPlacement: function(error, element) { + if(element.parent('.input-group').length || element.prop('type') === 'checkbox' || element.prop('type') === 'radio'){ + error.prepend(' ').insertAfter(element.parent()); + }else{ + error.prepend(' ').insertAfter(element); + } + } + }); + if($("body").is(".page-product")){ @@ -174,10 +228,12 @@ var $old_price_container = $(".old-price", $("#product-details")); + var $select_quantity = $(this).find(":selected").attr("data-quantity"); + // Switch Quantity in product page $("select", $(".product-options")).change(function(){ - var $select_quantity = $(this).find(":selected").attr("data-quantity"); + $select_quantity = $(this).find(":selected").attr("data-quantity"); var $old_price = $(this).find(":selected").attr("data-old-price"); var $best_price = $(this).find(":selected").attr("data-price"); @@ -229,7 +285,31 @@ }); } + $(".form-product").submit(function(){ + var url_action = $(this).attr("action"); + var $cartContainer = $(".cart-container"); + $.ajax({type:"POST", data: $(this).serialize(), url:url_action, + success: function(data){ + + $cartContainer.html($(data).html()); + + $.ajax({url:"ajax/addCartMessage", + success: function(data){ + bootbox.dialog({ + message : data, + buttons : {} + }); + } + }); + }, + error: function(){ + console.log('Error.'); + } + }); + + return false; + }); $('#limit-top').change(function(e){ window.location = $(this).val() diff --git a/templates/default/assets/less/thelia/buttons.less b/templates/default/assets/less/thelia/buttons.less index 5a4c936d7..209426efe 100644 --- a/templates/default/assets/less/thelia/buttons.less +++ b/templates/default/assets/less/thelia/buttons.less @@ -22,6 +22,7 @@ &.btn-checkout, &.btn-checkout-next, &.btn-checkout-home, + &.btn-contact, &.btn-forgot, &.btn-login, &.btn-proceed-checkout, diff --git a/templates/default/assets/less/thelia/forms.less b/templates/default/assets/less/thelia/forms.less index d39d64ea1..637ea3a79 100755 --- a/templates/default/assets/less/thelia/forms.less +++ b/templates/default/assets/less/thelia/forms.less @@ -50,7 +50,6 @@ // Form Register #form-address, -#form-contact, #form-register { .panel-body { .control-label { .make-sm-column(3); } @@ -65,3 +64,8 @@ .control-btn { .make-sm-column-offset(3); .make-sm-column(5); } } } + +// Form Contact +#form-contact { + +} \ No newline at end of file diff --git a/templates/default/assets/less/thelia/global.less b/templates/default/assets/less/thelia/global.less index ec2eb793a..1430bdaa4 100755 --- a/templates/default/assets/less/thelia/global.less +++ b/templates/default/assets/less/thelia/global.less @@ -3,6 +3,19 @@ // Main Title .page-header { margin-top: 0; } +// 404 Page +.page_404{ + color: @brand-primary; + font-size: 9em; font-weight: bold; + text-align: center; + + span{ + color : #CCC; + display: block; + font-size: 15px; font-weight: normal; + } +} + // Collapse .no-js .collapse { display: block!important; } @@ -101,3 +114,22 @@ ul { } } } + + +.modal-dialog{ + td{vertical-align: middle} + + .close{ + margin: 10px; + position: relative; z-index: 10; + } + + .btn{ + margin-left: 10px; + } +} +@media screen and (min-width: 768px){ + .modal-dialog{ + width: 800px; + } +} diff --git a/templates/default/assets/less/thelia/product.less b/templates/default/assets/less/thelia/product.less index c1f9f4ec2..44965ed2a 100755 --- a/templates/default/assets/less/thelia/product.less +++ b/templates/default/assets/less/thelia/product.less @@ -4,6 +4,11 @@ float: right; font-size: .6em; } + h3{ + top: -14px !important; + margin: 0; + } + } @@ -140,6 +145,7 @@ border: 1px solid @nav-tabs-border-color; border-radius: 0 0 @border-radius-base @border-radius-base; padding: 30px 15px; + min-height: 180px; height: auto!important; height: 180px; } } -} \ No newline at end of file +} diff --git a/templates/default/assets/themes/default/less/theme.less b/templates/default/assets/themes/default/less/theme.less index fb25a4acc..f3cd5fb99 100755 --- a/templates/default/assets/themes/default/less/theme.less +++ b/templates/default/assets/themes/default/less/theme.less @@ -148,7 +148,7 @@ label { font-weight: 600; } } // Align the navbar with carousel -.container > .navbar-collapse { margin-left: -15px; } +.container > .navbar-collapse { margin-left: -15px; margin-right: -15px; } // Search header { @@ -164,7 +164,7 @@ header { /* Custom button */ -.page .btn-primary { +.btn-primary { border-left: 3px solid lighten(@brand-primary, 20%); .border-radius(0); color: #fff; @@ -1214,3 +1214,14 @@ td.product, } } } + +// Page Contact +#google-map { + margin-bottom: @line-height-computed; + @filter-map: ~"grayscale(100%)"; + -webkit-filter: @filter-map; + -moz-filter: @filter-map; + -ms-filter: @filter-map; + -o-filter: @filter-map; + filter: @filter-map; +} diff --git a/templates/default/cart.html b/templates/default/cart.html index 8aa6ef3a3..8619b6e6b 100644 --- a/templates/default/cart.html +++ b/templates/default/cart.html @@ -154,7 +154,7 @@
    {loop name="product_upsell" type="product" promo="yes" limit="5"} - {include file="includes/single-product.html" product_id=$ID hasBtn=true hasDescription=true width="218" height="146"} + {include file="includes/single-product.html" product_id=$ID hasBtn=false hasDescription=true width="218" height="146"} {/loop}
diff --git a/templates/default/category.html b/templates/default/category.html index 8bbb1d10b..b47abd222 100644 --- a/templates/default/category.html +++ b/templates/default/category.html @@ -18,24 +18,31 @@ {$product_page={$smarty.get.page|default:1}} {$product_order={$smarty.get.order|default:'alpha'}}
- {include file="includes/toolbar.html" toolbar="top" limit=$limit order=$product_order} -
-
-
    - {loop type="product" name="product_list" category={category attr="id"} limit=$limit page=$product_page order=$product_order} - {include file="includes/single-product.html" product_id=$ID hasBtn=true hasDescription=true width="218" height="146"} - {/loop} -
+ {ifloop rel="product_list"} + {include file="includes/toolbar.html" toolbar="top" limit=$limit order=$product_order} +
+
+
    + {loop type="product" name="product_list" category={category attr="id"} limit=$limit page=$product_page order=$product_order} + {include file="includes/single-product.html" product_id=$ID hasBtn=true hasDescription=true width="218" height="146"} + {/loop} +
+
+
+ {include file="includes/toolbar.html" toolbar="bottom"} + {/ifloop} + {elseloop rel="product_list"} +
+ {intl l="No products available in this category"}
-
- {include file="includes/toolbar.html" toolbar="bottom"} + {/elseloop}
diff --git a/templates/default/contact-success.html b/templates/default/contact-success.html index 59a79974e..29e7d7ee4 100644 --- a/templates/default/contact-success.html +++ b/templates/default/contact-success.html @@ -1,15 +1,8 @@ -{extends file="layout.tpl"} +{extends file="contact.html"} -{* Breadcrumb *} -{block name='no-return-functions' append} - {$breadcrumbs = [['title' => {intl l="Thanks !"}, 'url'=>{url path="/contact/success"}]]} -{/block} - -{block name="main-content"} -
-
-

{intl l="Thanks !"}

-

{intl l="Thanks for your message, we will contact as soon as possible"}

-
+{block name="contact-form"} +
+

{intl l="Thanks !"}

+

{intl l="Thanks for your message, we will contact as soon as possible."}

{/block} \ No newline at end of file diff --git a/templates/default/contact.html b/templates/default/contact.html index 2a9458368..2b0c7e7a9 100644 --- a/templates/default/contact.html +++ b/templates/default/contact.html @@ -10,96 +10,88 @@

{intl l="Contact us"}

- {form name="thelia.contact"} - - {form_hidden_fields form=$form} -
-
- 1. {intl l="Personal Informations"} -
-
- {form_field form=$form field="firstname"} -
- -
- - {if $error } - {$message} - {assign var="error_focus" value="true"} - {elseif $value != "" && !$error} - - {/if} -
-
- {/form_field} - {form_field form=$form field="lastname"} -
- -
- - {if $error } - {$message} - {assign var="error_focus" value="true"} - {elseif $value != "" && !$error} - - {/if} -
-
- {/form_field} - {form_field form=$form field="email"} -
- -
- - {if $error } - {$message} - {assign var="error_focus" value="true"} - {elseif $value != "" && !$error} - - {/if} -
-
- {/form_field} - {form_field form=$form field="subject"} -
- -
- - {if $error } - {$message} - {assign var="error_focus" value="true"} - {elseif $value != "" && !$error} - - {/if} -
-
- {/form_field} - {form_field form=$form field="message"} -
- -
- - {if $error } - {$message} - {assign var="error_focus" value="true"} - {elseif $value != "" && !$error} - - {/if} -
-
- {/form_field} +
+ +
-
-
- + {block name="contact-form"} + {form name="thelia.front.contact"} + + {form_hidden_fields form=$form} +
+
+ {intl l="Send us a message"} +
+
+
+ {form_field form=$form field="name"} +
+ +
+ + {if $error } + {$message} + {assign var="error_focus" value="true"} + {elseif $value != "" && !$error} + + {/if} +
+
+ {/form_field} + {form_field form=$form field="email"} +
+ +
+ + {if $error } + {$message} + {assign var="error_focus" value="true"} + {elseif $value != "" && !$error} + + {/if} +
+
+ {/form_field}
-
-
-
- - {/form} + {form_field form=$form field="subject"} +
+ +
+ + {if $error } + {$message} + {assign var="error_focus" value="true"} + {elseif $value != "" && !$error} + + {/if} +
+
+ {/form_field} + {form_field form=$form field="message"} +
+ +
+ + {if $error } + {$message} + {assign var="error_focus" value="true"} + {elseif $value != "" && !$error} + + {/if} +
+
+ {/form_field} + +
+
+ +
+
+
+
+ + {/form} + {/block}
-{/block} \ No newline at end of file +{/block} diff --git a/templates/default/includes/addedToCart.html b/templates/default/includes/addedToCart.html new file mode 100644 index 000000000..808eea39c --- /dev/null +++ b/templates/default/includes/addedToCart.html @@ -0,0 +1,52 @@ +
+ {loop type="cart" name="cartloop" position="last"} + + + + + + +
+ {loop name="product_thumbnail" type="image" product=$PRODUCT_ID width="218" height="146" resize_mode="borders" limit="1"} + Product #{$LOOP_COUNT} + {/loop} + +

{$TITLE}

+ {loop type="attribute_combination" name="product_options" product_sale_elements="$PRODUCT_SALE_ELEMENTS_ID"} +

{$ATTRIBUTE_TITLE}

+

{$ATTRIBUTE_AVAILABILITY_TITLE}

+ {/loop} +
+ + {if $IS_PROMO == 1} + {assign "real_price" $PROMO_TAXED_PRICE} +
{currency attr="symbol"} {$PROMO_TAXED_PRICE}
+ {currency attr="symbol"} {$TAXED_PRICE} + {else} + {assign "real_price" $TAXED_PRICE} +
{currency attr="symbol"} {$TAXED_PRICE}
+ {/if} + +
+ {/loop} + + {intl l="View cart"} + +
+ +{ifloop rel="product_upsell"} + + {/ifloop} diff --git a/templates/default/includes/menu.html b/templates/default/includes/menu.html index 476e3ecd0..de39f9fe6 100644 --- a/templates/default/includes/menu.html +++ b/templates/default/includes/menu.html @@ -2,29 +2,45 @@

{intl l="Categories"}

diff --git a/templates/default/includes/mini-cart.html b/templates/default/includes/mini-cart.html index b3b8de597..739302620 100644 --- a/templates/default/includes/mini-cart.html +++ b/templates/default/includes/mini-cart.html @@ -1,5 +1,5 @@ {ifloop rel="cartloop"} - {/ifloop} {elseloop rel="cartloop"} -
- + {if $hasBtn == true} {form name="thelia.cart.add" } -
+ {form_hidden_fields form=$form} @@ -115,11 +115,12 @@
- {if $hasSubmit == true} - - {else} - {intl l="View product"} - {/if} + + {if $hasSubmit == true} + + {else} + {intl l="View product"} + {/if}
@@ -127,7 +128,7 @@ {/form} - + {/if} \ No newline at end of file diff --git a/templates/default/layout.tpl b/templates/default/layout.tpl index fcbe4a840..37d275aa9 100644 --- a/templates/default/layout.tpl +++ b/templates/default/layout.tpl @@ -76,7 +76,7 @@ URL: http://www.thelia.net