Пример #1
0
 public function update_status(OrderEvent $event)
 {
     if ($event->getOrder()->getDeliveryModuleId() === LocalPickup::getModCode()) {
         if ($event->getOrder()->isSent()) {
             $contact_email = ConfigQuery::read('store_email');
             if ($contact_email) {
                 $message = MessageQuery::create()->filterByName('order_confirmation_localpickup')->findOne();
                 if (false === $message) {
                     throw new \Exception("Failed to load message 'order_confirmation_localpickup'.");
                 }
                 $order = $event->getOrder();
                 $customer = $order->getCustomer();
                 $store = ConfigQuery::create();
                 $country = CountryQuery::create()->findPk($store->read("store_country"));
                 $country = CountryI18nQuery::create()->filterById($country->getId())->findOneByLocale($order->getLang()->getLocale())->getTitle();
                 $this->parser->assign('order_id', $order->getId());
                 $this->parser->assign('order_ref', $order->getRef());
                 $this->parser->assign('store_name', $store->read("store_name"));
                 $this->parser->assign('store_address1', $store->read("store_address1"));
                 $this->parser->assign('store_address2', $store->read("store_address2"));
                 $this->parser->assign('store_address3', $store->read("store_address3"));
                 $this->parser->assign('store_zipcode', $store->read("store_zipcode"));
                 $this->parser->assign('store_city', $store->read("store_city"));
                 $this->parser->assign('store_country', $country);
                 $message->setLocale($order->getLang()->getLocale());
                 $instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::read('store_name'));
                 // Build subject and body
                 $message->buildMessage($this->parser, $instance);
                 $this->getMailer()->send($instance);
             }
         }
     }
 }
Пример #2
0
 /**
  * Checks if we are the payment module for the order, and if the order is paid,
  * then send a confirmation email to the customer.
  *
  * @params OrderEvent $order
  */
 public function update_status(OrderEvent $event)
 {
     $payzen = new Payzen();
     if ($event->getOrder()->isPaid() && $payzen->isPaymentModuleFor($event->getOrder())) {
         $contact_email = ConfigQuery::read('store_email', false);
         Tlog::getInstance()->debug("Sending confirmation email from store contact e-mail {$contact_email}");
         if ($contact_email) {
             $message = MessageQuery::create()->filterByName(Payzen::CONFIRMATION_MESSAGE_NAME)->findOne();
             if (false === $message) {
                 throw new \Exception(sprintf("Failed to load message '%s'.", Payzen::CONFIRMATION_MESSAGE_NAME));
             }
             $order = $event->getOrder();
             $customer = $order->getCustomer();
             $this->parser->assign('order_id', $order->getId());
             $this->parser->assign('order_ref', $order->getRef());
             $message->setLocale($order->getLang()->getLocale());
             $instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::read('store_name'));
             // Build subject and body
             $message->buildMessage($this->parser, $instance);
             $this->getMailer()->send($instance);
             Tlog::getInstance()->debug("Confirmation email sent to customer " . $customer->getEmail());
         }
     } else {
         Tlog::getInstance()->debug("No confirmation email sent (order not paid, or not the proper payement module.");
     }
 }
Пример #3
0
 public function generate(ModuleGenerateEvent $event)
 {
     $templates = $this->findInPath($event->getResourcesPath(), "/__MODULE__.*\\.php\$/");
     $this->parser->assign("moduleCode", $event->getModuleCode());
     $this->parser->assign("tables", $event->getEntities());
     $this->processModule($templates, $event->getResourcesPath(), $event->getModulePath(), $event->getModuleCode());
 }
Пример #4
0
 public function defaultErrorFallback(GetResponseForExceptionEvent $event)
 {
     $this->parser->assign("status_code", 500);
     $this->parser->assign("exception_message", $event->getException()->getMessage());
     $this->parser->setTemplateDefinition($this->securityContext->hasAdminUser() ? $this->parser->getTemplateHelper()->getActiveAdminTemplate() : $this->parser->getTemplateHelper()->getActiveFrontTemplate());
     $response = new Response($this->parser->render(ConfigQuery::getErrorMessagePageName()), 500);
     $event->setResponse($response);
 }
Пример #5
0
 /**
  * @param  \TheliaStudio\Parser\Entity\Table $table
  * @param  \SplFileInfo[]                    $templates
  * @param $resourcesPath
  * @param $moduleCode
  * @throws \Exception
  * @throws \SmartyException
  */
 protected function processTemplate(Table $table, $templates, $resourcesPath, $moduleCode)
 {
     $this->parser->assign("table", $table);
     foreach ($templates as $template) {
         $fetchedTemplate = $this->parser->fetch($template->getRealPath());
         $fileName = str_replace("__TABLE__", str_replace("_", "-", $table->getRawTableName()), $template->getFilename());
         $relativePath = str_replace($resourcesPath, "", $template->getPath() . DS);
         $completeFilePath = THELIA_MODULE_DIR . $moduleCode . DS . $relativePath . DS . $fileName;
         $this->writeFile($completeFilePath, $fetchedTemplate, false, true);
     }
 }
Пример #6
0
 /**
  * @param  ModuleGenerateEvent $event
  * @return mixed
  */
 protected function generate(ModuleGenerateEvent $event)
 {
     $formConfig = $this->readConfigFormFile($event->getModulePath());
     if (empty($formConfig)) {
         return;
     }
     $this->parser->assign("form", $formConfig);
     $this->parser->assign("moduleCode", $event->getModuleCode());
     $this->generateClasses($event->getResourcesPath(), $event->getModulePath(), $event->getModuleCode());
     $this->generateTemplates($event->getResourcesPath(), $event->getModulePath(), $event->getModuleCode());
     $this->generateConfiguration($event->getModulePath(), $event->getModuleCode());
     $this->generateRouting($event->getModulePath(), $event->getModuleCode());
 }
Пример #7
0
 public function update_status(OrderEvent $event)
 {
     if ($event->getOrder()->getDeliveryModuleId() === DpdClassic::getModuleId()) {
         if ($event->getOrder()->getStatusId() === DpdClassic::STATUS_SENT) {
             $contact_email = ConfigQuery::read('store_email');
             if ($contact_email) {
                 $message = MessageQuery::create()->filterByName('order_confirmation_dpdclassic')->findOne();
                 if (false === $message) {
                     throw new \Exception("Failed to load message 'order_confirmation_dpdclassic'.");
                 }
                 $order = $event->getOrder();
                 $customer = $order->getCustomer();
                 $this->parser->assign('order_id', $order->getId());
                 $this->parser->assign('order_ref', $order->getRef());
                 $this->parser->assign('order_date', $order->getCreatedAt());
                 $this->parser->assign('update_date', $order->getUpdatedAt());
                 $this->parser->assign('package', $order->getDeliveryRef());
                 $message->setLocale($order->getLang()->getLocale());
                 $instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::read('store_name'));
                 // Build subject and body
                 $message->buildMessage($this->parser, $instance);
                 $this->getMailer()->send($instance);
             }
         }
     }
 }
Пример #8
0
 public function update_status(OrderEvent $event)
 {
     if ($event->getOrder()->getPaymentModuleId() === Paypal::getModCode()) {
         if ($event->getOrder()->isPaid()) {
             $contact_email = ConfigQuery::read('store_email');
             if ($contact_email) {
                 $message = MessageQuery::create()->filterByName('payment_confirmation_paypal')->findOne();
                 if (false === $message) {
                     throw new \Exception("Failed to load message 'payment_confirmation_paypal'.");
                 }
                 $order = $event->getOrder();
                 $customer = $order->getCustomer();
                 $this->parser->assign('order_id', $order->getId());
                 $this->parser->assign('order_ref', $order->getRef());
                 $message->setLocale($order->getLang()->getLocale());
                 $instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::read('store_name'));
                 // Build subject and body
                 $message->buildMessage($this->parser, $instance);
                 $this->getMailer()->send($instance);
             }
         }
     }
 }
Пример #9
0
 /**
  * Calculate the message body, given the HTML entered in the back-office, the message layout, and the message template
  * @param  ParserInterface $parser
  * @param $message
  * @param $layout
  * @param $template
  * @return bool
  */
 protected function getMessageBody($parser, $message, $layout, $template, $compressOutput = true)
 {
     $body = false;
     // Try to get the body from template file, if a file is defined
     if (!empty($template)) {
         try {
             $body = $parser->render($template, [], $compressOutput);
         } catch (ResourceNotFoundException $ex) {
             // Ignore this.
         }
     }
     // We did not get it ? Use the message entered in the back-office
     if ($body === false) {
         $body = $parser->renderString($message, [], $compressOutput);
     }
     // Do we have a layout ?
     if (!empty($layout)) {
         // Populate the message body variable
         $parser->assign('message_body', $body);
         // Render the layout file
         $body = $parser->render($layout, [], $compressOutput);
     }
     return $body;
 }