order.php

来自「全新且完善的强大网上商店系统」· PHP 代码 · 共 283 行 · 第 1/2 页

PHP
283
字号
<?php



  class order {
    var $info, $totals, $products, $customer, $delivery, $content_type;

    function order($order_id = '') {
      $this->info = array();
      $this->totals = array();
      $this->products = array();
      $this->customer = array();
      $this->delivery = array();

      if (tep_not_null($order_id)) {
        $this->query($order_id);
      } else {
        $this->cart();
      }
    }

    function query($order_id) {
      global $languages_id,$db, $table_orders_total, $table_orders, $table_orders_status, $table_orders_products, $table_orders_products_attributes;

      $order_id = ($order_id);

      $order_query = $db->query("select customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode,customers_tel_regular,customers_tel_mobile,customers_state, customers_country, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode,delivery_tel_regular,delivery_tel_mobile,  delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode,billing_tel_regular,billing_tel_mobile, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified from $table_orders where orders_id = '" . (int)$order_id . "'");
      $order = $db->fetch_array($order_query);

      $totals_query = $db->query("select title, text from $table_orders_total where orders_id = '" . (int)$order_id . "' order by sort_order");
      while ($totals = $db->fetch_array($totals_query)) {
        $this->totals[] = array('title' => $totals['title'],
                                'text' => $totals['text']);
      }

      $order_total_query = $db->query("select text from $table_orders_total where orders_id = '" . (int)$order_id . "' and class = 'ot_total'");
      $order_total = $db->fetch_array($order_total_query);

      $shipping_method_query = $db->query("select title from $table_orders_total where orders_id = '" . (int)$order_id . "' and class = 'ot_shipping'");
      $shipping_method = $db->fetch_array($shipping_method_query);

      $order_status_query = $db->query("select orders_status_name from $table_orders_status where orders_status_id = '" . $order['orders_status'] . "' and language_id = '" . (int)$languages_id . "'");
      $order_status = $db->fetch_array($order_status_query);

      $this->info = array('currency' => $order['currency'],
                          'currency_value' => $order['currency_value'],
                          'payment_method' => $order['payment_method'],
                          'cc_type' => $order['cc_type'],
                          'cc_owner' => $order['cc_owner'],
                          'cc_number' => $order['cc_number'],
                          'cc_expires' => $order['cc_expires'],
                          'date_purchased' => $order['date_purchased'],
                          'orders_status' => $order_status['orders_status_name'],
                          'last_modified' => $order['last_modified'],
                          'total' => strip_tags($order_total['text']),
                          'shipping_method' => ((substr($shipping_method['title'], -1) == ':') ? substr(strip_tags($shipping_method['title']), 0, -1) : strip_tags($shipping_method['title'])));

      $this->customer = array('id' => $order['customers_id'],
                              'firstname' => $order['customers_name'],
                              'company' => $order['customers_company'],
                              'street_address' => $order['customers_street_address'],
                              'suburb' => $order['customers_suburb'],
                              'city' => $order['customers_city'],
                              'postcode' => $order['customers_postcode'],
                              'tel_regular' => $order['customers_tel_regular'],
                              'tel_mobile' => $order['customers_tel_mobile'],
															'state' => $order['customers_state'],
                              'country' => $order['customers_country'],
                              'format_id' => $order['customers_address_format_id'],
                              'email_address' => $order['customers_email_address']);

      $this->delivery = array('name' => $order['delivery_name'],
                              'company' => $order['delivery_company'],
                              'street_address' => $order['delivery_street_address'],
                              'suburb' => $order['delivery_suburb'],
                              'city' => $order['delivery_city'],
                              'postcode' => $order['delivery_postcode'],
                              'tel_regular' => $order['delivery_tel_regular'],
                              'tel_mobile' => $order['delivery_tel_mobile'],
                              'state' => $order['delivery_state'],
                              'country' => $order['delivery_country'],
                              'format_id' => $order['delivery_address_format_id']);

      if (empty($this->delivery['name']) && empty($this->delivery['street_address'])) {
        $this->delivery = false;
      }

      $this->billing = array('name' => $order['billing_name'],
                             'company' => $order['billing_company'],
                             'street_address' => $order['billing_street_address'],
                             'suburb' => $order['billing_suburb'],
                             'city' => $order['billing_city'],
                             'postcode' => $order['billing_postcode'],
                             'tel_regular' => $order['billing_tel_regular'],
                             'tel_mobile' => $order['billing_tel_mobile'],
                             'state' => $order['billing_state'],
                             'country' => $order['billing_country'],
                             'format_id' => $order['billing_address_format_id']);

      $index = 0;
      $orders_products_query = $db->query("select orders_products_id, products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price from $table_orders_products where orders_id = '" . (int)$order_id . "'");
      
			while ($orders_products = $db->fetch_array($orders_products_query)) {
        $this->products[$index] = array('qty' => $orders_products['products_quantity'],
	                                'id' => $orders_products['products_id'],
                                        'name' => $orders_products['products_name'],
                                        'model' => $orders_products['products_model'],
                                        'tax' => $orders_products['products_tax'],
                                        'price' => $orders_products['products_price'],
                                        'final_price' => $orders_products['final_price']);

				$subindex = 0;
        $attributes_query = $db->query("select products_options, products_options_values, options_values_price, price_prefix from $table_orders_products_attributes where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'");
        if ($db->num_rows($attributes_query)) {
          while ($attributes = $db->fetch_array($attributes_query)) {
            $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'],
                                                                     'value' => $attributes['products_options_values'],
                                                                     'prefix' => $attributes['price_prefix'],
                                                                     'price' => $attributes['options_values_price']);

            $subindex++;
          }
        }

        $this->info['tax_groups']["{$this->products[$index]['tax']}"] = '1';

        $index++;
      }
    }

    function cart() {
      
			 global $db,$customer_id, $sendto, $billto, $cart, $languages_id, $currency, $currencies, $shipping, $payment;
       global $table_customers , $table_address_book , $table_zones , $table_countries , $table_zones , $table_products_options , $table_products_options_values , $table_products_attributes; 
      $this->content_type = $cart->get_content_type();

      $customer_address_query = $db->query("select c.customers_firstname, c.customers_email_address, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_tel_regular, ab.entry_tel_mobile, ab.entry_city, ab.entry_zone_id, z.zone_name, co.countries_id, co.countries_name, co.countries_iso_code_2, co.countries_iso_code_3, co.address_format_id, ab.entry_state from $table_customers c, $table_address_book ab left join $table_zones z on (ab.entry_zone_id = z.zone_id) left join $table_countries co on (ab.entry_country_id = co.countries_id) where c.customers_id = '" . (int)$customer_id . "' and ab.customers_id = '" . (int)$customer_id . "' and c.customers_default_address_id = ab.address_book_id");
      $customer_address = $db->fetch_array($customer_address_query);

      $shipping_address_query = $db->query("select ab.entry_firstname,  ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_tel_regular, ab.entry_tel_mobile, 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)$customer_id . "' and ab.address_book_id = '" . (int)$sendto . "'");
      $shipping_address = $db->fetch_array($shipping_address_query);
      

⌨️ 快捷键说明

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