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

📄 order.php

📁 Easy_Buy是一个在线销售系统
💻 PHP
📖 第 1 页 / 共 4 页
字号:
                                   where c.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                                   and ab.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                                   and c.customers_default_address_id = ab.address_book_id";

    $customer_address = $db->Execute($customer_address_query);

    $shipping_address_query = "select ab.entry_firstname, ab.entry_lastname, ab.entry_company,
                                    ab.entry_street_address, ab.entry_suburb, ab.entry_postcode,
                                    ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id,
                                    c.countries_id, c.countries_name, c.countries_iso_code_2,
                                    c.countries_iso_code_3, c.address_format_id, ab.entry_state
                                   from (" . TABLE_ADDRESS_BOOK . " ab
                                   left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)
                                   left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) )
                                   where ab.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                                   and ab.address_book_id = '" . (int)$_SESSION['sendto'] . "'";

    $shipping_address = $db->Execute($shipping_address_query);

    $billing_address_query = "select ab.entry_firstname, ab.entry_lastname, ab.entry_company,
                                   ab.entry_street_address, ab.entry_suburb, ab.entry_postcode,
                                   ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id,
                                   c.countries_id, c.countries_name, c.countries_iso_code_2,
                                   c.countries_iso_code_3, c.address_format_id, ab.entry_state
                                  from (" . TABLE_ADDRESS_BOOK . " ab
                                  left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)
                                  left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) )
                                  where ab.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                                  and ab.address_book_id = '" . (int)$_SESSION['billto'] . "'";

    $billing_address = $db->Execute($billing_address_query);
    //STORE_PRODUCT_TAX_BASIS

    switch (STORE_PRODUCT_TAX_BASIS) {
      case 'Shipping':

      $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id
                              from " . TABLE_ADDRESS_BOOK . " ab
                              left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)
                              where ab.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                              and ab.address_book_id = '" . (int)($this->content_type == 'virtual' ? $_SESSION['billto'] : $_SESSION['sendto']) . "'";
      $tax_address = $db->Execute($tax_address_query);
      break;
      case 'Billing':

      $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id
                              from " . TABLE_ADDRESS_BOOK . " ab
                              left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)
                              where ab.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                              and ab.address_book_id = '" . (int)$_SESSION['billto'] . "'";
      $tax_address = $db->Execute($tax_address_query);
      break;
      case 'Store':
      if ($billing_address->fields['entry_zone_id'] == STORE_ZONE) {

        $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id
                                from " . TABLE_ADDRESS_BOOK . " ab
                                left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)
                                where ab.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                                and ab.address_book_id = '" . (int)$_SESSION['billto'] . "'";
      } else {
        $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id
                                from " . TABLE_ADDRESS_BOOK . " ab
                                left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)
                                where ab.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                                and ab.address_book_id = '" . (int)($this->content_type == 'virtual' ? $_SESSION['billto'] : $_SESSION['sendto']) . "'";
      }
      $tax_address = $db->Execute($tax_address_query);
    }


    $class =& $_SESSION['payment'];

    if (isset($_SESSION['cc_id'])) {
      $coupon_code_query = "select coupon_code
                              from " . TABLE_COUPONS . "
                              where coupon_id = '" . (int)$_SESSION['cc_id'] . "'";

      $coupon_code = $db->Execute($coupon_code_query);


    }

    $this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID,
                        'currency' => $_SESSION['currency'],
                        'currency_value' => $currencies->currencies[$_SESSION['currency']]['value'],
                        'payment_method' => $GLOBALS[$class]->title,
                        'payment_module_code' => $GLOBALS[$class]->code,
                        'coupon_code' => $coupon_code->fields['coupon_code'],
    //                          'cc_type' => (isset($GLOBALS['cc_type']) ? $GLOBALS['cc_type'] : ''),
    //                          'cc_owner' => (isset($GLOBALS['cc_owner']) ? $GLOBALS['cc_owner'] : ''),
    //                          'cc_number' => (isset($GLOBALS['cc_number']) ? $GLOBALS['cc_number'] : ''),
    //                          'cc_expires' => (isset($GLOBALS['cc_expires']) ? $GLOBALS['cc_expires'] : ''),
    //                          'cc_cvv' => (isset($GLOBALS['cc_cvv']) ? $GLOBALS['cc_cvv'] : ''),
                        'shipping_method' => $_SESSION['shipping']['title'],
                        'shipping_module_code' => $_SESSION['shipping']['id'],
                        'shipping_cost' => $_SESSION['shipping']['cost'],
                        'subtotal' => 0,
                        'tax' => 0,
                        'total' => 0,
                        'tax_groups' => array(),
                        'comments' => (isset($_SESSION['comments']) ? $_SESSION['comments'] : ''),
                        'ip_address' => $_SESSION['customers_ip_address'] . ' - ' . $_SERVER['REMOTE_ADDR']
                        );

    //print_r($GLOBALS[$class]);
    //echo $class;
    //print_r($GLOBALS);
    //echo $_SESSION['payment'];
    /*
    // this is set above to the module filename it should be set to the module title like Checks/Money Order rather than moneyorder
    if (isset($$_SESSION['payment']) && is_object($$_SESSION['payment'])) {
    $this->info['payment_method'] = $$_SESSION['payment']->title;
    }
    */

/*
// bof: move below calculations
    if ($this->info['total'] == 0) {
      if (DEFAULT_ZERO_BALANCE_ORDERS_STATUS_ID == 0) {
        $this->info['order_status'] = DEFAULT_ORDERS_STATUS_ID;
      } else {
        $this->info['order_status'] = DEFAULT_ZERO_BALANCE_ORDERS_STATUS_ID;
      }
    }
    if (isset($GLOBALS[$class]) && is_object($GLOBALS[$class])) {
      if ( isset($GLOBALS[$class]->order_status) && is_numeric($GLOBALS[$class]->order_status) && ($GLOBALS[$class]->order_status > 0) ) {
        $this->info['order_status'] = $GLOBALS[$class]->order_status;
      }
    }
// eof: move below calculations
*/
    $this->customer = array('firstname' => $customer_address->fields['customers_firstname'],
                            'lastname' => $customer_address->fields['customers_lastname'],
                            'company' => $customer_address->fields['entry_company'],
                            'street_address' => $customer_address->fields['entry_street_address'],
                            'suburb' => $customer_address->fields['entry_suburb'],
                            'city' => $customer_address->fields['entry_city'],
                            'postcode' => $customer_address->fields['entry_postcode'],
                            'state' => ((zen_not_null($customer_address->fields['entry_state'])) ? $customer_address->fields['entry_state'] : $customer_address->fields['zone_name']),
                            'zone_id' => $customer_address->fields['entry_zone_id'],
                            'country' => array('id' => $customer_address->fields['countries_id'], 'title' => $customer_address->fields['countries_name'], 'iso_code_2' => $customer_address->fields['countries_iso_code_2'], 'iso_code_3' => $customer_address->fields['countries_iso_code_3']),
                            'format_id' => $customer_address->fields['address_format_id'],
                            'telephone' => $customer_address->fields['customers_telephone'],
                            'email_address' => $customer_address->fields['customers_email_address']);

    $this->delivery = array('firstname' => $shipping_address->fields['entry_firstname'],
                            'lastname' => $shipping_address->fields['entry_lastname'],
                            'company' => $shipping_address->fields['entry_company'],
                            'street_address' => $shipping_address->fields['entry_street_address'],
                            'suburb' => $shipping_address->fields['entry_suburb'],
                            'city' => $shipping_address->fields['entry_city'],
                            'postcode' => $shipping_address->fields['entry_postcode'],
                            'state' => ((zen_not_null($shipping_address->fields['entry_state'])) ? $shipping_address->fields['entry_state'] : $shipping_address->fields['zone_name']),
                            'zone_id' => $shipping_address->fields['entry_zone_id'],
                            'country' => array('id' => $shipping_address->fields['countries_id'], 'title' => $shipping_address->fields['countries_name'], 'iso_code_2' => $shipping_address->fields['countries_iso_code_2'], 'iso_code_3' => $shipping_address->fields['countries_iso_code_3']),
                            'country_id' => $shipping_address->fields['entry_country_id'],
                            'format_id' => $shipping_address->fields['address_format_id']);

    $this->billing = array('firstname' => $billing_address->fields['entry_firstname'],
                           'lastname' => $billing_address->fields['entry_lastname'],
                           'company' => $billing_address->fields['entry_company'],
                           'street_address' => $billing_address->fields['entry_street_address'],
                           'suburb' => $billing_address->fields['entry_suburb'],
                           'city' => $billing_address->fields['entry_city'],
                           'postcode' => $billing_address->fields['entry_postcode'],
                           'state' => ((zen_not_null($billing_address->fields['entry_state'])) ? $billing_address->fields['entry_state'] : $billing_address->fields['zone_name']),
                           'zone_id' => $billing_address->fields['entry_zone_id'],
                           'country' => array('id' => $billing_address->fields['countries_id'], 'title' => $billing_address->fields['countries_name'], 'iso_code_2' => $billing_address->fields['countries_iso_code_2'], 'iso_code_3' => $billing_address->fields['countries_iso_code_3']),
                           'country_id' => $billing_address->fields['entry_country_id'],
                           'format_id' => $billing_address->fields['address_format_id']);

    $index = 0;
    $products = $_SESSION['cart']->get_products();
    for ($i=0, $n=sizeof($products); $i<$n; $i++) {
      $this->products[$index] = array('qty' => $products[$i]['quantity'],
                                      'name' => $products[$i]['name'],
                                      'model' => $products[$i]['model'],
                                      'tax' => zen_get_tax_rate($products[$i]['tax_class_id'], $tax_address->fields['entry_country_id'], $tax_address->fields['entry_zone_id']),
                                      'tax_description' => zen_get_tax_description($products[$i]['tax_class_id'], $tax_address->fields['entry_country_id'], $tax_address->fields['entry_zone_id']),
                                      'price' => $products[$i]['price'],
                                      'final_price' => $products[$i]['price'] + $_SESSION['cart']->attributes_price($products[$i]['id']),
                                      'onetime_charges' => $_SESSION['cart']->attributes_price_onetime_charges($products[$i]['id'], $products[$i]['quantity']),
                                      'weight' => $products[$i]['weight'],
                                      'products_priced_by_attribute' => $products[$i]['products_priced_by_attribute'],
                                      'product_is_free' => $products[$i]['product_is_free'],
                                      'products_discount_type' => $products[$i]['products_discount_type'],
                                      'products_discount_type_from' => $products[$i]['products_discount_type_from'],
                                      'id' => $products[$i]['id']);

      if ($products[$i]['attributes']) {
        $subindex = 0;
        reset($products[$i]['attributes']);
        while (list($option, $value) = each($products[$i]['attributes'])) {
          /*
          //clr 030714 Determine if attribute is a text attribute and change products array if it is.
          if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID){
          $attr_value = $products[$i]['attributes_values'][$option];
          } else {
          $attr_value = $attributes->fields['products_options_values_name'];
          }
          */

          $attributes_query = "select popt.products_options_name, poval.products_options_values_name,
                                          pa.options_values_price, pa.price_prefix
                                   from " . TABLE_PRODUCTS_OPTIONS . " popt,
                                        " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval,
                                        " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                   where pa.products_id = '" . (int)$products[$i]['id'] . "'
                                   and pa.options_id = '" . (int)$option . "'
                                   and pa.options_id = popt.products_options_id
                                   and pa.options_values_id = '" . (int)$value . "'
                                   and pa.options_values_id = poval.products_options_values_id
                                   and popt.language_id = '" . (int)$_SESSION['languages_id'] . "'
                                   and poval.language_id = '" . (int)$_SESSION['languages_id'] . "'";

          $attributes = $db->Execute($attributes_query);

          //clr 030714 Determine if attribute is a text attribute and change products array if it is.
          if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID){
            $attr_value = $products[$i]['attributes_values'][$option];
          } else {
            $attr_value = $attributes->fields['products_options_values_name'];
          }

          $this->products[$index]['attributes'][$subindex] = array('option' => $attributes->fields['products_options_name'],
                                                                   'value' => $attr_value,
                                                                   'option_id' => $option,
                                                                   'value_id' => $value,
                                                                   'prefix' => $attributes->fields['price_prefix'],
                                                                   'price' => $attributes->fields['options_values_price']);

          $subindex++;
        }
      }

      // add onetime charges here
      //$_SESSION['cart']->attributes_price_onetime_charges($products[$i]['id'], $products[$i]['quantity'])

      $shown_price = (zen_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'])

⌨️ 快捷键说明

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