Exemplo n.º 1
0
 /**
  * extends the checkout controller to show the trustedShops items
  *
  * @param \Enlight_Event_EventArgs $args
  * @return void
  */
 public function onCheckoutPostDispatch(\Enlight_Event_EventArgs $args)
 {
     /** @var $subject \Enlight_Controller_Action */
     $subject = $args->getSubject();
     $view = $subject->View();
     $request = $subject->Request();
     $shopId = $this->shop->getId();
     //get basic config of trusted shop for the seal template and trusted shop id
     $config = $this->getConfig($shopId);
     $basket = $view->sBasket;
     //if the current controller is the checkout controller extend the config for the basket
     if ($request->getActionName() != 'finish') {
         $this->controlBasketTsArticle($subject, $request, $basket['Amount']);
     }
     $basketConfig = $this->getTrustedShopBasketConfig($subject, $basket['Amount']);
     $config = array_merge($basketConfig, $config);
     $config['excellence'] = $this->tsSoapApi->checkCertificateTypeIfExcellence($shopId, false);
     if (isset($basket['content'])) {
         foreach ($basket['content'] as &$article) {
             $explode = explode('_', $article['ordernumber']);
             if (count($explode) == 4 && substr($explode[0], 0, 2) == 'TS') {
                 $article['trustedShopArticle'] = true;
             }
         }
         //set delivery date
         $config['deliveryDate'] = $this->getDeliveryDate($basket['content']);
     }
     if ($request->getActionName() == 'finish') {
         $paymentName = $view->sPayment;
         $config['paymentName'] = $this->tsConfig->getTsPaymentCode($paymentName['name']);
     }
     //extend template
     $view->sTrustedShops = $config;
     if (!$this->isResponsiveTemplate()) {
         $this->template->addTemplateDir($this->bootstrapPath . 'Views/emotion');
         $view->extendsTemplate('frontend/plugins/swag_trusted_shops/index/index.tpl');
         $view->extendsTemplate('frontend/plugins/swag_trusted_shops/checkout/cart.tpl');
         if ($request->getActionName() == 'finish') {
             $view->extendsTemplate('frontend/plugins/swag_trusted_shops/checkout/finish.tpl');
         }
     } else {
         $this->template->addTemplateDir($this->bootstrapPath . 'Views/responsive');
     }
 }