예제 #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');
     }
 }
예제 #2
0
 /**
  * prepares the data for the soap request
  *
  * @param sOrder $order
  * @param string $tsProductId
  * @param $shopId
  * @return array | data for the soap call
  */
 private function prepareDataForSoapRequest(sOrder $order, $tsProductId, $shopId)
 {
     /** @var Repository $shopRepository */
     $shopRepository = $this->em->getRepository('Shopware\\Models\\Shop\\Shop');
     $shop = $shopRepository->findOneBy(array('id' => $shopId));
     $settings = $this->tsConfig->getSettings($shopId);
     $user = $order->sUserData;
     $basket = $order->sBasketData;
     $userID = $user['billingaddress']['customernumber'];
     $currency = $shop->getCurrency()->toArray();
     $payment = $user['additional']['payment']['name'];
     $payment = $this->tsConfig->getTsPaymentCode($payment);
     $orderNumber = $order->sOrderNumber;
     $orderDate = date('Y-m-d', time()) . 'T' . date('H:i:s', time());
     $shopSystemVersion = 'Shopware/' . $this->config->get('Version') . ' ? TS v0.1';
     $decimalAmount = (double) $basket['AmountNumeric'];
     $tsId = $settings['trustedShopsId'];
     return array($tsId, $tsProductId, $decimalAmount, strtoupper($currency['currency']), strtoupper($payment), $user['additional']['user']['email'], $userID, $orderNumber, $orderDate, $shopSystemVersion, $settings['trustedShopsUser'], $settings['trustedShopsPassword']);
 }