📄 functions_lookups.php
字号:
where categories_id = '" . $category_id . "'
and language_id = '" . $fn_language_id . "'";
$category = $db->Execute($category_query);
return $category->fields['categories_description'];
}
/*
* Return a product's category
* TABLES: products_to_categories
*/
function zen_get_products_category_id($products_id) {
global $db;
$the_products_category_query = "select products_id, categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "'" . " order by products_id,categories_id";
$the_products_category = $db->Execute($the_products_category_query);
return $the_products_category->fields['categories_id'];
}
/*
* Return category's image
* TABLES: categories
*/
function zen_get_categories_image($what_am_i) {
global $db;
$the_categories_image_query= "select categories_image from " . TABLE_CATEGORIES . " where categories_id= '" . $what_am_i . "'";
$the_products_category = $db->Execute($the_categories_image_query);
return $the_products_category->fields['categories_image'];
}
/*
* Return category's name from ID, assuming current language
* TABLES: categories_description
*/
function zen_get_categories_name($who_am_i) {
global $db;
$the_categories_name_query= "select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id= '" . $who_am_i . "' and language_id= '" . $_SESSION['languages_id'] . "'";
$the_categories_name = $db->Execute($the_categories_name_query);
return $the_categories_name->fields['categories_name'];
}
/*
* Return a product's manufacturer's name, from ID
* TABLES: products, manufacturers
*/
function zen_get_products_manufacturers_name($product_id) {
global $db;
$product_query = "select m.manufacturers_name
from " . TABLE_PRODUCTS . " p, " .
TABLE_MANUFACTURERS . " m
where p.products_id = '" . (int)$product_id . "'
and p.manufacturers_id = m.manufacturers_id";
$product =$db->Execute($product_query);
return ($product->RecordCount() > 0) ? $product->fields['manufacturers_name'] : "";
}
/*
* Return a product's manufacturer's image, from Prod ID
* TABLES: products, manufacturers
*/
function zen_get_products_manufacturers_image($product_id) {
global $db;
$product_query = "select m.manufacturers_image
from " . TABLE_PRODUCTS . " p, " .
TABLE_MANUFACTURERS . " m
where p.products_id = '" . (int)$product_id . "'
and p.manufacturers_id = m.manufacturers_id";
$product =$db->Execute($product_query);
return $product->fields['manufacturers_image'];
}
/*
* Return attributes products_options_sort_order
* TABLE: PRODUCTS_ATTRIBUTES
*/
function zen_get_attributes_sort_order($products_id, $options_id, $options_values_id) {
global $db;
$check = $db->Execute("select products_options_sort_order
from " . TABLE_PRODUCTS_ATTRIBUTES . "
where products_id = '" . $products_id . "'
and options_id = '" . $options_id . "'
and options_values_id = '" . $options_values_id . "' limit 1");
return $check->fields['products_options_sort_order'];
}
/*
* return attributes products_options_sort_order
* TABLES: PRODUCTS_OPTIONS, PRODUCTS_ATTRIBUTES
*/
function zen_get_attributes_options_sort_order($products_id, $options_id, $options_values_id) {
global $db;
$check = $db->Execute("select products_options_sort_order
from " . TABLE_PRODUCTS_OPTIONS . "
where products_options_id = '" . $options_id . "' limit 1");
$check_options_id = $db->Execute("select products_id, options_id, options_values_id, products_options_sort_order
from " . TABLE_PRODUCTS_ATTRIBUTES . "
where products_id='" . $products_id . "'
and options_id='" . $options_id . "'
and options_values_id = '" . $options_values_id . "' limit 1");
return $check->fields['products_options_sort_order'] . '.' . str_pad($check_options_id->fields['products_options_sort_order'],5,'0',STR_PAD_LEFT);
}
/*
* check if attribute is display only
*/
function zen_get_attributes_valid($product_id, $option, $value) {
global $db;
// regular attribute validation
$check_attributes = $db->Execute("select attributes_display_only, attributes_required from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . $product_id . "' and options_id='" . $option . "' and options_values_id='" . $value . "'");
$check_valid = true;
// display only cannot be selected
if ($check_attributes->fields['attributes_display_only'] == '1') {
$check_valid = false;
}
// text required validation
if (ereg('^txt_', $option)) {
$check_attributes = $db->Execute("select attributes_display_only, attributes_required from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . $product_id . "' and options_id='" . ereg_replace('txt_', '', $option) . "' and options_values_id='0'");
// text cannot be blank
if ($check_attributes->fields['attributes_required'] == '1' and empty($value)) {
$check_valid = false;
}
}
return $check_valid;
}
/*
* Return Options_Name from ID
*/
function zen_options_name($options_id) {
global $db;
$options_id = str_replace('txt_','',$options_id);
$options_values = $db->Execute("select products_options_name
from " . TABLE_PRODUCTS_OPTIONS . "
where products_options_id = '" . (int)$options_id . "'
and language_id = '" . (int)$_SESSION['languages_id'] . "'");
return $options_values->fields['products_options_name'];
}
/*
* Return Options_values_name from value-ID
*/
function zen_values_name($values_id) {
global $db;
$values_values = $db->Execute("select products_options_values_name
from " . TABLE_PRODUCTS_OPTIONS_VALUES . "
where products_options_values_id = '" . (int)$values_id . "'
and language_id = '" . (int)$_SESSION['languages_id'] . "'");
return $values_values->fields['products_options_values_name'];
}
/*
* configuration key value lookup
* TABLE: configuration
*/
function zen_get_configuration_key_value($lookup) {
global $db;
$configuration_query= $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key='" . $lookup . "'");
$lookup_value= $configuration_query->fields['configuration_value'];
if ( !($lookup_value) ) {
$lookup_value='<span class="lookupAttention">' . $lookup . '</span>';
}
return $lookup_value;
}
/*
* Return products description, based on specified language (or current lang if not specified)
*/
function zen_get_products_description($product_id, $language = '') {
global $db;
if (empty($language)) $language = $_SESSION['languages_id'];
$product_query = "select products_description
from " . TABLE_PRODUCTS_DESCRIPTION . "
where products_id = '" . (int)$product_id . "'
and language_id = '" . (int)$language . "'";
$product = $db->Execute($product_query);
return $product->fields['products_description'];
}
/*
* look up the product type from product_id and return an info page name (for template/page handling)
*/
function zen_get_info_page($zf_product_id) {
global $db;
$sql = "select products_type from " . TABLE_PRODUCTS . " where products_id = '" . $zf_product_id . "'";
$zp_type = $db->Execute($sql);
if ($zp_type->RecordCount() == 0) {
return 'product_info';
} else {
$zp_product_type = $zp_type->fields['products_type'];
$sql = "select type_handler from " . TABLE_PRODUCT_TYPES . " where type_id = '" . $zp_product_type . "'";
$zp_handler = $db->Execute($sql);
return $zp_handler->fields['type_handler'] . '_info';
}
}
/*
* Get accepted credit cards
* There needs to be a define on the accepted credit card in the language file credit_cards.php example: TEXT_CC_ENABLED_VISA
*/
function zen_get_cc_enabled($text_image = 'TEXT_', $cc_seperate = ' ', $cc_make_columns = 0) {
global $db;
$cc_check_accepted_query = $db->Execute(SQL_CC_ENABLED);
$cc_check_accepted = '';
$cc_counter = 0;
if ($cc_make_columns == 0) {
while (!$cc_check_accepted_query->EOF) {
$check_it = $text_image . $cc_check_accepted_query->fields['configuration_key'];
if (defined($check_it)) {
$cc_check_accepted .= constant($check_it) . $cc_seperate;
}
$cc_check_accepted_query->MoveNext();
}
} else {
// build a table
$cc_check_accepted = '<table class="ccenabled">' . "\n";
$cc_check_accepted .= '<tr class="ccenabled">' . "\n";
while (!$cc_check_accepted_query->EOF) {
$check_it = $text_image . $cc_check_accepted_query->fields['configuration_key'];
if (defined($check_it)) {
$cc_check_accepted .= '<td class="ccenabled">' . constant($check_it) . '</td>' . "\n";
}
$cc_check_accepted_query->MoveNext();
$cc_counter++;
if ($cc_counter >= $cc_make_columns) {
$cc_check_accepted .= '</tr>' . "\n" . '<tr class="ccenabled">' . "\n";
$cc_counter = 0;
}
}
$cc_check_accepted .= '</tr>' . "\n" . '</table>' . "\n";
}
return $cc_check_accepted;
}
/*
* Return Category Name from product ID
* TABLES: categories_name
*/
function zen_get_categories_name_from_product($product_id) {
global $db;
$check_products_category= $db->Execute("select products_id, categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id='" . $product_id . "' limit 1");
$the_categories_name= $db->Execute("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id= '" . $check_products_category->fields['categories_id'] . "' and language_id= '" . $_SESSION['languages_id'] . "'");
return $the_categories_name->fields['categories_name'];
}
/*
* configuration key value lookup in TABLE_PRODUCT_TYPE_LAYOUT
* Used to determine keys/flags used on a per-product-type basis for template-use, etc
*/
function zen_get_configuration_key_value_layout($lookup, $type=1) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -