/** * Called from confirmAction View * Customers requests to finish current order * Check if all conditions match and save order * * @return void */ public function finishAction() { if ($this->Request()->getParam('sUniqueID') && !empty($this->session['sOrderVariables'])) { $sql = ' SELECT transactionID as sTransactionumber, ordernumber as sOrderNumber FROM s_order WHERE temporaryID=? AND userID=? '; $order = Shopware()->Db()->fetchRow($sql, array($this->Request()->getParam('sUniqueID'), Shopware()->Session()->sUserId)); if (!empty($order)) { $this->View()->assign($order); $this->View()->assign($this->session['sOrderVariables']->getArrayCopy()); return; } } if (empty($this->session['sOrderVariables']) || $this->getMinimumCharge() || $this->getEsdNote() || $this->getDispatchNoOrder()) { return $this->forward('confirm'); } $checkQuantities = $this->basket->sCheckBasketQuantities(); if (!empty($checkQuantities['hideBasket'])) { return $this->forward('confirm'); } $this->View()->assign($this->session['sOrderVariables']->getArrayCopy()); if ($this->basket->sCountBasket() <= 0) { $this->View()->assign($this->session['sOrderVariables']->getArrayCopy()); return; } if (!empty($this->View()->sUserData['additional']['payment']['embediframe'])) { $this->View()->assign($this->session['sOrderVariables']->getArrayCopy()); return; } if ($this->Request()->getParam('sNewsletter') !== null) { $this->session['sNewsletter'] = $this->Request()->getParam('sNewsletter') ? true : false; } if ($this->Request()->getParam('sComment') !== null) { $this->session['sComment'] = trim(strip_tags($this->Request()->getParam('sComment'))); } $basket = $this->View()->sBasket; $agreements = $this->getInvalidAgreements($basket, $this->Request()); if (!empty($agreements)) { $this->View()->sAGBError = array_key_exists('agbError', $agreements); return $this->forward('confirm', null, null, ['agreementErrors' => $agreements]); } if (!$this->basket->validateVoucher($this->session['sessionId'], $this->session['sUserId'])) { $namespace = $this->container->get('snippets')->getNamespace('frontend/basket/internalMessages'); return $this->forward('confirm', null, null, ['voucherErrors' => array($namespace->get('VoucherFailureAlreadyUsed', 'This voucher was used in an previous order'))]); } if (!empty($this->session['sNewsletter'])) { $this->admin->sUpdateNewsletter(true, $this->admin->sGetUserMailById(), true); } $this->saveOrder(); $this->View()->assign($this->session['sOrderVariables']->getArrayCopy()); }