⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 attributes_preview.php

📁 Easy_Buy是一个在线销售系统
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php
/**
 * @package admin
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: attributes_preview.php 3009 2006-02-11 15:41:10Z wilt $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}
//////////////////////////////////////////////////
//// BOF: attributes
//////////////////////////////////////////////////
// limit to 1 for larger tables

    $_GET['products_id'] = $pInfo->products_id;
    $prod_id = $pInfo->products_id;

    $sql = "select count(*) as total
            from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib
            where    patrib.products_id='" . (int)$_GET['products_id'] . "'
            and      patrib.options_id = popt.products_options_id
            and      popt.language_id = '" . (int)$_SESSION['languages_id'] . "'" .
            " limit 1";

    $pr_attr = $db->Execute($sql);

    if ($pr_attr->fields['total'] > 0) {
      if (PRODUCTS_OPTIONS_SORT_ORDER=='0') {
        $options_order_by= ' order by LPAD(popt.products_options_sort_order,11,"0")';
      } else {
        $options_order_by= ' order by popt.products_options_name';
      }

      $sql = "select distinct popt.products_options_id, popt.products_options_name, popt.products_options_sort_order,
                              popt.products_options_type, popt.products_options_length, popt.products_options_comment, popt.products_options_size,
                              popt.products_options_images_per_row,
                              popt.products_options_images_style
              from        " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib
              where           patrib.products_id='" . (int)$_GET['products_id'] . "'
              and             patrib.options_id = popt.products_options_id
              and             popt.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
              $options_order_by;

      $products_options_names = $db->Execute($sql);

// iii 030813 added: initialize $number_of_uploads
      $number_of_uploads = 0;

      if ( PRODUCTS_OPTIONS_SORT_BY_PRICE =='1' ) {
        $order_by= ' order by LPAD(pa.products_options_sort_order,11,"0"), pov.products_options_values_name';
      } else {
        $order_by= ' order by LPAD(pa.products_options_sort_order,11,"0"), pa.options_values_price';
      }

      $discount_type = zen_get_products_sale_discount_type((int)$_GET['products_id']);
      $discount_amount = zen_get_discount_calc((int)$_GET['products_id']);
      $show_onetime_charges_description = 'false';
      $show_attributes_qty_prices_description = 'false';

      while (!$products_options_names->EOF) {
        $products_options_array = array();

/*
                          pa.options_values_price, pa.price_prefix,
                          pa.products_options_sort_order, pa.product_attribute_is_free, pa.products_attributes_weight, pa.products_attributes_weight_prefix,
                          pa.attributes_default, pa.attributes_discounted, pa.attributes_image
*/

        $sql = "select    pov.products_options_values_id,
                          pov.products_options_values_name,
                          pa.*
                from      " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov
                where     pa.products_id = '" . (int)$_GET['products_id'] . "'
                and       pa.options_id = '" . (int)$products_options_names->fields['products_options_id'] . "'
                and       pa.options_values_id = pov.products_options_values_id
                and       pov.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
                $order_by;

        $products_options = $db->Execute($sql);

        $products_options_value_id = '';
        $products_options_details = '';
        $products_options_details_noname = '';
        $tmp_radio = '';
        $tmp_checkbox = '';
        $tmp_html = '';
        $selected_attribute = false;

        $tmp_attributes_image = '';
        $tmp_attributes_image_row = 0;
        $show_attributes_qty_prices_icon = 'false';
        while (!$products_options->EOF) {
          // reset
          $products_options_display_price='';
          $new_attributes_price= '';
          $price_onetime = '';

          $products_options_array[] = array('id' => $products_options->fields['products_options_values_id'],
                                            'text' => $products_options->fields['products_options_values_name']);

          if (((CUSTOMERS_APPROVAL == '2' and $_SESSION['customer_id'] == '') or (STORE_STATUS == '1')) or (CUSTOMERS_APPROVAL_AUTHORIZATION == 2 and $_SESSION['customers_authorization'] != 0)) {
            $new_attributes_price = '';
            $new_options_values_price = 0;
            $products_options_display_price = '';
            $price_onetime = '';
          } else {
// collect price information if it exists
            if ($products_options->fields['attributes_discounted'] == 1) {
// apply product discount to attributes if discount is on
//              $new_attributes_price = $products_options->fields['options_values_price'];
              $new_attributes_price = zen_get_attributes_price_final($products_options->fields["products_attributes_id"], 1, '', 'false');
              $new_attributes_price = zen_get_discount_calc((int)$_GET['products_id'], true, $new_attributes_price);
            } else {
// discount is off do not apply
              $new_attributes_price = $products_options->fields['options_values_price'];
            }

            if ($products_options->fields['attributes_price_onetime'] != 0 or $products_options->fields['attributes_price_factor_onetime'] != 0) {
              $show_onetime_charges_description = 'true';
              $new_onetime_charges = zen_get_attributes_price_final_onetime($products_options->fields["products_attributes_id"], 1, '');
              $price_onetime = TEXT_ONETIME_CHARGE_SYMBOL . $currencies->display_price($new_onetime_charges,
              zen_get_tax_rate($product_info->fields['products_tax_class_id']));
            } else {
              $price_onetime = '';
            }

            if ($products_options->fields['attributes_qty_prices'] != '' or $products_options->fields['attributes_qty_prices_onetime'] != '') {
              $show_attributes_qty_prices_description = 'true';
              $show_attributes_qty_prices_icon = 'true';
            }

            if ($products_options->fields['options_values_price'] != '0' and ($products_options->fields['product_attribute_is_free'] != '1' and $product_info->fields['product_is_free'] != '1')) {
              // show sale maker discount if a percentage
              $products_options_display_price= ' (' . $products_options->fields['price_prefix'] .
              $currencies->display_price($new_attributes_price,
              zen_get_tax_rate($product_info->fields['products_tax_class_id'])) . ') ';
            } else {
              // if product_is_free and product_attribute_is_free
              if ($products_options->fields['product_attribute_is_free'] == '1' and $product_info->fields['product_is_free'] == '1') {
                  $products_options_display_price= TEXT_ATTRIBUTES_PRICE_WAS . $products_options->fields['price_prefix'] .
                  $currencies->display_price($new_attributes_price,
                  zen_get_tax_rate($product_info->fields['products_tax_class_id'])) . TEXT_ATTRIBUTE_IS_FREE;
              } else {
                // normal price
                if ($new_attributes_price == 0) {
                  $products_options_display_price= '';
                } else {
                  $products_options_display_price= ' (' . $products_options->fields['price_prefix'] .
                  $currencies->display_price($new_attributes_price,
                  zen_get_tax_rate($product_info->fields['products_tax_class_id'])) . ') ';
                }
              }
            }

          $products_options_display_price .= $price_onetime;

          } // approve
          $products_options_array[sizeof($products_options_array)-1]['text'] .= $products_options_display_price;

// collect weight information if it exists zen_get_show_product_switch($prod_id, 'WEIGHT_ATTRIBUTES')
          if ((zen_get_show_product_switch($prod_id, 'WEIGHT_ATTRIBUTES') =='1' and $products_options->fields['products_attributes_weight'] != '0')) {
            $products_options_display_weight = ' (' . $products_options->fields['products_attributes_weight_prefix'] . round($products_options->fields['products_attributes_weight'],2) . TEXT_PRODUCT_WEIGHT_UNIT . ')';
            $products_options_array[sizeof($products_options_array)-1]['text'] .= $products_options_display_weight;
          } else {
            // reset
            $products_options_display_weight='';
          }

// prepare product options details
          $prod_id = $_GET['products_id'];
//die($prod_id);
          if ($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_CHECKBOX or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_RADIO or $products_options->RecordCount() == 1 or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_READONLY) {
            $products_options_value_id = $products_options->fields['products_options_values_id'];
            if ($products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_TEXT and $products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_FILE) {
              $products_options_details = $products_options->fields['products_options_values_name'];
            } else {
              // don't show option value name on TEXT or filename
              $products_options_details = '';
            }
            if ($products_options_names->fields['products_options_images_style'] >= 3) {
              $products_options_details .= $products_options_display_price . ($products_options->fields['options_values_price'] != 0 ? '<br />' . $products_options_display_weight : '');
              $products_options_details_noname = $products_options_display_price . ($products_options->fields['options_values_price'] != 0 ? '<br />' . $products_options_display_weight : '');
            } else {
              $products_options_details .= $products_options_display_price . ($products_options->fields['options_values_price'] != 0 ? '&nbsp;' . $products_options_display_weight : '');
              $products_options_details_noname = $products_options_display_price . ($products_options->fields['options_values_price'] != 0 ? '&nbsp;' . $products_options_display_weight : '');
            }
          }

// radio buttons
//echo $prod_id;
//echo $_SESSION['cart']->in_cart($prod_id);



          if ($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_RADIO) {
            if (false) {
              if ($_SESSION['cart']->contents[$prod_id]['attributes'][$products_options_names->fields['products_options_id']] == $products_options->fields['products_options_values_id']) {
                $selected_attribute = $_SESSION['cart']->contents[$prod_id]['attributes'][$products_options_names->fields['products_options_id']];
              } else {
                $selected_attribute = false;
              }
            } else {
//              $selected_attribute = ($products_options->fields['attributes_default']=='1' ? true : false);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -