Ejemplo n.º 1
0
 /**
  * Получает параметры заказа
  */
 public function getOrderData()
 {
     $model = new Models_Order();
     $orderData = $model->getOrder(" id = " . DB::quote($_POST['id']));
     $orderData = $orderData[$_POST['id']];
     if ($orderData['number'] == '') {
         $orderData['number'] = $orderData['id'];
         DB::query("UPDATE `" . PREFIX . "order` SET `number`= " . DB::quote($orderData['number']) . " WHERE `id`=" . DB::quote($orderData['id']) . "");
     }
     $orderData['yur_info'] = unserialize(stripslashes($orderData['yur_info']));
     $orderData['order_content'] = unserialize(stripslashes($orderData['order_content']));
     // Запрос для проверки, существует ли система скидок
     $percent = false;
     $discountSyst = false;
     $res = DB::query('SELECT * FROM `' . PREFIX . 'plugins` WHERE `folderName` = "discount-system"');
     $act = DB::fetchArray($res);
     $result = DB::query('SHOW TABLES LIKE "' . PREFIX . 'discount-system%"');
     if (DB::numRows($result) == 2 && $act['active']) {
         $percent = 0;
         $discountSyst = true;
     }
     if (!empty($orderData['order_content'])) {
         $product = new Models_Product();
         foreach ($orderData['order_content'] as &$item) {
             foreach ($item as &$v) {
                 $v = rawurldecode($v);
             }
         }
         foreach ($orderData['order_content'] as &$items) {
             $res = $product->getProduct($items['id']);
             $items['image_url'] = $res['image_url'];
             $items['property'] = htmlspecialchars_decode(str_replace('&', '&', $items['property']));
             $response['discount'] = $items['discount'];
             $percent = $items['discount'];
             $items['maxCount'] = $res['count'];
             $variants = DB::query("SELECT `id`, `count` FROM `" . PREFIX . "product_variant`\n                  WHERE `product_id`=" . DB::quote($items['id']) . " AND `code`=" . DB::quote($items['code']));
             if ($variant = DB::fetchAssoc($variants)) {
                 $items['variant'] = $variant['id'];
                 $items['maxCount'] = $variant['count'];
             }
         }
     }
     //заменить на получение скидки
     $codes = array();
     // Запрос для проверки , существуют ли промокоды.
     $result = DB::query('SHOW TABLES LIKE "' . PREFIX . 'promo-code"');
     if (DB::numRows($result)) {
         $res = DB::query('SELECT * FROM `' . PREFIX . 'plugins` WHERE `folderName` = "promo-code"');
         $act = DB::fetchArray($res);
         if ($act['active']) {
             $res = DB::query('SELECT code, percent FROM `' . PREFIX . 'promo-code` 
       WHERE invisible = 1 
       AND now() >= `from_datetime`
       AND now() <= `to_datetime`');
             while ($code = DB::fetchAssoc($res)) {
                 $codes[] = $code['code'];
                 if ($code['code'] == $orderData['order_content'][0]['coupon']) {
                     $percent = $percent == 0 ? $code['percent'] : $percent;
                 }
             }
         }
     }
     $response['order'] = $orderData;
     $response['order']['discountsSystem'] = $discountSyst;
     $response['order']['discontPercent'] = $percent;
     $response['order']['promoCodes'] = $codes;
     $response['order']['date_delivery'] = $orderData['date_delivery'] ? date('d.m.Y', strtotime($orderData['date_delivery'])) : '';
     $deliveryArray = $model->getDeliveryMethod();
     $response['deliveryArray'] = $deliveryArray;
     $paymentArray = array();
     $i = 1;
     while ($payment = $model->getPaymentMethod($i)) {
         $paymentArray[$i] = $payment;
         $i++;
     }
     $response['paymentArray'] = $paymentArray;
     $this->data = $response;
     return true;
 }
Ejemplo n.º 2
0
 /**
  * Возвращает массив доступных способов доставки.
  * @return mixed массив доступных способов доставки .
  */
 public function getDelivery()
 {
     $result = array();
     // Модель для работы заказом.
     $model = new Models_Order();
     $cart = new Models_Cart();
     $cartSumm = $cart->getTotalSumm();
     foreach ($model->getDeliveryMethod() as $id => $delivery) {
         if ($delivery['free'] != 0 && $delivery['free'] <= $cartSumm) {
             $delivery['cost'] = 0;
         }
         if (!$delivery['activity']) {
             continue;
         }
         if (isset($_POST['delivery']) && $_POST['delivery'] == $id) {
             $delivery['checked'] = 1;
         }
         // Заполнение массива способов доставки.
         $result[$delivery['id']] = $delivery;
     }
     // Если доступен только один способ доставки, то он будет выделен.
     if (1 === count($result)) {
         $deliveryId = array_keys($result);
         $result[$deliveryId[0]]['checked'] = 1;
     }
     return $result;
 }
Ejemplo n.º 3
0
                    // }
                    foreach ($colorScheme as $scheme) {
                        if (strpos($scheme, 'color') === 0) {
                            $color = str_replace(array('color_', '.css'), '', $scheme);
                            $schemes[] = $color;
                        }
                    }
                }
            }
            $templates[] = array('foldername' => $foldername, 'colorScheme' => $schemes, 'colorSchemeActive' => $colorSchemeActive);
        }
    }
}
$licenceKey = MG::getOption('licenceKey', true);
$mOrder = new Models_Order();
$deliveryArray = $mOrder->getDeliveryMethod();
//массив способов оплаты
$paymentArray = array();
$i = 1;
while ($payment = $mOrder->getPaymentMethod($i)) {
    $paymentArray[$i] = $payment;
    $i++;
}
$paymentArray = array_reverse($paymentArray);
usort($paymentArray, array("Models_Order", "sort"));
$res = DB::query("\r\n  SELECT *\r\n  FROM `" . PREFIX . "setting`\r\n  WHERE `active` = 'Y'\r\n  ");
while ($option = DB::fetchAssoc($res)) {
    $options[$option['option']] = $option;
}
$allGroupsOptions = array('smtpHost', 'smtpLogin', 'smtpPass', 'smtpPort');
$groups = array('STNG_GROUP_1' => array('sitename', 'adminEmail', 'noReplyEmail', 'templateName', 'currencyShopIso', 'priceFormat', 'phoneMask', 'widgetCode'), 'STNG_GROUP_2' => array('horizontMenu', 'actionInCatalog', 'printRemInfo', 'printProdNullRem', 'printStrProp', 'printCompareButton', 'compareCategory', 'useCaptcha', 'autoRegister', 'printFilterResult', 'lockAuthorization', 'orderNumber', 'popupCart', 'catalogIndex', 'productInSubcat', 'copyrightMoguta', 'picturesCategory', 'requiredFields'), 'STNG_GROUP_3' => array('mainPageIsCatalog', 'countСatalogProduct', 'countNewProduct', 'countRecomProduct', 'countSaleProduct', 'randomProdBlock', 'buttonBuyName', 'buttonMoreName', 'buttonCompareName'), 'STNG_GROUP_4' => array('heightPreview', 'widthPreview', 'heightSmallPreview', 'widthSmallPreview', 'waterMark', 'waterMarkVariants'), 'STNG_GROUP_5' => array('smtp', 'smtpHost', 'smtpLogin', 'smtpPass', 'smtpPort'), 'STNG_GROUP_6' => array('shopName', 'shopPhone', 'shopAddress', 'shopLogo', 'backgroundSite'), 'STNG_GROUP_7' => array('cacheObject', 'cacheMode', 'cacheTime', 'cacheHost', 'cachePort', 'cacheCssJs'));