Example #1
0
 public function checkEraty($idpaymentmethod)
 {
     $price = Session::getActiveglobalPriceWithDispatchmethod();
     if ($price > 0) {
         if ($price < 100) {
             return 0;
         }
     } else {
         $order = Session::getActiveClientOrder();
         if (!isset($order['priceWithDispatchMethod']) || $order['priceWithDispatchMethod'] < 100) {
             return 0;
         }
     }
     $sql = "SELECT ES.wariantsklepu, ES.numersklepu, ES.`char`\n\t\t\t\t\tFROM eratysettings ES\n\t\t\t\t\t\tLEFT JOIN paymentmethodview PV ON  ES.paymentmethodid  = PV.paymentmethodid\n\t\t\t\t\tWHERE PV.viewid = :viewid\n\t\t\t\t\tAND ES.paymentmethodid = :idpaymentmethod";
     $stmt = Db::getInstance()->prepare($sql);
     $stmt->bindValue('viewid', Helper::getViewId());
     $stmt->bindValue('idpaymentmethod', $idpaymentmethod);
     $stmt->execute();
     $rs = $stmt->fetch();
     if ($rs) {
         $Data = array('wariantsklepu' => $rs['wariantsklepu'], 'numersklepu' => $rs['numersklepu'], 'char' => $rs['char']);
         return $Data;
     }
     return 0;
 }
Example #2
0
 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);
     }
 }
Example #3
0
 public function setClientOrder($Data = array())
 {
     $customerOpinion = isset($Data['customeropinion']) ? App::getModel('formprotection')->cropDangerousCode($Data['customeropinion']) : '';
     Event::notify($this, 'frontend.finalization.setActiveClientOrder', array('dispatchmethod' => Session::getActiveDispatchmethodChecked(), 'cart' => Session::getActiveCart()));
     $clientOrder = array('cart' => Session::getActiveCart(), 'globalPrice' => App::getModel('cart')->getGlobalPrice(), 'globalPriceWithoutVat' => App::getModel('cart')->getGlobalPriceWithoutVat(), 'priceWithDispatchMethod' => Session::getActiveglobalPriceWithDispatchmethod(), 'priceWithDispatchMethodNetto' => Session::getActiveglobalPriceWithDispatchmethodNetto(), 'count' => App::getModel('cart/cart')->getProductAllCount(), 'clientdata' => App::getModel('client')->getClient(), 'clientaddress' => Session::getActiveOrderClientAddress(), 'deliveryAddress' => Session::getActiveOrderDeliveryAddress(), 'contactData' => Session::getActiveOrderContactData(), 'dispatchmethod' => Session::getActiveDispatchmethodChecked(), 'payment' => Session::getActivePaymentMethodChecked(), 'clientid' => Session::getActiveClientid(), 'customeropinion' => $customerOpinion);
     $rulesDiscount = $this->getRulesCart($clientOrder);
     if (is_array($rulesDiscount) && count($rulesDiscount) > 0 && $clientOrder['dispatchmethod'] > 0 && $clientOrder['payment'] > 0) {
         if ($rulesDiscount['freeshipping'] == 1) {
             $clientOrder['priceWithDispatchMethod'] = $clientOrder['priceWithDispatchMethod'] - $clientOrder['dispatchmethod']['dispatchmethodcost'];
             $clientOrder['priceWithDispatchMethodNetto'] = $clientOrder['priceWithDispatchMethodNetto'] - $clientOrder['dispatchmethod']['dispatchmethodcostnetto'];
             $clientOrder['dispatchmethod']['dispatchmethodcost'] = 0;
             $clientOrder['dispatchmethod']['dispatchmethodcostnetto'] = 0;
         }
         if ($rulesDiscount['symbol'] == '+') {
             $globalPricePromo = sprintf('%01.2f', $clientOrder['globalPrice'] + $rulesDiscount['discount']);
             $globalPriceWithoutVatPromo = sprintf('%01.2f', $clientOrder['globalPriceWithoutVat'] + $rulesDiscount['discount']);
             $priceWithDispatchMethodPromo = sprintf('%01.2f', $clientOrder['priceWithDispatchMethod'] + $rulesDiscount['discount']);
             $priceWithDispatchMethodNettoPromo = sprintf('%01.2f', $clientOrder['priceWithDispatchMethodNetto'] + $rulesDiscount['discount']);
             $message = $rulesDiscount['symbol'] . $this->registry->core->processPrice($rulesDiscount['discount']);
         } elseif ($rulesDiscount['symbol'] == '-') {
             $globalPricePromo = sprintf('%01.2f', $clientOrder['globalPrice'] - $rulesDiscount['discount']);
             $globalPriceWithoutVatPromo = sprintf('%01.2f', $clientOrder['globalPriceWithoutVat'] - $rulesDiscount['discount']);
             $priceWithDispatchMethodPromo = sprintf('%01.2f', $clientOrder['priceWithDispatchMethod'] - $rulesDiscount['discount']);
             $priceWithDispatchMethodNettoPromo = sprintf('%01.2f', $clientOrder['priceWithDispatchMethodNetto'] - $rulesDiscount['discount']);
             $message = $rulesDiscount['symbol'] . $this->registry->core->processPrice($rulesDiscount['discount']);
         } elseif ($rulesDiscount['symbol'] == '%') {
             $globalPricePromo = sprintf('%01.2f', abs($clientOrder['globalPrice'] * $rulesDiscount['discount'] / 100));
             $globalPriceWithoutVatPromo = sprintf('%01.2f', abs($clientOrder['globalPriceWithoutVat'] * $rulesDiscount['discount'] / 100));
             $priceWithDispatchMethodPromo = sprintf('%01.2f', abs($clientOrder['priceWithDispatchMethod'] * $rulesDiscount['discount'] / 100));
             $priceWithDispatchMethodNettoPromo = sprintf('%01.2f', abs($clientOrder['priceWithDispatchMethodNetto'] * $rulesDiscount['discount'] / 100));
             $message = ($rulesDiscount['discount'] - 100 > 0 ? '+' : '-') . abs($rulesDiscount['discount'] - 100) . $rulesDiscount['symbol'];
         }
         if ($globalPricePromo > 0 && $globalPriceWithoutVatPromo > 0 && $priceWithDispatchMethodPromo > 0 && $priceWithDispatchMethodNettoPromo > 0) {
             $clientOrder['globalPricePromo'] = $globalPricePromo;
             $clientOrder['globalPriceWithoutVatPromo'] = $globalPriceWithoutVatPromo;
             $clientOrder['priceWithDispatchMethodPromo'] = $priceWithDispatchMethodPromo;
             $clientOrder['priceWithDispatchMethodNettoPromo'] = $priceWithDispatchMethodNettoPromo;
             $clientOrder['rulescart'] = $rulesDiscount['name'];
             $clientOrder['rulescartdescription'] = $rulesDiscount['description'];
             $clientOrder['rulescartid'] = $rulesDiscount['rulescartid'];
             $clientOrder['rulescartmessage'] = $message;
             $clientOrder['rulescartfreeshipping'] = $rulesDiscount['freeshipping'];
         }
     }
     Session::setActiveClientOrder($clientOrder);
     return $this->getClientOrder();
 }