/** * 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; }
function fn_twg_get_admin_settings($auth) { $settings = array(); $needed_langvars = fn_twg_get_admin_langvars(); $settings['lang'] = array(); foreach ($needed_langvars as $needed_langvar) { $settings['lang'][$needed_langvar] = __($needed_langvar); } $settings['lang'] = array_merge($settings['lang'], Lang::getLangVarsByPrefix('twapp')); $settings['lang'] = fn_twg_process_langvars($settings['lang']); $settings['statuses'] = fn_twg_get_statuses(); $settings['profileFields'] = fn_twg_prepare_profile_fields(fn_get_profile_fields('O'), false); list($settings['countries']) = fn_get_countries(array('only_avail' => true)); $settings['states'] = fn_twg_get_states(); $settings['titles'] = array(); $settings['saved_searches'] = fn_twg_get_searches($auth); $settings = array_merge($settings, fn_twg_get_checkout_settings()); $settings['currency'] = Registry::get('currencies.' . CART_PRIMARY_CURRENCY); $settings['use_email_as_login'] = Registry::get('settings.General.use_email_as_login'); if (!$settings['use_email_as_login']) { // For 4.3+ $settings['use_email_as_login'] = '******'; } $settings['time_format'] = Registry::get('settings.Appearance.time_format'); $settings['date_format'] = Registry::get('settings.Appearance.date_format'); $settings['languages'] = fn_twg_get_languages(); $settings['cart_language'] = CART_LANGUAGE; $settings['descr_sl'] = DESCR_SL; $settings['permissions'] = fn_twg_get_admin_permissions($auth); $settings['runtime_company_id'] = Registry::get('runtime.company_id'); $settings['user_company_id'] = isset($auth['company_id']) ? $auth['company_id'] : 0; $settings_company_name = Registry::get('settings.Company.company_name'); $runtime_company_name = Registry::get('runtime.company_data.company'); $settings['company_name'] = $runtime_company_name ? $runtime_company_name : $settings_company_name; $settings['storefront_url'] = Registry::get('runtime.company_data.storefront'); if (Registry::get('runtime.companies_available_count') > 1) { $settings['companies'] = fn_twg_get_admin_companies(PRODUCT_EDITION == 'ULTIMATE', 0); } else { $settings['companies'] = false; } return $settings; }