示例#1
0
 public static function getOrdersAsApiList($orders, $lang_code)
 {
     $order_ids = array();
     foreach ($orders as $order) {
         $order_ids[] = $order['order_id'];
     }
     if (!empty($order_ids)) {
         $payment_names = db_get_hash_array("SELECT order_id, payment\n                 FROM ?:orders, ?:payment_descriptions\n                 WHERE ?:payment_descriptions.payment_id = ?:orders.payment_id\n                 AND ?:payment_descriptions.lang_code = ?s\n                 AND ?:orders.order_id IN (?a)", 'order_id', $lang_code, $order_ids);
         $shippings = db_get_hash_array("SELECT order_id, data\n                 FROM ?:order_data\n                 WHERE type = ?s\n                 AND order_id IN (?a)", 'order_id', 'L', $order_ids);
     } else {
         $payment_names = array();
         $shippings = array();
     }
     foreach ($orders as $k => $v) {
         $orders[$k]['payment'] = !empty($payment_names[$v['order_id']]['payment']) ? $payment_names[$v['order_id']]['payment'] : '';
         $orders[$k]['shippings'] = array();
         if (!empty($shippings[$v['order_id']]['data'])) {
             $shippings = unserialize($shippings[$v['order_id']]['data']);
             if (empty($shippings)) {
                 continue;
             }
             foreach ($shippings as $shipping) {
                 $orders[$k]['shippings'][] = array('carrier' => !empty($shipping['carrier']) ? $shipping['carrier'] : '', 'shipping' => !empty($shipping['shipping']) ? $shipping['shipping'] : '');
             }
         }
     }
     $fields = array('order_id', 'user_id', 'total', 'timestamp', 'status', 'date', 'status_info', 'firstname', 'lastname', 'email', 'payment_name', 'shippings');
     return Api::getAsList('orders', $orders, $fields);
 }
示例#2
0
文件: func.php 项目: arpad9/bygmarket
/**
 * Prepare all settings, wich should be passed to js
 */
function fn_twg_get_all_settings()
{
    $settings = fn_twg_get_boot_settings();
    $addon_settings = TwigmoSettings::get();
    $settings['access_id'] = $addon_settings['access_id'];
    $settings['currency'] = Registry::get('currencies.' . CART_SECONDARY_CURRENCY);
    $settings['primaryCurrency'] = Registry::get('currencies.' . CART_PRIMARY_CURRENCY);
    $settings['url_for_facebook'] = isset($addon_settings['url_for_facebook']) ? fn_twg_get_external_info_url($addon_settings['url_for_facebook']) : '';
    $settings['url_for_twitter'] = isset($addon_settings['url_for_twitter']) ? fn_twg_get_external_info_url($addon_settings['url_for_twitter']) : '';
    $settings['lang'] = array_merge(fn_twg_get_default_customer_langvars(), Lang::getCustomerLangVars());
    // Countries/states
    list($countries) = fn_get_countries(array('only_avail' => true));
    $settings = array_merge($settings, Api::getAsList('countries', $countries));
    $settings['states'] = fn_twg_get_states();
    // Info pages
    $pages_location = $addon_settings['home_page_content'] == 'tw_home_page_blocks' ? 'twigmo.post' : 'index.index';
    $pages = TwigmoBlock::getBlocksForLocation($pages_location, array('pages'));
    $settings['info_pages'] = array();
    foreach ($pages as $page) {
        $settings['info_pages'] = array_merge($settings['info_pages'], $page['pages']['page']);
    }
    // If page link begin with # then interpret this link as twigmo page
    foreach ($settings['info_pages'] as $k => $page) {
        if (preg_match('/^\\#.*$/', $page['link'])) {
            $settings['info_pages'][$k]['twigmo_page'] = substr($page['link'], 1);
        }
    }
    // Only required profile fields
    $only_required = isset($addon_settings['only_req_profile_fields']) ? $addon_settings['only_req_profile_fields'] : 'N';
    $settings['profileFields'] = fn_twg_prepare_profile_fields(fn_get_profile_fields(), $only_required);
    $settings['profileFieldsCheckout'] = fn_twg_prepare_profile_fields(fn_get_profile_fields('O'), $only_required);
    $settings['show_product_code'] = isset($addon_settings['show_product_code']) ? $addon_settings['show_product_code'] : 'N';
    $settings['titles'] = array();
    $settings['profile'] = fn_twg_get_user_info($_SESSION['auth']['user_id']);
    $settings['cart'] = fn_twg_api_get_session_cart($_SESSION['cart']);
    $settings['sortings'] = fn_twg_get_sortings();
    $settings['security_hash'] = fn_generate_security_hash();
    $settings['productType'] = PRODUCT_EDITION;
    $settings['languages'] = array_values(Lang::getLanguages());
    $settings['cart_language'] = CART_LANGUAGE;
    $settings['cart_prices_w_taxes'] = Registry::get('settings.Appearance.cart_prices_w_taxes');
    $settings['show_prices_taxed_clean'] = Registry::get('settings.Appearance.show_prices_taxed_clean');
    $settings['no_image_path'] = Registry::get('config.no_image_path');
    // Suppliers
    $settings['suppliers_vendor'] = Registry::get('settings.Suppliers.apply_for_vendor');
    $settings['display_supplier'] = Registry::get('settings.Suppliers.display_supplier') === 'Y' || Registry::get('settings.Vendors.display_vendor') === 'Y';
    $settings['display_supplier'] = $settings['display_supplier'] ? 'Y' : 'N';
    // General section
    $fields = array('use_email_as_login', 'min_order_amount', 'min_order_amount_type', 'allow_negative_amount', 'inventory_tracking', 'allow_anonymous_shopping', 'tax_calculation');
    foreach ($fields as $field) {
        $settings[$field] = Registry::get('settings.General.' . $field);
    }
    $settings = array_merge($settings, fn_twg_get_checkout_settings());
    if (version_compare(PRODUCT_VERSION, '4.0.2', '>=')) {
        $anonymous_shopping_settings_map = array('allow_shopping' => 'Y', 'hide_price_and_add_to_cart' => 'P', 'hide_add_to_cart' => 'B');
        $settings['allow_anonymous_shopping'] = $anonymous_shopping_settings_map[$settings['allow_anonymous_shopping']];
    }
    $settings['default_location'] = array('country' => Registry::get('settings.General.default_country'), 'state' => Registry::get('settings.General.default_state'));
    $settings['show_modifiers'] = Registry::get('settings.General.display_options_modifiers');
    $settings['SEOEnabled'] = Registry::get('addons.seo.status') == 'A';
    $settings['GATrackEcommerce'] = Registry::get('addons.google_analytics.status') == 'A' && Registry::get('addons.google_analytics.track_ecommerce') == 'Y' && file_exists(Registry::get('config.dir.addons') . 'google_analytics/controllers/frontend/checkout.post.php');
    if (fn_allowed_for('MULTIVENDOR')) {
        $settings['company_data'] = !empty($_SESSION['auth']['company_id']) ? fn_get_company_data($_SESSION['auth']['company_id']) : array();
    } else {
        $settings['company_data'] = array();
    }
    $settings['checkout'] = Registry::get('settings.Checkout');
    fn_set_hook('twg_get_all_settings', $settings);
    $settings['lang'] = fn_twg_process_langvars($settings['lang']);
    return $settings;
}
示例#3
0
     }
     $pagination_params = array('items_per_page' => !empty($items_per_page) ? $items_per_page : TWG_RESPONSE_ITEMS_LIMIT, 'page' => !empty($_REQUEST['page']) ? $_REQUEST['page'] : 1, 'total_items' => !empty($total_items) ? $total_items : 0);
     if ($is_paginate) {
         fn_twg_set_response_pagination($response, $pagination_params);
     }
     $response->returnResponse($object);
 }
 if ($_REQUEST['action'] == 'details') {
     if ($object == 'shipment_data') {
         $shippings = db_get_array("SELECT a.shipping_id,\n                 b.shipping\n                 FROM ?:shippings as a\n                 LEFT JOIN ?:shipping_descriptions as b\n                 ON a.shipping_id = b.shipping_id AND b.lang_code = ?s\n                 WHERE a.status = ?s\n                 ORDER BY a.position", DESCR_SL, 'A');
         $carriers_data = fn_twg_get_carriers();
         $carriers = array();
         foreach ($carriers_data as $k => $v) {
             $carriers[] = array('carrier_id' => $k, 'carrier' => $v);
         }
         $result = array('shippings' => Api::getAsList('shippings', $shippings), 'carriers' => Api::getAsList('carriers', $carriers));
         $response->setData($result);
         $response->returnResponse($object);
     }
     if (empty($_REQUEST['id'])) {
         $response->addError('ERROR_WRONG_OBJECT_DATA', str_replace('[object]', $object, __('twgadmin_wrong_api_object_data')));
         $response->returnResponse();
     }
     if ($object == 'orders') {
         $order_id = $_REQUEST['id'];
         $order = TwigmoOrder::apiGetOrderDetails($order_id);
         if (empty($order)) {
             $response->addError('ERROR_OBJECT_WAS_NOT_FOUND', str_replace('[object]', $object, __('twgadmin_object_was_not_found')));
             $response->returnResponse();
         }
         $response->setData($order);
示例#4
0
             }
         }
         $cart['recalculate'] = true;
         $cart['calculate_shipping'] = true;
         Registry::set('runtime.controller', 'checkout', true);
         fn_calculate_cart_content($cart, $auth, 'E', true, 'F', true);
         Registry::set('runtime.controller', 'twigmo');
         $response->setData(array('payments' => $payment_methods['payment'], 'cart' => fn_twg_api_get_session_cart($cart, $lang_code)));
     }
 } elseif ($meta['object'] == 'shipping_methods') {
     $_SESSION['cart']['calculate_shipping'] = true;
     $params = array('cart' => &$_SESSION['cart'], 'auth' => &$_SESSION['auth']);
     Registry::set('runtime.controller', 'checkout', true);
     $product_groups = fn_twg_api_get_shippings($params);
     Registry::set('runtime.controller', 'twigmo');
     $shipping_methods = Api::getAsList('companies_rates', $product_groups);
     $shipping_methods['shipping_failed'] = !empty($_SESSION['cart']['shipping_failed']) ? $_SESSION['cart']['shipping_failed'] : false;
     $response->setData($shipping_methods);
 } elseif ($meta['object'] == 'product_files') {
     $file_url = array('fileUrl' => fn_url("orders.get_file&ekey=" . $_REQUEST['ekey'] . "&file_id=" . $_REQUEST['file_id'] . "&product_id=" . $_REQUEST['product_id'], AREA, 'rel'));
     $response->setData($file_url);
 } elseif ($meta['object'] == 'errors') {
     $response->returnResponse();
 } elseif ($meta['object'] == 'reward_points_userlog') {
     $items_per_page = !empty($items_per_page) ? $items_per_page : TWG_RESPONSE_ITEMS_LIMIT;
     $request = $_REQUEST;
     $auth =& $_SESSION['auth'];
     $page = !empty($request['page']) ? $request['page'] : 1;
     list($_reward_points_log, $params) = fn_twg_get_reward_points_userlog(array('user_id' => $auth['user_id'], 'items_per_page' => $items_per_page, 'page' => $page));
     $reward_points_log = array();
     $statuses = fn_get_simple_statuses(STATUSES_ORDER, true, true);
示例#5
0
 /**
  * Get blocks for the twigmo homepage
  * @param  string $dispatch        Dispatch of needed location
  * @param  array  $allowed_objects - array of blocks types
  * @return array  blocks
  */
 public static final function getBlocksForLocation($dispatch, $allowed_objects)
 {
     $allowed_page_types = array('T', 'L', 'F');
     $blocks = array();
     $location = Location::instance(fn_twg_get_default_layout_id())->get($dispatch);
     if (!$location) {
         return $blocks;
     }
     $get_cont_params = array('location_id' => $location['location_id']);
     $container = Container::getList($get_cont_params);
     if (!$container or !$container['CONTENT']) {
         return $blocks;
     }
     $grids_params = array('container_ids' => $container['CONTENT']['container_id']);
     $grids = Grid::getList($grids_params);
     if (!$grids) {
         return $blocks;
     }
     $block_grids = Block::instance()->getList(array('?:bm_snapping.*', '?:bm_blocks.*', '?:bm_blocks_descriptions.*'), Grid::getIds($grids));
     $image_params = TwigmoSettings::get('images.catalog');
     foreach ($block_grids as $block_grid) {
         foreach ($block_grid as $block) {
             if ($block['status'] != 'A' or !in_array($block['type'], $allowed_objects)) {
                 continue;
             }
             $block_data = array('block_id' => $block['block_id'], 'title' => $block['name'], 'hide_header' => isset($block['properties']['hide_header']) ? $block['properties']['hide_header'] : 'N', 'user_class' => $block['user_class']);
             $block_scheme = SchemesManager::getBlockScheme($block['type'], array());
             if ($block['type'] == 'html_block') {
                 // Html block
                 if (isset($block['content']['content']) and fn_string_not_empty($block['content']['content'])) {
                     $block_data['html'] = $block['content']['content'];
                 }
             } elseif (!empty($block_scheme['content']) and !empty($block_scheme['content']['items'])) {
                 // Products and categories: get items
                 $template_variable = 'items';
                 $field = $block_scheme['content']['items'];
                 fn_set_hook('render_block_content_pre', $template_variable, $field, $block_scheme, $block);
                 $items = RenderManager::getValue($template_variable, $field, $block_scheme, $block);
                 // Filter pages - only texts, links and forms posible
                 if ($block['type'] == 'pages') {
                     foreach ($items as $item_id => $item) {
                         if (!in_array($item['page_type'], $allowed_page_types)) {
                             unset($items[$item_id]);
                         }
                     }
                 }
                 if (empty($items)) {
                     continue;
                 }
                 $block_data['total_items'] = count($items);
                 // Images
                 if ($block['type'] == 'products' or $block['type'] == 'categories') {
                     $object_type = $block['type'] == 'products' ? 'product' : 'category';
                     foreach ($items as $items_id => $item) {
                         if (!empty($item['main_pair'])) {
                             $main_pair = $item['main_pair'];
                         } else {
                             $main_pair = fn_get_image_pairs($item[$object_type . '_id'], $object_type, 'M', true, true);
                         }
                         if (!empty($main_pair)) {
                             $items[$items_id]['icon'] = TwigmoImage::getApiImageData($main_pair, $object_type, 'icon', $image_params);
                         }
                     }
                 }
                 // Banners properties
                 if ($block['type'] == 'banners') {
                     $rotation = $block['properties']['template'] == 'addons/banners/blocks/carousel.tpl' ? 'Y' : 'N';
                     $block_data['delay'] = $rotation == 'Y' ? $block['properties']['delay'] : 0;
                     $block_data['hide_navigation'] = isset($block['properties']['navigation']) && $block['properties']['navigation'] == 'N' ? 'Y' : 'N';
                 }
                 $block_data[$block['type']] = Api::getAsList($block['type'], $items);
             }
             $blocks[$block['block_id']] = $block_data;
         }
     }
     return $blocks;
 }
示例#6
0
         list($logs, $pagination_params) = fn_twg_get_logs();
         $data['timeline'] = array($logs, $pagination_params);
     }
     $response->setData($data);
     $is_paginate = true;
 } elseif ($object == 'users') {
     $_REQUEST['user_type'] = 'C';
     if (empty($_REQUEST['page'])) {
         $_REQUEST['page'] = 1;
     }
     list($users, $search) = fn_get_users($_REQUEST, $auth, $items_per_page);
     $total_items = $search['total_items'];
     if (empty($users)) {
         $response->returnResponse();
     }
     $response->setResponseList(Api::getAsList($object, $users));
     $is_paginate = true;
 } elseif ($object == 'orders') {
     $_REQUEST['compact'] = 'Y';
     if (!empty($_REQUEST['sname'])) {
         $_REQUEST['cname'] = $_REQUEST['email'] = $_REQUEST['order_id'] = $_REQUEST['sname'];
     }
     if (!empty($_REQUEST['status'])) {
         $_REQUEST['status'] = unserialize($_REQUEST['status']);
     }
     list($orders, $search) = fn_get_orders($_REQUEST, $items_per_page);
     $total_items = $search['total_items'];
     if (empty($orders)) {
         $response->returnResponse();
     }
     $response->setResponseList(TwigmoOrder::getOrdersAsApiList($orders, $lang_code));