本文整理汇总了PHP中fn_get_product_options函数的典型用法代码示例。如果您正苦于以下问题:PHP fn_get_product_options函数的具体用法?PHP fn_get_product_options怎么用?PHP fn_get_product_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fn_get_product_options函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: fn_product_price_calculator_clone_product_post
function fn_product_price_calculator_clone_product_post($product_id, $pid, $orig_name, $new_name)
{
if (fn_check_price_calc($product_id) == 'Y') {
$fields = fn_get_fields($product_id);
if (!empty($fields)) {
foreach ($fields as $v) {
$v['product_id'] = $pid;
db_query('INSERT INTO ?:ppc ?e', $v);
}
}
$formula = db_get_field('SELECT formula FROM ?:ppc_formula WHERE product_id = ?i', $product_id);
$for_des = fn_get_formula_description($product_id);
$product_options = fn_get_product_options($product_id, CART_LANGUAGE);
$new_product_options = fn_get_product_options($pid, CART_LANGUAGE);
foreach ($product_options as $k => $v) {
foreach ($new_product_options as $k1 => $v1) {
if ($v['option_name'] == $v1['option_name']) {
$formula = str_replace("[opt_{$k}]", "[opt_{$k1}]", $formula);
$formula = str_replace("[optw_{$k}]", "[optw_{$k1}]", $formula);
break;
}
}
}
db_query('INSERT INTO ?:ppc_formula VALUES (?i, ?s, ?s)', $pid, $formula, $for_des);
}
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:26,代码来源:func.php
示例2: fn_exim_set_product_option_exception
function fn_exim_set_product_option_exception($product_id, $combinations, &$counter, $set_delimiter, $lang_code)
{
static $_product_id = 0;
static $_product_option = array();
$result = array();
if ($_product_id != $product_id) {
$_options = fn_get_product_options($product_id, $lang_code);
foreach ($_options as $option) {
$_product_option[$option['option_name']] = $option;
unset($_product_option[$option['option_name']]['variants']);
foreach ($option['variants'] as $variant) {
$_product_option[$option['option_name']]['variants'][$variant['variant_name']] = $variant;
}
}
}
foreach ($combinations as $lang_code => $combination) {
$combination = explode($set_delimiter, $combination);
foreach ($combination as $option_variant) {
list($option, $variant) = explode('=', $option_variant);
$option = trim($option);
$variant = trim($variant);
$option_id = isset($_product_option[$option]) ? $_product_option[$option]['option_id'] : 0;
if (strpos($variant, '#') !== false) {
$variant_id = strtolower($variant) == '#no' ? '-2' : '-1';
} else {
$variant_id = isset($_product_option[$option]['variants'][$variant]) ? $_product_option[$option]['variants'][$variant]['variant_id'] : 0;
}
if (empty($option_id) || empty($variant_id)) {
$counter['S']++;
return false;
}
$result[$option_id] = $variant_id;
}
}
$combination = array('product_id' => $product_id, 'combination' => serialize($result));
if (db_get_field('SELECT COUNT(*) FROM ?:product_options_exceptions WHERE combination = ?s', serialize($result)) > 0) {
$counter['S']++;
} else {
db_query('INSERT INTO ?:product_options_exceptions ?e', $combination);
$counter['N']++;
}
return $combination;
}
开发者ID:askzap,项目名称:ultimate,代码行数:43,代码来源:option_exceptions.functions.php
示例3: fn_get_product_options_inventory
function fn_get_product_options_inventory($params, $items_per_page = 0, $lang_code = DESCR_SL)
{
$default_params = array('page' => 1, 'product_id' => 0, 'items_per_page' => $items_per_page);
$params = array_merge($default_params, $params);
$limit = '';
if (!empty($params['items_per_page'])) {
$params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:product_options_inventory WHERE product_id = ?i", $params['product_id']);
$limit = db_paginate($params['page'], $params['items_per_page']);
}
$inventory = db_get_array("SELECT * FROM ?:product_options_inventory WHERE product_id = ?i ORDER BY position {$limit}", $params['product_id']);
foreach ($inventory as $k => $v) {
$inventory[$k]['combination'] = fn_get_product_options_by_combination($v['combination']);
$inventory[$k]['image_pairs'] = fn_get_image_pairs($v['combination_hash'], 'product_option', 'M', true, true, $lang_code);
$inventory[$k]['additional_image_pairs'] = fn_get_image_pairs($v['combination_hash'], 'product_option', 'A', true, true, $lang_code);
}
$product_options = fn_get_product_options($params['product_id'], $lang_code, true, true);
$product_inventory = db_get_field("SELECT tracking FROM ?:products WHERE product_id = ?i", $params['product_id']);
return array($inventory, $params, $product_options, $product_inventory);
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:19,代码来源:product_options.php
示例4: fn_look_through_variants_prices
function fn_look_through_variants_prices($product_id, $options, $variants)
{
$product = fn_get_product_data($product_id, $_SESSION['auth'], CART_LANGUAGE, '', true, true, true, true, $auth['area'] == 'A' && !empty($_REQUEST['action']) && $_REQUEST['action'] == 'preview');
$product['product_options'] = fn_get_product_options(array($product_id), CART_LANGUAGE);
$product = fn_apply_options_rules($product);
//var_dump($product['product_options']);
$position = 0;
$hashes = array();
$combinations = fn_get_options_combinations($options, $variants);
//var_dump($combinations);
foreach ($combinations as $key => $combination) {
$flagToUnsetArrayElement = 0;
$productArrayOtionsVariants = fn_get_options_variants_by_option_variant_id($product_id, $combination);
foreach ($combination as $optionId => $variantId) {
if ($productArrayOtionsVariants[$optionId] && !in_array($variantId, $productArrayOtionsVariants[$optionId])) {
$flagToUnsetArrayElement = 1;
}
}
if ($flagToUnsetArrayElement == 1) {
unset($combinations[$key]);
}
}
//var_dump($combinations);
if (!empty($combinations)) {
foreach ($combinations as $combination) {
$_data = array();
$_data['product_id'] = $product_id;
$_data['combination_hash'] = fn_generate_cart_id($product_id, array('product_options' => $combination));
if (array_search($_data['combination_hash'], $hashes) === false) {
$hashes[] = $_data['combination_hash'];
$_data['combination'] = fn_get_options_combination($combination);
$product['product_options'] = fn_get_selected_product_options($product['product_id'], $combination, CART_LANGUAGE);
$product = fn_apply_options_rules($product);
$_data['price'] = fn_calculate_price_of_a_product($product, $combination);
$old_data = db_get_row("SELECT combination_hash, price " . "FROM ?:product_options_inventory_prices " . "WHERE product_id = ?i AND combination_hash = ?i AND temp = 1", $product_id, $_data['combination_hash']);
/**
* Changes data before update combination
*
* @param array $combination Array of combination data
* @param array $data Combination data to update
* @param int $product_id Product identifier
* @param int $amount Default combination amount
* @param array $options Array of options identifiers
* @param array $variants Array of option variants identifiers arrays in order corresponding to $options parameter
*/
db_query("REPLACE INTO ?:product_options_inventory_prices ?e", $_data);
$combinations[] = $combination;
}
echo str_repeat('. ', count($combination));
}
}
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:52,代码来源:fn.catalog.php
示例5: fn_add_product_options_files
function fn_add_product_options_files($product_data, &$cart, &$auth, $update = false, $location = 'cart')
{
// Check if products have cusom images
if (!$update) {
$uploaded_data = fn_filter_uploaded_data('product_data');
} else {
$uploaded_data = fn_filter_uploaded_data('cart_products');
}
// Check for the already uploaded files
if (!empty($product_data['custom_files']['uploaded'])) {
foreach ($product_data['custom_files']['uploaded'] as $file_id => $file_data) {
if (Storage::instance('images')->isExist('sess_data/' . fn_basename($file_data['path']))) {
$id = $file_data['product_id'] . $file_data['option_id'] . $file_id;
$uploaded_data[$id] = array('name' => $file_data['name'], 'path' => 'sess_data/' . fn_basename($file_data['path']));
$product_data['custom_files'][$id] = $file_data['product_id'] . '_' . $file_data['option_id'];
}
}
}
if (!empty($uploaded_data) && !empty($product_data['custom_files'])) {
$files_data = array();
foreach ($uploaded_data as $key => $file) {
$file_info = fn_pathinfo($file['name']);
$file['extension'] = empty($file_info['extension']) ? '' : $file_info['extension'];
$file['is_image'] = fn_get_image_extension($file['type']);
$_data = explode('_', $product_data['custom_files'][$key]);
$product_id = empty($_data[0]) ? 0 : $_data[0];
$option_id = empty($_data[1]) ? 0 : $_data[1];
$file_id = str_replace($option_id . $product_id, '', $key);
if (empty($file_id)) {
$files_data[$product_id][$option_id][] = $file;
} else {
$files_data[$product_id][$option_id][$file_id] = $file;
}
}
}
unset($product_data['custom_files']);
foreach ($product_data as $key => $data) {
$product_id = !empty($data['product_id']) ? $data['product_id'] : $key;
// Check if product has cusom images
if ($update || isset($files_data[$key])) {
$hash = $key;
} else {
$hash = $product_id;
}
$_options = fn_get_product_options($product_id);
if (!empty($files_data[$hash]) && is_array($files_data[$hash])) {
foreach ($files_data[$hash] as $option_id => $files) {
foreach ($files as $file_id => $file) {
// Check for the allowed extensions
if (!empty($_options[$option_id]['allowed_extensions'])) {
if (empty($file['extension']) && !empty($_options[$option_id]['allowed_extensions']) || !preg_match("/\\b" . $file['extension'] . "\\b/i", $_options[$option_id]['allowed_extensions'])) {
fn_set_notification('E', __('error'), $file['name'] . ': ' . __('text_forbidden_uploaded_file_extension', array('[ext]' => $file['extension'], '[exts]' => $_options[$option_id]['allowed_extensions'])));
unset($files_data[$hash][$option_id][$file_id]);
continue;
}
}
// Check for the max file size
if (!empty($_options[$option_id]['max_file_size'])) {
if (empty($file['size'])) {
$file['size'] = filesize($file['path']);
}
if ($file['size'] > $_options[$option_id]['max_file_size'] * 1024) {
fn_set_notification('E', __('error'), $file['name'] . ': ' . __('text_forbidden_uploaded_file_size', array('[size]' => $_options[$option_id]['max_file_size'] . ' kb')));
unset($files_data[$hash][$option_id][$file_id]);
continue;
}
}
$_file_path = 'sess_data/file_' . uniqid(TIME);
list(, $_file_path) = Storage::instance('custom_files')->put($_file_path, array('file' => $file['path']));
if (!$_file_path) {
fn_set_notification('E', __('error'), __('text_cannot_create_file', array('[file]' => $file['name'])));
unset($files_data[$hash][$option_id][$file_id]);
continue;
}
$file['path'] = $_file_path;
$file['file'] = fn_basename($file['path']);
if ($file['is_image']) {
$file['thumbnail'] = 'image.custom_image?image=' . $file['file'] . '&type=T';
$file['detailed'] = 'image.custom_image?image=' . $file['file'] . '&type=D';
}
$file['location'] = $location;
if ($update) {
$cart['products'][$key]['extra']['custom_files'][$option_id][] = $file;
} else {
$data['extra']['custom_files'][$option_id][] = $file;
}
}
if ($update) {
if (!empty($cart['products'][$key]['product_options'][$option_id])) {
$cart['products'][$key]['product_options'][$option_id] = md5(serialize($cart['products'][$key]['extra']['custom_files'][$option_id]));
}
} else {
if (!empty($data['extra']['custom_files'][$option_id])) {
$data['product_options'][$option_id] = md5(serialize($data['extra']['custom_files'][$option_id]));
}
}
}
// Check the required options
if (empty($data['extra']['parent'])) {
foreach ($_options as $option) {
//.........这里部分代码省略.........
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:101,代码来源:fn.cart.php
示例6: fn_exim_get_product_options
function fn_exim_get_product_options($product_id, $lang_code = '')
{
$pair_delimiter = ':';
$set_delimiter = '; ';
$vars_delimiter = ',';
$result = array();
$options = fn_get_product_options($product_id, $lang_code);
if (!empty($options)) {
foreach ($options as $o) {
$glob_opt = db_get_field("SELECT option_id FROM ?:product_global_option_links WHERE option_id = ?i AND product_id = ?i", $o['option_id'], $product_id);
$prefix = '';
if (!empty($o['company_id'])) {
$company_name = fn_get_company_name($o['company_id']);
$prefix = '(' . $company_name . ') ';
}
$str = $prefix . "{$o['option_name']}{$pair_delimiter} {$o['option_type']}" . (empty($glob_opt) ? '' : 'G');
$variants = array();
if (!empty($o['variants'])) {
foreach ($o['variants'] as $v) {
$variants[] = $v['variant_name'];
}
$str .= '[' . implode($vars_delimiter, $variants) . ']';
}
$result[] = $str;
}
}
return !empty($result) ? implode($set_delimiter, $result) : '';
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:28,代码来源:products.functions.php
示例7: index
public function index($id = 0, $params = array())
{
$lang_code = $this->safeGet($params, 'lang_code', DEFAULT_LANGUAGE);
if (empty($id) && empty($params['product_id'])) {
$status = Response::STATUS_BAD_REQUEST;
$data['message'] = __('api_required_field', array('[field]' => 'product_id'));
} else {
$product_id = $this->safeGet($params, 'product_id', 0);
if (empty($product_id)) {
$product_id = db_get_field('SELECT product_id FROM ?:product_options WHERE option_id = ?i', $id);
}
$product_data = fn_get_product_data($product_id, $this->auth, $lang_code, '', false, false, false, false, false, false, false);
if (empty($product_data)) {
$status = Response::STATUS_NOT_FOUND;
$data = array();
} else {
if (!empty($id)) {
$data = fn_get_product_option_data($id, $product_id, $lang_code);
$status = Response::STATUS_OK;
} else {
$data = fn_get_product_options($product_id, $lang_code);
$status = Response::STATUS_OK;
}
if (empty($data)) {
$status = Response::STATUS_NOT_FOUND;
}
}
}
return array('status' => $status, 'data' => $data);
}
开发者ID:askzap,项目名称:ultimate,代码行数:30,代码来源:Options.php
示例8: elseif
} elseif ($mode == 'delete') {
if (!empty($_REQUEST['option_id'])) {
$p_id = db_get_field("SELECT product_id FROM ?:product_options WHERE option_id = ?i", $_REQUEST['option_id']);
if (!empty($_REQUEST['product_id']) && empty($p_id)) {
// we're deleting global option from the product
db_query("DELETE FROM ?:product_global_option_links WHERE product_id = ?i AND option_id = ?i", $_REQUEST['product_id'], $_REQUEST['option_id']);
} else {
fn_delete_product_option($_REQUEST['option_id']);
}
if (empty($_REQUEST['product_id']) && empty($p_id)) {
// we're deleting global option itself
db_query("DELETE FROM ?:product_global_option_links WHERE option_id = ?i", $_REQUEST['option_id']);
}
}
if (!empty($_REQUEST['product_id'])) {
$_options = fn_get_product_options($_REQUEST['product_id']);
if (empty($_options)) {
$view->display('views/product_options/manage.tpl');
}
exit;
}
return array(CONTROLLER_STATUS_REDIRECT, "product_options.manage");
} elseif ($mode == 'rebuild_combinations') {
fn_rebuild_product_options_inventory($_REQUEST['product_id']);
return array(CONTROLLER_STATUS_OK, "product_options.inventory?product_id={$_REQUEST['product_id']}");
} elseif ($mode == 'delete_combination') {
if (!empty($_REQUEST['combination_hashe'])) {
fn_delete_image_pairs($_REQUEST['combination_hashe'], 'product_option');
db_query("DELETE FROM ?:product_options_inventory WHERE combination_hash = ?i", $_REQUEST['combination_hashe']);
}
return array(CONTROLLER_STATUS_REDIRECT, "product_options.inventory?product_id={$_REQUEST['product_id']}");
开发者ID:diedsmiling,项目名称:busenika,代码行数:31,代码来源:product_options.php
示例9: elseif
// Update option
//
} elseif ($mode == 'update') {
$product_id = !empty($_REQUEST['product_id']) ? $_REQUEST['product_id'] : 0;
$o_data = fn_get_product_option_data($_REQUEST['option_id'], $product_id);
if (fn_allowed_for('ULTIMATE') && !empty($_REQUEST['product_id'])) {
Registry::get('view')->assign('shared_product', fn_ult_is_shared_product($_REQUEST['product_id']));
Registry::get('view')->assign('product_company_id', db_get_field('SELECT company_id FROM ?:products WHERE product_id = ?i', $_REQUEST['product_id']));
}
if (isset($_REQUEST['object'])) {
Registry::get('view')->assign('object', $_REQUEST['object']);
}
Registry::get('view')->assign('option_data', $o_data);
Registry::get('view')->assign('option_id', $_REQUEST['option_id']);
}
if (!fn_allowed_for('ULTIMATE:FREE')) {
//
// Product options exceptions
//
if ($mode == 'exceptions') {
$exceptions = fn_get_product_exceptions($_REQUEST['product_id']);
$product_options = fn_get_product_options($_REQUEST['product_id'], DESCR_SL, true);
$product_data = fn_get_product_data($_REQUEST['product_id'], $auth, DESCR_SL, '', true, true, true, true);
Registry::get('view')->assign('product_options', $product_options);
Registry::get('view')->assign('exceptions', $exceptions);
Registry::get('view')->assign('product_data', $product_data);
}
}
if (!empty($_REQUEST['product_id'])) {
Registry::get('view')->assign('product_id', $_REQUEST['product_id']);
}
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:31,代码来源:product_options.php
示例10: fn_add_product_options_files
function fn_add_product_options_files($product_data, &$cart, &$auth, $update = false, $location = 'cart')
{
// Check if products have cusom images
if (!$update) {
$uploaded_data = fn_filter_uploaded_data('product_data');
} else {
$uploaded_data = fn_filter_uploaded_data('cart_products');
}
$dir_path = DIR_CUSTOM_FILES . 'sess_data';
// Check for the already uploaded files
if (!empty($product_data['custom_files']['uploaded'])) {
foreach ($product_data['custom_files']['uploaded'] as $file_id => $file_data) {
if (file_exists($dir_path . '/' . basename($file_data['path']))) {
$id = $file_data['product_id'] . $file_data['option_id'] . $file_id;
$uploaded_data[$id] = array('name' => $file_data['name'], 'path' => $dir_path . '/' . basename($file_data['path']));
$product_data['custom_files'][$id] = $file_data['product_id'] . '_' . $file_data['option_id'];
}
}
}
if (!empty($uploaded_data) && !empty($product_data['custom_files'])) {
$files_data = array();
foreach ($uploaded_data as $key => $file) {
$file_info = pathinfo($file['name']);
$file['extension'] = empty($file_info['extension']) ? '' : $file_info['extension'];
$file_info = getimagesize($file['path']);
$file['type'] = $file_info['mime'];
$file['is_image'] = fn_get_image_extension($file_info['mime']);
$_data = explode('_', $product_data['custom_files'][$key]);
$product_id = empty($_data[0]) ? 0 : $_data[0];
$option_id = empty($_data[1]) ? 0 : $_data[1];
$file_id = str_replace($option_id . $product_id, '', $key);
if (empty($file_id)) {
$files_data[$product_id][$option_id][] = $file;
} else {
$files_data[$product_id][$option_id][$file_id] = $file;
}
}
if (!is_dir($dir_path)) {
if (!fn_mkdir($dir_path)) {
// Unable to create a directory
fn_set_notification('E', fn_get_lang_var('error'), str_replace('[directory]', DIR_CUSTOM_FILES, fn_get_lang_var('text_cannot_write_directory')));
}
}
}
unset($product_data['custom_files']);
foreach ($product_data as $key => $data) {
$product_id = !empty($data['product_id']) ? $data['product_id'] : $key;
// Check if product has cusom images
if ($update || isset($files_data[$key])) {
$hash = $key;
} else {
$hash = $product_id;
}
if (!empty($files_data[$hash]) && is_array($files_data[$hash])) {
$_options = fn_get_product_options($product_id);
foreach ($files_data[$hash] as $option_id => $files) {
foreach ($files as $file_id => $file) {
// Check for the allowed extensions
if (!empty($_options[$option_id]['allowed_extensions'])) {
if (empty($file['extension']) && !empty($_options[$option_id]['allowed_extensions']) || !preg_match("/\\b" . $file['extension'] . "\\b/i", $_options[$option_id]['allowed_extensions'])) {
$message = fn_get_lang_var('text_forbidden_uploaded_file_extension');
$message = str_replace('[ext]', $file['extension'], $message);
$message = str_replace('[exts]', $_options[$option_id]['allowed_extensions'], $message);
fn_set_notification('E', fn_get_lang_var('error'), $file['name'] . ': ' . $message);
unset($files_data[$hash][$option_id][$file_id]);
continue;
}
}
// Check for the max file size
if (!empty($_options[$option_id]['max_file_size'])) {
if (empty($file['size'])) {
$file['size'] = filesize($file['path']);
}
if ($file['size'] > $_options[$option_id]['max_file_size'] * 1024) {
fn_set_notification('E', fn_get_lang_var('error'), str_replace('[size]', $_options[$option_id]['max_file_size'] . ' kb', $file['name'] . ': ' . fn_get_lang_var('text_forbidden_uploaded_file_size')));
unset($files_data[$hash][$option_id][$file_id]);
continue;
}
}
$_file_path = tempnam($dir_path, 'file_');
if (!fn_copy($file['path'], $_file_path)) {
fn_set_notification('E', fn_get_lang_var('error'), str_replace('[file]', $file['name'], fn_get_lang_var('text_cannot_create_file')));
unset($files_data[$hash][$option_id][$file_id]);
continue;
}
$file['path'] = $_file_path;
$file['file'] = basename($file['path']);
if ($file['is_image']) {
$file['thumbnail'] = 'image.custom_image&image=' . $file['file'] . '&type=T';
$file['detailed'] = 'image.custom_image&image=' . $file['file'] . '&type=D';
}
$file['location'] = $location;
if ($update) {
$cart['products'][$key]['extra']['custom_files'][$option_id][] = $file;
} else {
$data['extra']['custom_files'][$option_id][] = $file;
}
}
if ($update) {
if (!empty($cart['products'][$key]['product_options'][$option_id])) {
//.........这里部分代码省略.........
开发者ID:diedsmiling,项目名称:busenika,代码行数:101,代码来源:fn.cart.php
示例11: fn_get_default_product_options
/**
* Gets default product options
*
* @param integer $product_id Product identifier
* @param bool $get_all Whether to get all the default options or not
* @param array $product Product data
* @return array The resulting array
*/
function fn_get_default_product_options($product_id, $get_all = false, $product = array())
{
$result = $default = $exceptions = $product_options = array();
$selectable_option_types = array('S', 'R', 'C');
/**
* Get default product options ( at the beginning of fn_get_default_product_options() )
*
* @param integer $product_id Product id
* @param bool $get_all Whether to get all the default options or not
* @param array $product Product data
* @param array $selectable_option_types Selectable option types
*/
fn_set_hook('get_default_product_options_pre', $product_id, $get_all, $product, $selectable_option_types);
if (!fn_allowed_for('ULTIMATE:FREE')) {
$exceptions = fn_get_product_exceptions($product_id, true);
$exceptions_type = empty($product['exceptions_type']) ? db_get_field('SELECT exceptions_type FROM ?:products WHERE product_id = ?i', $product_id) : $product['exceptions_type'];
}
$track_with_options = empty($product['tracking']) ? db_get_field("SELECT tracking FROM ?:products WHERE product_id = ?i", $product_id) : $product['tracking'];
if (!empty($product['product_options'])) {
//filter out only selectable options
foreach ($product['product_options'] as $option_id => $option) {
if (in_array($option['option_type'], $selectable_option_types)) {
$product_options[$option_id] = $option;
}
}
} else {
$product_options = fn_get_product_options($product_id, CART_LANGUAGE, true);
}
if (!empty($product_options)) {
foreach ($product_options as $option_id => $option) {
if (!empty($option['variants'])) {
$default[$option_id] = key($option['variants']);
foreach ($option['variants'] as $variant_id => $variant) {
$options[$option_id][$variant_id] = true;
}
}
}
} else {
return array();
}
unset($product_options);
if (!fn_allowed_for('ULTIMATE:FREE')) {
if (empty($exceptions)) {
return $default;
}
}
$inventory_combinations = array();
if ($track_with_options == 'O') {
$inventory_combinations = db_get_array("SELECT combination FROM ?:product_options_inventory WHERE product_id = ?i AND amount > 0 AND combination != ''", $product_id);
if (!empty($inventory_combinations)) {
$_combinations = array();
foreach ($inventory_combinations as $_combination) {
$_combinations[] = fn_get_product_options_by_combination($_combination['combination']);
}
$inventory_combinations = $_combinations;
unset($_combinations);
}
}
if (!fn_allowed_for('ULTIMATE:FREE')) {
if ($exceptions_type == 'F') {
// Forbidden combinations
$_options = array_keys($options);
$_variants = array_values($options);
if (!empty($_variants)) {
foreach ($_variants as $key => $variants) {
$_variants[$key] = array_keys($variants);
}
}
list($result) = fn_get_allowed_options_combination($_options, $_variants, '', 0, $exceptions, $inventory_combinations);
} else {
// Allowed combinations
foreach ($exceptions as $exception) {
$result = array();
foreach ($exception as $option_id => $variant_id) {
if (isset($options[$option_id][$variant_id]) || $variant_id == -1) {
$result[$option_id] = $variant_id != -1 ? $variant_id : (isset($options[$option_id]) ? key($options[$option_id]) : '');
} else {
continue 2;
}
}
$_opt = array_diff_key($options, $result);
if (!empty($_opt)) {
foreach ($_opt as $option_id => $variants) {
$result[$option_id] = key($variants);
}
}
if (empty($inventory_combinations)) {
break;
} else {
foreach ($inventory_combinations as $_icombination) {
$_res = array_diff($_icombination, $result);
if (empty($_res)) {
//.........这里部分代码省略.........
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:101,代码来源:fn.catalog.php
示例12: fn_check_and_update_product_sharing
/**
* Function checks and changes shared product data
*
* @param int $product_id Product ID
*/
function fn_check_and_update_product_sharing($product_id)
{
$shared = false;
$new_categories_company_ids = db_get_fields("SELECT DISTINCT c.company_id" . " FROM ?:products_categories pc" . " LEFT JOIN ?:categories c ON c.category_id = pc.category_id" . " WHERE pc.product_id = ?i", $product_id);
$shared_categories_company_ids = db_get_fields("SELECT DISTINCT company_id FROM ?:ult_product_descriptions WHERE product_id = ?i", $product_id);
$count = count($new_categories_company_ids);
$company_id = reset($new_categories_company_ids);
$product_company_id = db_get_field('SELECT company_id FROM ?:products WHERE product_id = ?i', $product_id);
if ($count == 1 && $company_id == $product_company_id) {
// product belongs to one store. It is not shared now
// check that products.company_id == category.company_id
/* Do not touch product.company_id.
if ($company_id != $product_company_id) {
db_query('UPDATE ?:products SET company_id = ?i WHERE product_id = ?i', $company_id, $product_id);
}*/
db_query('DELETE FROM ?:ult_product_descriptions WHERE product_id = ?i', $product_id);
db_query('DELETE FROM ?:ult_product_prices WHERE product_id = ?i', $product_id);
$product_options = fn_get_product_options($product_id, DESCR_SL, false, false, false, true);
$product_options = array_keys($product_options);
if (!empty($product_options)) {
db_query('DELETE FROM ?:ult_product_option_variants WHERE option_id IN (?a)', $product_options);
}
} else {
$shared = true;
$new_company_ids = array_diff($new_categories_company_ids, $shared_categories_company_ids);
if (!empty($new_company_ids)) {
$product_options = fn_get_product_options($product_id, DESCR_SL, false, false, false, true);
$product_options = array_keys($product_options);
}
foreach ($new_company_ids as $new_cid) {
// coping owner data to tables with shared data
db_query('REPLACE INTO ?:ult_product_descriptions (' . ' product_id, lang_code, company_id, product, shortname, short_description,' . ' full_description, meta_keywords, meta_description, search_words, page_title,' . ' age_warning_message, promo_text)' . ' SELECT' . ' product_id, lang_code, ?i, product, shortname, short_description,' . ' full_description, meta_keywords, meta_description, search_words,' . ' page_title, age_warning_message, promo_text' . ' FROM ?:product_descriptions' . ' WHERE product_id = ?i', $new_cid, $product_id);
db_query('REPLACE INTO ?:ult_product_prices (' . ' product_id, price, percentage_discount, lower_limit, company_id, usergroup_id)' . ' SELECT product_id, price, percentage_discount, lower_limit, ?i, usergroup_id' . ' FROM ?:product_prices' . ' WHERE product_id = ?i', $new_cid, $product_id);
if (!empty($product_options)) {
db_query('REPLACE INTO ?:ult_product_option_variants (' . ' variant_id, option_id, company_id, modifier, modifier_type)' . ' SELECT variant_id, option_id, ?i, modifier, modifier_type' . ' FROM ?:product_option_variants' . ' WHERE option_id IN (?a)', $new_cid, $product_options);
}
}
$deleted_company_ids = array_diff($shared_categories_company_ids, $new_categories_company_ids);
if (!empty($deleted_company_ids)) {
// deleting data from shared tables
db_query('DELETE FROM ?:ult_product_descriptions' . ' WHERE product_id = ?i AND company_id IN (?a)', $product_id, $deleted_company_ids);
db_query('DELETE FROM ?:ult_product_prices' . ' WHERE product_id = ?i AND company_id IN (?a)', $product_id, $deleted_company_ids);
if (!isset($product_options)) {
$product_options = fn_get_product_options($product_id, DESCR_SL, false, false, false, true);
$product_options = array_keys($product_options);
}
if (!empty($product_options)) {
db_query('DELETE FROM ?:ult_product_option_variants' . ' WHERE option_id IN (?a) AND company_id IN (?a)', $product_options, $deleted_company_ids);
}
}
$global_option_links = db_get_fields("SELECT option_id FROM ?:product_global_option_links WHERE product_id = ?i", $product_id);
$product_options = array_merge(isset($product_options) ? $product_options : array(), $global_option_links);
if (!empty($product_options)) {
foreach ($product_options as $po_id) {
fn_ult_share_product_option($po_id, $product_id);
}
}
}
$cids = db_get_fields('SELECT category_id FROM ?:products_categories WHERE product_id = ?i', $product_id);
fn_update_product_count($cids);
/**
* Processed addition/deletion of companies product is shared between
*
* @param int $product_id
* @param boolean $shared
* @param array $shared_categories_company_ids
* @param array $new_categories_company_ids
*/
fn_set_hook('check_and_update_product_sharing', $product_id, $shared, $shared_categories_company_ids, $new_categories_company_ids);
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:75,代码来源:fn.ultimate.php
示例13: fn_get_short_companies
$view->assign('product_data', $product_data);
$view->assign('taxes', $taxes);
$view->assign('companies', fn_get_short_companies());
$product_options = fn_get_product_options($_REQUEST['product_id'], DESCR_SL);
if (!empty($product_options)) {
$has_inventory = false;
foreach ($product_options as $p) {
if ($p['inventory'] == 'Y') {
$has_inventory = true;
break;
}
}
$view->assign('has_inventory', $has_inventory);
}
$view->assign('product_options', $product_options);
$view->assign('global_options', fn_get_product_options(0));
// If the product is electronnicaly distributed, get the assigned files
$view->assign('product_files', fn_get_product_files($_REQUEST['product_id']));
// [Page sections]
Registry::set('navigation.tabs', array('detailed' => array('title' => fn_get_lang_var('general'), 'js' => true), 'images' => array('title' => fn_get_lang_var('images'), 'js' => true), 'categories' => array('title' => fn_get_lang_var('additional_categories'), 'js' => true), 'options' => array('title' => fn_get_lang_var('options'), 'js' => true), 'qty_discounts' => array('title' => fn_get_lang_var('qty_discounts'), 'js' => true), 'files' => array('title' => fn_get_lang_var('files'), 'js' => true), 'blocks' => array('title' => fn_get_lang_var('blocks'), 'js' => true), 'addons' => array('title' => fn_get_lang_var('addons'), 'js' => true), 'vendors' => array('title' => fn_get_lang_var('vendors'), 'js' => true)));
// [/Page sections]
// If we have some additional product fields, lets add a tab for them
if (!empty($product_data['product_features'])) {
Registry::set('navigation.tabs.features', array('title' => fn_get_lang_var('features'), 'js' => true));
}
// [Block manager]
$block_settings = fn_get_all_blocks('products');
$view->assign('block_settings', $block_settings);
list($blocks, $object_id) = fn_get_blocks(array('location' => 'products', 'all' => true, 'product_id' => $_REQUEST['product_id']), false, DESCR_SL);
list($all_blocks) = fn_get_blocks(array('location' => 'all_pages', 'all' => true, 'block_properties_location' => 'products'), false);
$blocks = fn_array_merge($blocks, $all_blocks, true);
开发者ID:diedsmiling,项目名称:busenika,代码行数:31,代码来源:products.php
示例14: content_55dc81a5ed2a88_04135619
//.........这里部分代码省略.........
?>
">
<?php
$_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "product_picker:table_rows"));
$_block_repeat = true;
echo smarty_block_hook(array('name' => "product_picker:table_rows"), null, $_smarty_tpl, $_block_repeat);
while ($_block_repeat) {
ob_start();
?>
<?php
if ($_smarty_tpl->tpl_vars['item_ids']->value) {
?>
<?php
$_smarty_tpl->tpl_vars["product"] = new Smarty_Variable();
$_smarty_tpl->tpl_vars["product"]->_loop = false;
$_smarty_tpl->tpl_vars["product_id"] = new Smarty_Variable();
$_from = $_smarty_tpl->tpl_vars['item_ids']->value;
if (!is_array($_from) && !is_object($_from)) {
settype($_from, 'array');
}
foreach ($_from as $_smarty_tpl->tpl_vars["product"]->key => $_smarty_tpl->tpl_vars["product"]->value) {
$_smarty_tpl->tpl_vars["product"]->_loop = true;
$_smarty_tpl->tpl_vars["product_id"]->value = $_smarty_tpl->tpl_vars["product"]->key;
?>
<?php
if ($_smarty_tpl->tpl_vars['display']->value) {
?>
<?php
$_smarty_tpl->_capture_stack[0][] = array("product_options", null, null);
ob_start();
?>
<?php
$_smarty_tpl->tpl_vars["prod_opts"] = new Smarty_variable(fn_get_product_options($_smarty_tpl->tpl_vars['product']->value['product_id']), null, 0);
?>
<?php
if ($_smarty_tpl->tpl_vars['prod_opts']->value && !$_smarty_tpl->tpl_vars['product']->value['product_options']) {
?>
<span><?php
echo $_smarty_tpl->__("options");
?>
: </span> <?php
echo $_smarty_tpl->__("any_option_combinations");
?>
<?php
} elseif ($_smarty_tpl->tpl_vars['product']->value['product_options']) {
?>
<?php
if ($_smarty_tpl->tpl_vars['product']->value['product_options_value']) {
?>
<?php
echo $_smarty_tpl->getSubTemplate("common/options_info.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('product_options' => $_smarty_tpl->tpl_vars['product']->value['product_options_value']), 0);
?>
<?php
} else {
?>
<?php
echo $_smarty_tpl->getSubTemplate("common/options_info.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('product_options' => fn_get_selected_product_options_info($_smarty_tpl->tpl_vars['product']->value['product_options'])), 0);
?>
<?php
}
?>
<?php
开发者ID:AlanIsrael0,项目名称:market,代码行数:67,代码来源:0f764cd54e3b4c6cb9eb7122203a1dc82afeeb4a.tygh.picker.tpl.php
示例15: fn_is_allowed_options
/**
* Checks if all selected product options are available now
*
* @param array $product Product data
* @return bool true if all options are available, false otherwise
*/
function fn_is_allowed_options($product)
{
if (empty($product['product_options'])) {
return true;
}
$options = fn_get_product_options($product['product_id']);
foreach ($product['product_options'] as $option_id => $variant_id) {
if (empty($variant_id)) {
// Forbidden combination in action
continue;
}
if (!isset($options[$option_id]) || !empty($options[$option_id]['variants']) && !isset($options[$option_id]['variants'][$variant_id])) {
return false;
}
}
return true;
}
开发 |
请发表评论