本文整理汇总了PHP中fn_explode函数的典型用法代码示例。如果您正苦于以下问题:PHP fn_explode函数的具体用法?PHP fn_explode怎么用?PHP fn_explode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fn_explode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fn_get_short_companies
/**
* Gets brief company data array: <i>(company_id => company_name)</i>
*
* @param array $params Array of search params:
* <ul>
* <li>string status - Status field from the <i>?:companies table</i></li>
* <li>string item_ids - Comma separated list of company IDs</li>
* <li>int displayed_vendors - Number of companies for displaying. Will be used as LIMIT condition</i>
* </ul>
* Global variable <i>$_REQUEST</i> can be passed as argument
* @return mixed If <i>$params</i> was not empty returns array:
* <ul>
* <li>companies - Hash array of companies <i>(company_id => company)</i></li>
* <li>count - Number of returned companies</li>
* </ul>
* else returns hash array of companies <i>(company_id => company)</i></li>
*/
function fn_get_short_companies($params = array())
{
$condition = $limit = $join = $companies = '';
if (!empty($params['status'])) {
$condition .= db_quote(" AND ?:companies.status = ?s ", $params['status']);
}
if (!empty($params['item_ids'])) {
$params['item_ids'] = fn_explode(",", $params['item_ids']);
$condition .= db_quote(" AND ?:companies.company_id IN (?n) ", $params['item_ids']);
}
if (!empty($params['displayed_vendors'])) {
$limit = 'LIMIT ' . $params['displayed_vendors'];
}
$condition .= Registry::get('runtime.company_id') ? fn_get_company_condition('?:companies.company_id', true, Registry::get('runtime.company_id')) : '';
fn_set_hook('get_short_companies', $params, $condition, $join, $limit);
$count = db_get_field("SELECT COUNT(*) FROM ?:companies {$join} WHERE 1 {$condition}");
$_companies = db_get_hash_single_array("SELECT ?:companies.company_id, ?:companies.company FROM ?:companies {$join} WHERE 1 {$condition} ORDER BY ?:companies.company {$limit}", array('company_id', 'company'));
if (!fn_allowed_for('ULTIMATE')) {
$companies[0] = Registry::get('settings.Company.company_name');
$companies = $companies + $_companies;
} else {
$companies = $_companies;
}
$return = array('companies' => $companies, 'count' => $count);
if (!empty($params)) {
unset($return['companies'][0]);
return array($return);
}
return $companies;
}
示例2: array_sort_by_fields
function array_sort_by_fields(&$data, $sortby)
{
static $sort_funcs = array();
if (empty($sort_funcs[$sortby])) {
$code = "\$c=0;";
foreach (fn_explode(',', $sortby) as $key) {
$d = '1';
if (substr($key, 0, 1) == '-') {
$d = '-1';
$key = substr($key, 1);
}
if (substr($key, 0, 1) == '#') {
$key = substr($key, 1);
$code .= "if ( \$a['{$key}'] > \$b['{$key}']) return {$d} * 1;\n";
$code .= "if ( \$a['{$key}'] < \$b['{$key}']) return {$d} * -1;\n";
} else {
$code .= "if ( (\$c = strcasecmp(\$a['{$key}'],\$b['{$key}'])) != 0 ) return {$d} * \$c;\n";
}
}
$code .= 'return $c;';
$sort_func = $sort_funcs[$sortby] = create_function('$a, $b', $code);
} else {
$sort_func = $sort_funcs[$sortby];
}
uasort($data, $sort_func);
}
示例3: create
public function create($params)
{
$data = array();
$valid_params = true;
$status = Response::STATUS_BAD_REQUEST;
unset($params['product_id']);
if (empty($params['category_ids'])) {
$data['message'] = __('api_required_field', array('[field]' => 'category_ids'));
$valid_params = false;
}
if (!isset($params['price'])) {
$data['message'] = __('api_required_field', array('[field]' => 'price'));
$valid_params = false;
}
if ($valid_params) {
if (!is_array($params['category_ids'])) {
$params['category_ids'] = fn_explode(',', $params['category_ids']);
}
$this->prepareFeature($params);
$this->prepareImages($params);
$product_id = fn_update_product($params);
if ($product_id) {
$status = Response::STATUS_CREATED;
$data = array('product_id' => $product_id);
}
}
return array('status' => $status, 'data' => $data);
}
示例4: fn_get_newsletters
function fn_get_newsletters($params = array(), $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
$default_params = array('type' => NEWSLETTER_TYPE_NEWSLETTER, 'only_available' => true, 'page' => 1, 'items_per_page' => $items_per_page);
$params = array_merge($default_params, $params);
$_conditions = array();
if ($params['only_available']) {
$_conditions[] = "?:newsletters.status = 'A'";
}
if ($params['type']) {
$_conditions[] = db_quote("?:newsletters.type = ?s", $params['type']);
}
if (!empty($_conditions)) {
$_conditions = implode(' AND ', $_conditions);
} else {
$_conditions = '1';
}
$limit = '';
if (!empty($params['items_per_page'])) {
$params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:newsletters WHERE ?p", $_conditions);
$limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
}
$newsletters = db_get_array("SELECT ?:newsletters.newsletter_id, ?:newsletters.status, ?:newsletters.sent_date, " . "?:newsletters.status, ?:newsletters.mailing_lists, ?:newsletter_descriptions.newsletter FROM ?:newsletters " . "LEFT JOIN ?:newsletter_descriptions ON ?:newsletter_descriptions.newsletter_id=?:newsletters.newsletter_id " . "AND ?:newsletter_descriptions.lang_code= ?s " . "WHERE ?p ORDER BY ?:newsletters.sent_date DESC, ?:newsletters.status {$limit}", $lang_code, $_conditions);
foreach ($newsletters as $id => $data) {
$newsletters[$id]['mailing_lists'] = !empty($data['mailing_lists']) ? fn_explode(',', $data['mailing_lists']) : array();
}
return array($newsletters, $params);
}
示例5: fn_top_menu_form
/**
* Form top menu
*
* @param array $top_menu Top menu data from the database
* @param int $level Current menu level
* @param boolean $active Menu item active flag, returned by reference to set tree branch as active
*
* @return array Formed top menu
*/
function fn_top_menu_form($top_menu, $level = 0, &$active = NULL)
{
/**
* Modifies top menu forming parameters
*
* @param array $top_menu Top menu data from the database
* @param int $level Current menu level
* @param boolean $active Menu item active flag
*/
fn_set_hook('top_menu_form_pre', $top_menu, $level, $active);
$_active = false;
foreach ($top_menu as $k => $v) {
if (!empty($v['param_3'])) {
// get extra items
list($type, $id, $use_name) = fn_explode(':', $v['param_3']);
if ($type == 'C') {
// categories
$cats = fn_get_categories_tree($id, true);
$v['subitems'] = fn_array_merge(fn_top_menu_standardize($cats, 'category_id', 'category', 'subcategories', 'categories.view?category_id='), !empty($v['subitems']) ? $v['subitems'] : array(), false);
if ($use_name == 'Y' && !empty($id)) {
$v['descr'] = fn_get_category_name($id);
$v['param'] = 'categories.view?category_id=' . $id;
}
//Should add this checking because the same pages can have different request parameters and the next checking
//with fn_top_menu_is_current_url function could return incorrect result.
//For example: categories.view?category_id=165 and categories.view?category_id=165¤cy=EUR should have the same active elements.
if (fn_check_is_active_menu_item(array('category_id' => $id), 'categories')) {
$top_menu[$k]['active'] = true;
}
} elseif ($type == 'A') {
// pages
$params = array('from_page_id' => $id, 'get_tree' => 'multi_level', 'status' => 'A');
list($pages) = fn_get_pages($params);
$v['subitems'] = fn_array_merge(fn_top_menu_standardize($pages, 'page_id', 'page', 'subpages', 'pages.view?page_id='), !empty($v['subitems']) ? $v['subitems'] : array(), false);
if ($use_name == 'Y' && !empty($id)) {
$page_data = fn_get_page_data($id);
$v['descr'] = $page_data['page'];
$v['param'] = !empty($page_data['link']) ? $page_data['link'] : 'pages.view?page_id=' . $id;
}
if (fn_check_is_active_menu_item(array('page_id' => $id), 'pages')) {
$top_menu[$k]['active'] = true;
}
} else {
// for addons
/**
* Deprecated since 4.3.6, use top_menu_form_post instead
*/
fn_set_hook('top_menu_form', $v, $type, $id, $use_name);
}
}
if (!empty($v['param']) && fn_top_menu_is_current_url($v['param'], $v['param_2'])) {
$top_menu[$k]['active'] = true;
// Store active value
$_active = true;
}
if (!empty($v['subitems'])) {
$top_menu[$k]['subitems'] = fn_top_menu_form($v['subitems'], $level + 1, $active);
// If active status was returned fron children
if ($active) {
$top_menu[$k]['active'] = $active;
// Strore fo return and reset activity status for athother elements on this level
// Because in one level may be only one active item
$_active = true;
$active = false;
}
}
$top_menu[$k]['item'] = $v['descr'];
$top_menu[$k]['href'] = $v['param'];
$top_menu[$k]['level'] = $level;
unset($top_menu[$k]['descr'], $top_menu[$k]['param']);
}
$active = $_active;
/**
* Modifies top menu items
*
* @param array $top_menu Top menu data from the database
* @param int $level Current menu level
* @param boolean $active Menu item active flag
*/
fn_set_hook('top_menu_form_post', $top_menu, $level, $active);
return $top_menu;
}
示例6: list
list($cml, $s_commerceml) = RusEximCommerceml::getParamsCommerceml();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$suffix = '';
if ($mode == 'save_offers_data') {
if ($s_commerceml['exim_1c_create_prices'] == 'Y') {
$prices = $_REQUEST['prices_1c'];
if (!empty($_REQUEST['list_price_1c'])) {
$_list_prices = fn_explode(',', $_REQUEST['list_price_1c']);
$list_prices = array();
foreach ($_list_prices as $_list_price) {
$list_prices[] = array('price_1c' => trim($_list_price), 'usergroup_id' => 0, 'type' => 'list');
}
$prices = fn_array_merge($list_prices, $prices, false);
}
if (!empty($_REQUEST['base_price_1c'])) {
$_base_prices = fn_explode(',', $_REQUEST['base_price_1c']);
$base_prices = array();
foreach ($_base_prices as $_base_price) {
$base_prices[] = array('price_1c' => trim($_base_price), 'usergroup_id' => 0, 'type' => 'base');
}
$prices = fn_array_merge($base_prices, $prices, false);
db_query("DELETE FROM ?:rus_exim_1c_prices");
foreach ($prices as $price) {
if (!empty($price['price_1c'])) {
db_query("INSERT INTO ?:rus_exim_1c_prices ?e", $price);
}
}
} else {
fn_set_notification('W', __('warning'), __('base_price_empty'));
}
}
示例7: fn_top_menu_select
/**
* Select active tab in top menu
*
* @param array $top_menu top menu data from the database
* @param string $controller current controller
* @param string $mode current mode
* @param string $current_url current URL
* @param mixed $child_key key of selected child
* @return array formed top menu
*/
function fn_top_menu_select($top_menu, $controller, $mode, $current_url, &$child_key = NULL)
{
$selected_key = NULL;
foreach ($top_menu as $k => $v) {
if (!empty($v['param_2'])) {
// get currently selected item
$d = fn_explode(',', $v['param_2']);
foreach ($d as $p) {
if (strpos($p, '.') !== false) {
list($c, $m) = fn_explode('.', $p);
} else {
$c = $p;
$m = '';
}
if ($controller == $c && (empty($m) || $m == $mode)) {
$selected_key = $k;
}
}
} elseif (!empty($v['href'])) {
// if url is not empty, get selected tab by it
parse_str(substr($v['href'], strpos($v['href'], '?') + 1), $a);
$equal = true;
foreach ($a as $_k => $_v) {
if (!isset($_REQUEST[$_k]) || $_REQUEST[$_k] != $_v) {
$equal = false;
break;
}
}
if ($equal == true) {
$selected_key = $k;
}
}
if ($selected_key === NULL && !empty($v['subitems'])) {
$c_key = NULL;
$top_menu[$k]['subitems'] = fn_top_menu_select($v['subitems'], $controller, $mode, $current_url, $c_key);
if ($c_key !== NULL) {
$selected_key = $k;
}
}
if ($selected_key !== NULL) {
$top_menu[$selected_key]['selected'] = true;
$child_key = true;
break;
}
}
return $top_menu;
}
示例8: fn_import_feature
function fn_import_feature($data, &$processed_data, &$skip_record)
{
static $new_groups = array();
$skip_record = true;
$feature = reset($data);
$langs = array_keys($data);
$main_lang = reset($langs);
if (Registry::get('runtime.company_id')) {
$company_id = Registry::get('runtime.company_id');
} else {
if (!empty($feature['company'])) {
$company_id = fn_get_company_id_by_name($feature['company']);
} else {
$company_id = isset($feature['company_id']) ? $feature['company_id'] : Registry::get('runtime.company_id');
}
}
if (!empty($feature['feature_id'])) {
$feature_id = db_get_field('SELECT ?:product_features.feature_id FROM ?:product_features WHERE feature_id = ?i', $feature['feature_id']);
}
$parent_id = fn_exim_get_product_feature_group_id($feature['parent_id'], $company_id, $new_groups, $main_lang);
if (empty($feature_id)) {
$condition = db_quote("WHERE description = ?s AND lang_code = ?s AND feature_type = ?s", $feature['description'], $main_lang, $feature['feature_type']);
$condition .= db_quote(" AND parent_id = ?i", $parent_id);
$feature_id = db_get_field('SELECT ?:product_features.feature_id FROM ?:product_features_descriptions ' . 'LEFT JOIN ?:product_features ON ?:product_features.feature_id = ?:product_features_descriptions.feature_id ' . $condition);
}
unset($feature['feature_id']);
$feature['company_id'] = $company_id;
$feature['parent_id'] = $parent_id;
$feature['variants'] = array();
if (!empty($feature['Variants'])) {
$variants = fn_explode(',', $feature['Variants']);
list($origin_variants) = fn_get_product_feature_variants(array('feature_id' => $feature_id), 0, $main_lang);
$feature['original_var_ids'] = implode(',', array_keys($origin_variants));
foreach ($variants as $variant) {
$feature['variants'][]['variant'] = $variant;
}
}
$skip = false;
if (empty($feature_id)) {
$feature_id = fn_update_product_feature($feature, 0, $main_lang);
$processed_data['N']++;
fn_set_progress('echo', __('updating') . ' features <b>' . $feature_id . '</b>. ', false);
} else {
if (!fn_check_company_id('product_features', 'feature_id', $feature_id)) {
$processed_data['S']++;
$skip = true;
} else {
fn_update_product_feature($feature, $feature_id, $main_lang);
if (in_array($feature_id, $new_groups)) {
$processed_data['N']++;
} else {
$processed_data['E']++;
fn_set_progress('echo', __('creating') . ' features <b>' . $feature_id . '</b>. ', false);
}
}
}
if (!$skip) {
fn_exim_set_product_feature_categories($feature_id, $feature, $main_lang);
foreach ($data as $lang_code => $feature_data) {
unset($feature_data['feature_id']);
db_query('UPDATE ?:product_features_descriptions SET ?u WHERE feature_id = ?i AND lang_code = ?s', $feature_data, $feature_id, $lang_code);
}
if (fn_allowed_for('ULTIMATE')) {
if (!empty($company_id)) {
fn_exim_update_share_feature($feature_id, $company_id);
}
}
}
return $feature_id;
}
示例9: array
}
}
$navigation['static'][$root][(string) $it['title']] = array('href' => (string) $it['dispatch'] . (!empty($it['extra']) ? '?' . (string) $it['extra'] : ''), 'position' => isset($it['links_group']) ? $groups[(string) $it['links_group']] : $is[$root]);
// 1st way
if ($_dispatch == (string) $it['dispatch']) {
if (empty($it['extra']) || strpos(Registry::get('config.current_url'), (string) $it['extra']) !== false) {
$navigation['selected_tab'] = $root;
$navigation['subsection'] = (string) $it['title'];
$tab_selected = true;
}
}
// 1st A way
if (!empty($it['alt'])) {
$alt = fn_explode(',', (string) $it['alt']);
foreach ($alt as $v) {
@(list($_d, $_m) = fn_explode('.', $v));
if ((!empty($_m) && MODE == $_m || empty($_m)) && CONTROLLER == $_d) {
$navigation['selected_tab'] = $root;
$navigation['subsection'] = (string) $it['title'];
$tab_selected = true;
break;
}
}
}
// 2nd way
if (empty($tab_selected) && strpos((string) $it['dispatch'], CONTROLLER . (strpos((string) $it['dispatch'], '.') ? '.' : '')) === 0) {
$navigation['selected_tab'] = $root;
$navigation['subsection'] = (string) $it['title'];
$tab_selected = true;
}
}
示例10: db_get_row
$_SESSION['current_category_id'] = $product['main_category'];
}
}
if (!empty($product['meta_description']) || !empty($product['meta_keywords'])) {
Registry::get('view')->assign('meta_description', $product['meta_description']);
Registry::get('view')->assign('meta_keywords', $product['meta_keywords']);
} else {
$meta_tags = db_get_row("SELECT meta_description, meta_keywords FROM ?:category_descriptions WHERE category_id = ?i AND lang_code = ?s", $_SESSION['current_category_id'], CART_LANGUAGE);
if (!empty($meta_tags)) {
Registry::get('view')->assign('meta_description', $meta_tags['meta_description']);
Registry::get('view')->assign('meta_keywords', $meta_tags['meta_keywords']);
}
}
if (!empty($_SESSION['current_category_id'])) {
$_SESSION['continue_url'] = "categories.view?category_id={$_SESSION['current_category_id']}";
$parent_ids = fn_explode('/', db_get_field("SELECT id_path FROM ?:categories WHERE category_id = ?i", $_SESSION['current_category_id']));
if (!empty($parent_ids)) {
Registry::set('runtime.active_category_ids', $parent_ids);
$cats = fn_get_category_name($parent_ids);
foreach ($parent_ids as $c_id) {
fn_add_breadcrumb($cats[$c_id], "categories.view?category_id={$c_id}");
}
}
}
fn_add_breadcrumb($product['product']);
if (!empty($_REQUEST['combination'])) {
$product['combination'] = $_REQUEST['combination'];
}
//wishlist options selected
$wishlistOptionsVariantsSelected = array();
if (isset($_REQUEST['wishlist_id'])) {
示例11: fn_top_menu_form
/**
* Form top menu
*
* @param array $top_menu top menu data from the database
* @param int $level current menu level
* @param boolean $active - menu item active flag, returned by reference to set tree branch as active
* @return array formed top menu
*/
function fn_top_menu_form($top_menu, $level = 0, &$active = NULL)
{
$_active = false;
foreach ($top_menu as $k => $v) {
if (!empty($v['param_3'])) {
// get extra items
list($type, $id, $use_name) = fn_explode(':', $v['param_3']);
if ($type == 'C') {
// categories
$cats = fn_get_categories_tree($id, true);
$v['subitems'] = fn_array_merge(fn_top_menu_standardize($cats, 'category_id', 'category', 'subcategories', 'categories.view?category_id='), !empty($v['subitems']) ? $v['subitems'] : array(), false);
if ($use_name == 'Y' && !empty($id)) {
$v['descr'] = fn_get_category_name($id);
$v['param'] = 'categories.view?category_id=' . $id;
}
} elseif ($type == 'A') {
// pages
$params = array('from_page_id' => $id, 'get_tree' => 'multi_level', 'status' => 'A');
list($pages) = fn_get_pages($params);
$v['subitems'] = fn_array_merge(fn_top_menu_standardize($pages, 'page_id', 'page', 'subpages', 'pages.view?page_id='), !empty($v['subitems']) ? $v['subitems'] : array(), false);
if ($use_name == 'Y' && !empty($id)) {
$page_data = fn_get_page_data($id);
$v['descr'] = $page_data['page'];
$v['param'] = !empty($page_data['link']) ? $page_data['link'] : 'pages.view?page_id=' . $id;
}
} else {
// for addons
fn_set_hook('top_menu_form', $v, $type, $id, $use_name);
}
}
if (!empty($v['param']) && fn_top_menu_is_current_url($v['param'], $v['param_2'])) {
$top_menu[$k]['active'] = true;
// Store active value
$_active = true;
}
if (!empty($v['subitems'])) {
$top_menu[$k]['subitems'] = fn_top_menu_form($v['subitems'], $level + 1, $active);
// If active status was returned fron children
if ($active) {
$top_menu[$k]['active'] = $active;
// Strore fo return and reset activity status for athother elements on this level
// Because in one level may be only one active item
$_active = true;
$active = false;
}
}
$top_menu[$k]['item'] = $v['descr'];
$top_menu[$k]['href'] = $v['param'];
$top_menu[$k]['level'] = $level;
unset($top_menu[$k]['descr'], $top_menu[$k]['param']);
}
$active = $_active;
return $top_menu;
}
示例12: fn_update_newsletter
$newsletter_id = fn_update_newsletter($_REQUEST['newsletter_data'], $_REQUEST['newsletter_id'], DESCR_SL);
return array(CONTROLLER_STATUS_OK, 'newsletters.update?newsletter_id=' . $newsletter_id);
}
//
// Send newsletter
//
if ($mode == 'send') {
$newsletter_id = fn_update_newsletter($_REQUEST['newsletter_data'], $_REQUEST['newsletter_id'], DESCR_SL);
if (!empty($_REQUEST['newsletter_data']['mailing_lists']) || !empty($_REQUEST['newsletter_data']['users']) || !empty($_REQUEST['newsletter_data']['abandoned_days'])) {
$list_recipients = array();
if (!empty($_REQUEST['newsletter_data']['mailing_lists'])) {
$list_recipients = db_get_array("SELECT * FROM ?:subscribers AS s LEFT JOIN ?:user_mailing_lists AS u ON s.subscriber_id=u.subscriber_id LEFT JOIN ?:mailing_lists AS m ON u.list_id = m.list_id WHERE u.list_id IN(?n) AND (u.confirmed='1' OR m.register_autoresponder = 0) GROUP BY s.subscriber_id", $_REQUEST['newsletter_data']['mailing_lists']);
}
$user_recipients = array();
if (!empty($_REQUEST['newsletter_data']['users'])) {
$users = fn_explode(',', $_REQUEST['newsletter_data']['users']);
$user_recipients = db_get_array("SELECT user_id, email, lang_code FROM ?:users WHERE user_id IN (?n)", $users);
foreach ($user_recipients as $k => $v) {
// populate user array with sensible defaults
$user_recipients[$k]['from_name'] = '';
$user_recipients[$k]['reply_to'] = '';
$user_recipients[$k]['users_list'] = 'Y';
}
}
$abandoned_recipients = array();
if (!empty($_REQUEST['newsletter_data']['abandoned_days'])) {
$time = time() - intval($_REQUEST['newsletter_data']['abandoned_days']) * 24 * 60 * 60;
// X days * 24 hours * 60 mins * 60 secs;
$condition = db_quote("AND ?:user_session_products.timestamp <= ?i", $time);
if ($_REQUEST['newsletter_data']['abandoned_type'] == 'cart') {
$condition .= db_quote(' AND ?:user_session_products.type = ?s', 'C');
示例13: fn_exim_set_localizations
/**
* Assign localizations to the product
*
* @param int $product_id Product ID
* @param string $data - comma delimited list of localizations
* @return boolean always true
*/
function fn_exim_set_localizations($product_id, $data)
{
if (empty($data)) {
db_query("UPDATE ?:products SET localization = ''");
return true;
}
$multi_lang = array_keys($data);
$main_lang = reset($multi_lang);
$loc_ids = db_get_fields("SELECT localization_id FROM ?:localization_descriptions WHERE localization IN (?a) AND lang_code = ?s", fn_explode(',', $data[$main_lang]), $main_lang);
$_data = array('localization' => fn_create_set($loc_ids));
db_query('UPDATE ?:products SET ?u WHERE product_id = ?i', $_data, $product_id);
return true;
}
示例14: fn_checkout_update_shipping
function fn_checkout_update_shipping(&$cart, $shipping_ids)
{
$cart['shipping'] = array();
$parsed_data = array();
foreach ($shipping_ids as $k => $shipping_id) {
if (strpos($k, ',') !== false) {
$parsed_data = fn_array_merge($parsed_data, fn_array_combine(fn_explode(',', $k), $shipping_id));
} else {
$parsed_data[$k] = $shipping_id;
}
}
foreach ($parsed_data as $k => $shipping_id) {
if (empty($cart['shipping'][$shipping_id])) {
$cart['shipping'][$shipping_id] = array('shipping' => $_SESSION['shipping_rates'][$shipping_id]['name']);
}
if (!isset($cart['shipping'][$shipping_id]['rates'])) {
$cart['shipping'][$shipping_id]['rates'] = array();
}
if (isset($_SESSION['shipping_rates'][$shipping_id]['rates'][$k])) {
$cart['shipping'][$shipping_id]['rates'][$k] = $_SESSION['shipping_rates'][$shipping_id]['rates'][$k];
}
}
return true;
}
示例15: importProductOffersFile
public static function importProductOffersFile($data_offers, $import_params)
{
$cml = self::$cml;
$create_prices = self::$s_commerceml['exim_1c_create_prices'];
$schema_version = self::$s_commerceml['exim_1c_schema_version'];
$import_mode = self::$s_commerceml['exim_1c_import_mode_offers'];
$negative_amount = Registry::get('settings.General.allow_negative_amount');
if (isset($data_offers->{$cml}['prices_types']->{$cml}['price_type'])) {
$price_offers = self::dataPriceOffers($data_offers->{$cml}['prices_types']->{$cml}['price_type']);
if ($create_prices == 'Y') {
$data_prices = db_get_array("SELECT price_1c, type, usergroup_id FROM ?:rus_exim_1c_prices");
$prices_commerseml = self::dataPriceFile($data_offers->{$cml}['prices_types']->{$cml}['price_type'], $data_prices);
}
}
$options_data = $global_options_data = array();
foreach ($data_offers->{$cml}['offers']->{$cml}['offer'] as $offer) {
$product = array();
$amount = 0;
$combination_id = 0;
$ids = fn_explode('#', strval($offer->{$cml}['id']));
$guid_product = array_shift($ids);
if (!empty($ids)) {
$combination_id = reset($ids);
}
$product_data = db_get_row("SELECT product_id, update_1c, status FROM ?:products WHERE external_id = ?s", $guid_product);
$product_id = !empty($product_data['product_id']) ? $product_data['product_id'] : 0;
$update_product = !empty($product_data['update_1c']) ? $product_data['update_1c'] : 'N';
if (!self::checkImportPrices($product_data)) {
continue;
}
if (isset($offer->{$cml}['amount']) && !empty($offer->{$cml}['amount'])) {
$amount = strval($offer->{$cml}['amount']);
} elseif (isset($offer->{$cml}['store'])) {
foreach ($offer->{$cml}['store'] as $store) {
$amount += strval($store[$cml['in_stock']]);
}
}
$prices = array();
if (isset($offer->{$cml}['prices']) && !empty($price_offers)) {
$product_prices = self::conversionProductPrices($offer->{$cml}['prices']->{$cml}['price'], $price_offers);
if ($create_prices == 'Y') {
$prices = self::dataProductPrice($product_prices, $prices_commerseml);
} elseif (!empty($product_prices[strval($offer->{$cml}['prices']->{$cml}['price']->{$cml}['price_id'])]['price'])) {
$prices['base_price'] = $product_prices[strval($offer->{$cml}['prices']->{$cml}['price']->{$cml}['price_id'])]['price'];
} else {
$prices['base_price'] = 0;
}
}
if (empty($prices)) {
$prices['base_price'] = 0;
}
if ($amount < 0 && $negative_amount == 'N') {
$amount = 0;
}
$o_amount = $amount;
if (!empty($product_amount[$product_id])) {
$o_amount = $o_amount + $product_amount[$product_id]['amount'];
}
$product_amount[$product_id]['amount'] = $o_amount;
$product['status'] = self::updateProductStatus($product_id, $product_data['status'], $product_amount[$product_id]['amount']);
if (empty($combination_id)) {
$product['amount'] = $amount;
db_query("UPDATE ?:products SET ?u WHERE product_id = ?i", $product, $product_id);
self::addProductPrice($product_id, $prices);
self::addMessageLog('Added product = ' . strval($offer->{$cml}['name']) . ', price = ' . $prices['base_price'] . ' and amount = ' . $amount);
} else {
$product['tracking'] = 'O';
db_query("UPDATE ?:products SET ?u WHERE product_id = ?i", $product, $product_id);
if ($schema_version == '2.07') {
self::addProductPrice($product_id, array('base_price' => 0));
$option_id = self::dataProductOption($product_id, $import_params['lang_code']);
$variant_id = db_get_field("SELECT variant_id FROM ?:product_option_variants WHERE external_id = ?s AND option_id = ?i", $combination_id, $option_id);
if (!empty($option_id) && !empty($variant_id)) {
$price = $prices['base_price'];
if (self::$s_commerceml['exim_1c_option_price'] == 'Y') {
$price = '0.00';
}
db_query("UPDATE ?:product_option_variants SET modifier = ?i WHERE variant_id = ?i", $price, $variant_id);
$add_options_combination = array($option_id => $variant_id);
self::addNewCombination($product_id, $combination_id, $add_options_combination, $import_params, $amount);
self::addMessageLog('Added product = ' . strval($offer->{$cml}['name']) . ', option_id = ' . $option_id . ', variant_id = ' . $variant_id . ', price = ' . $prices['base_price'] . ' and amount = ' . $amount);
} elseif (empty($variant_id) && $import_mode == 'global_option') {
$data_combination = db_get_row("SELECT combination_hash, combination FROM ?:product_options_inventory WHERE external_id = ?s AND product_id = ?i", $combination_id, $product_id);
$add_options_combination = fn_get_product_options_by_combination($data_combination['combination']);
self::addProductOptionException($add_options_combination, $product_id, $import_params, $amount);
if (!empty($data_combination['combination_hash'])) {
$image_pair_id = db_get_field("SELECT pair_id FROM ?:images_links WHERE object_id = ?i", $data_combination['combination_hash']);
db_query("UPDATE ?:product_options_inventory SET amount = ?i WHERE combination_hash = ?i", $amount, $data_combination['combination_hash']);
if (!empty($image_pair_id)) {
db_query("UPDATE ?:images_links SET object_id = ?i WHERE pair_id = ?i", $data_combination['combination_hash'], $image_pair_id);
}
}
self::addMessageLog('Added global option product = ' . strval($offer->{$cml}['name']) . ', price = ' . $prices['base_price'] . ' and amount = ' . $amount);
} elseif (empty($variant_id) && $import_mode == 'individual_option') {
$data_combination = db_get_row("SELECT combination_hash, combination FROM ?:product_options_inventory WHERE external_id = ?s AND product_id = ?i", $combination_id, $product_id);
$add_options_combination = fn_get_product_options_by_combination($data_combination['combination']);
self::addProductOptionException($add_options_combination, $product_id, $import_params, $amount);
if (!empty($data_combination['combination_hash'])) {
$image_pair_id = db_get_field("SELECT pair_id FROM ?:images_links WHERE object_id = ?i", $data_combination['combination_hash']);
db_query("UPDATE ?:product_options_inventory SET amount = ?i WHERE combination_hash = ?i", $amount, $data_combination['combination_hash']);
//.........这里部分代码省略.........