public function saveOrder($Data) { $objResponse = new xajaxResponse(); try { $order = $this->setClientOrder($Data); if ($order != NULL) { if (empty($order['dispatchmethod'])) { $objResponse->script("GError('" . _('ERR_ORDER_SAVE') . "', '" . _('ERR_NO_DELIVERY_SELECTED') . "');"); return $objResponse; } if (empty($order['payment'])) { $objResponse->script("GError('" . _('ERR_ORDER_SAVE') . "', '" . _('ERR_NO_PAYMENT_SELECTED') . "');"); return $objResponse; } $saveOrder = App::getModel('order')->saveOrder($order); $clientid = Session::getActiveClientid(); Session::setActiveorderid($saveOrder); $email = $order['contactData']['email']; $orderid = Session::getActiveorderid(); $orderlink = App::getModel('order')->generateOrderLink($orderid); if ($orderlink != NULL && $orderid != NULL) { App::getModel('order')->changeOrderLink($orderid, $orderlink); $banktransfer = $this->registry->core->loadModuleSettings('banktransfer', Helper::getViewId()); $payment_model = App::getModel('Admin/paymentmethod/paymentmethod')->getPaymentmethodModelById($order['payment']['idpaymentmethod']); $this->registry->template->assign('order', $order); $this->registry->template->assign('orderId', $orderid); $this->registry->template->assign('orderlink', $orderlink); $this->registry->template->assign('paymentmodel', $payment_model); $this->registry->template->assign('bankdata', $banktransfer); $mailer = App::getModel('mailer'); if (!empty($this->layer['terms'])) { $mailer->AddAttachment('./upload/' . $this->layer['terms'], Core::clearUTF(_('TXT_CONDITIONS')) . '.pdf'); } $mailer->sendEmail(array('template' => 'orderClient', 'email' => array($email), 'bcc' => true, 'subject' => _('TXT_ORDER_CLIENT') . ': ' . $orderid, 'viewid' => Helper::getViewId())); Session::unsetActiveCart(); Session::unsetActiveglobalPriceWithDispatchmethod(); Session::unsetActiveglobalPriceWithDispatchmethodNetto(); Session::unsetActiveDispatchmethodChecked(); Session::unsetActivePaymentMethodChecked(); Session::unsetActiveGlobalPrice(); Session::unsetActiveGlobalPriceWithoutVat(); $paymentMethodData = array('orderId' => Session::getActiveorderid(), 'orderData' => Session::getActiveClientOrder()); Session::setActivePaymentData($paymentMethodData); Session::unsetActiveorderid(); Session::unsetActiveClientOrder(); App::getModel('dataset')->flushCache(); $url = $this->registry->router->generate('frontend.payment', true, array('action' => 'accept')); $objResponse->script("window.location.href = '{$url}';"); } } else { $objResponse->script("GError('" . _('ERR_ORDER_SAVE') . "','" . _('ERR_ORDER_NOT_DEFINED') . "');"); } } catch (Exception $e) { $objResponse->script("GError('" . _('ERR_ORDER_SAVE') . "','" . _('ERR_ORDER_SAVE_MSG') . "');"); } return $objResponse; }
public function getCartVariables() { $method = Session::getActiveDispatchmethodChecked(); $payment = Session::getActivePaymentMethodChecked(); $this->clientModel = App::getModel('client'); $this->paymentModel = App::getModel('payment'); $this->deliveryModel = App::getModel('delivery'); $this->dispatchMethods = $this->deliveryModel->getDispatchmethodPrice(); // check rules $checkRulesCart = App::getModel('cart')->checkRulesCart(); if (is_array($checkRulesCart) && count($checkRulesCart) > 0) { $this->registry->template->assign('checkRulesCart', $checkRulesCart); } // DON'T CHECK DISPATCH METHOD BY DEFAULT //if ($method == NULL || !isset($this->dispatchMethods[$method['dispatchmethodid']])){ // set dispatch method if not selected or not available //$method = current($this->dispatchMethods); //App::getModel('delivery')->setDispatchmethodChecked($method['dispatchmethodid']); //} // unset paymentmethod if not available for selected dispatchmethod if (!isset($this->dispatchMethods[$method['dispatchmethodid']])) { Session::unsetActivePaymentMethodChecked(); } if ($method != NULL && isset($this->dispatchMethods[$method['dispatchmethodid']])) { App::getModel('delivery')->setDispatchmethodChecked($method['dispatchmethodid']); } // check payment $paymentMethods = App::getModel('payment')->getPaymentMethods(); $paymentAvailable = false; foreach ($paymentMethods as $method) { if ($method['idpaymentmethod'] == $payment['idpaymentmethod']) { $paymentAvailable = true; } } if ($payment == 0 || !$paymentAvailable) { if (isset($paymentMethods[0])) { App::getModel('payment')->setPaymentMethodChecked($paymentMethods[0]['idpaymentmethod'], $paymentMethods[0]['name']); } } else { App::getModel('payment')->setPaymentMethodChecked($payment['idpaymentmethod'], $payment['paymentmethodname']); } $minimumordervalue = $this->getMinimumOrderValue(); $order = App::getModel('finalization')->setClientOrder(); $assignData = array('deliverymethods' => $this->dispatchMethods, 'checkedDelivery' => Session::getActiveDispatchmethodChecked(), 'checkedPayment' => Session::getActivePaymentMethodChecked(), 'checkedDeliveryOption' => Session::getActiveDispatchmethodOption(), 'payments' => $paymentMethods, 'minimumordervalue' => $minimumordervalue, 'priceWithDispatchMethod' => Session::getActiveglobalPriceWithDispatchmethod(), 'summary' => App::getModel('finalization')->getOrderSummary(), 'order' => Session::getActiveClientOrder()); foreach ($assignData as $key => $assign) { $this->registry->template->assign($key, $assign); } }