order.php

来自「this the oscommerce 3.0 aplha 4」· PHP 代码 · 共 593 行 · 第 1/2 页

PHP
593
字号
<?php/*  $Id: order.php 1498 2007-03-29 14:04:50Z hpdl $  osCommerce, Open Source E-Commerce Solutions  http://www.oscommerce.com  Copyright (c) 2007 osCommerce  This program is free software; you can redistribute it and/or modify  it under the terms of the GNU General Public License v2 (1991)  as published by the Free Software Foundation.*/  class osC_Order {// private variables    var $_valid_order;// class constructor    function osC_Order($order_id = '') {      $this->_valid_order = false;      if (is_numeric($order_id)) {        $this->_getSummary($order_id);      }    }// private methods    function _getSummary($order_id) {      global $osC_Database;      $Qorder = $osC_Database->query('select * from :table_orders where orders_id = :orders_id');      $Qorder->bindTable(':table_orders', TABLE_ORDERS);      $Qorder->bindInt(':orders_id', $order_id);      $Qorder->execute();      if ($Qorder->numberOfRows() === 1) {        $this->_valid_order = true;        $this->_order_id = $Qorder->valueInt('orders_id');        $this->_customer = array('name' => $Qorder->valueProtected('customers_name'),                                 'company' => $Qorder->valueProtected('customers_company'),                                 'street_address' => $Qorder->valueProtected('customers_street_address'),                                 'suburb' => $Qorder->valueProtected('customers_suburb'),                                 'city' => $Qorder->valueProtected('customers_city'),                                 'postcode' => $Qorder->valueProtected('customers_postcode'),                                 'state' => $Qorder->valueProtected('customers_state'),                                 'zone_code' => $Qorder->value('customers_state_code'),                                 'country_title' => $Qorder->value('customers_country'),                                 'country_iso2' => $Qorder->value('customers_country_iso2'),                                 'country_iso3' => $Qorder->value('customers_country_iso3'),                                 'format' => $Qorder->value('customers_address_format'),                                 'telephone' => $Qorder->valueProtected('customers_telephone'),                                 'email_address' => $Qorder->valueProtected('customers_email_address'));        $this->_delivery = array('name' => $Qorder->valueProtected('delivery_name'),                                 'company' => $Qorder->valueProtected('delivery_company'),                                 'street_address' => $Qorder->valueProtected('delivery_street_address'),                                 'suburb' => $Qorder->valueProtected('delivery_suburb'),                                 'city' => $Qorder->valueProtected('delivery_city'),                                 'postcode' => $Qorder->valueProtected('delivery_postcode'),                                 'state' => $Qorder->valueProtected('delivery_state'),                                 'zone_code' => $Qorder->value('delivery_state_code'),                                 'country_title' => $Qorder->value('delivery_country'),                                 'country_iso2' => $Qorder->value('delivery_country_iso2'),                                 'country_iso3' => $Qorder->value('delivery_country_iso3'),                                 'format' => $Qorder->value('delivery_address_format'));        $this->_billing = array('name' => $Qorder->valueProtected('billing_name'),                                'company' => $Qorder->valueProtected('billing_company'),                                'street_address' => $Qorder->valueProtected('billing_street_address'),                                'suburb' => $Qorder->valueProtected('billing_suburb'),                                'city' => $Qorder->valueProtected('billing_city'),                                'postcode' => $Qorder->valueProtected('billing_postcode'),                                'state' => $Qorder->valueProtected('billing_state'),                                'zone_code' => $Qorder->value('billing_state_code'),                                'country_title' => $Qorder->value('billing_country'),                                'country_iso2' => $Qorder->value('billing_country_iso2'),                                'country_iso3' => $Qorder->value('billing_country_iso3'),                                'format' => $Qorder->value('billing_address_format'));        $this->_payment_method = $Qorder->value('payment_method');        $this->_payment_module = $Qorder->value('payment_module');        $this->_currency = array('code' => $Qorder->value('currency'),                                 'value' => $Qorder->value('currency_value'));        $this->_date_purchased = $Qorder->value('date_purchased');        $this->_last_modified = $Qorder->value('last_modified');        $this->_status_id = $Qorder->value('orders_status');      }    }    function _getStatus() {      global $osC_Database, $osC_Language;      $Qstatus = $osC_Database->query('select orders_status_name from :table_orders_status where orders_status_id = :orders_status_id and language_id = :language_id');      $Qstatus->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);      $Qstatus->bindInt(':orders_status_id', $this->_status_id);/* HPDL - DEFAULT_LANGUAGE is the language code, not the language id *///        $Qstatus->bindInt(':language_id', (isset($_SESSION['languages_id']) ? $_SESSION['languages_id'] : DEFAULT_LANGUAGE));      $Qstatus->bindInt(':language_id', $osC_Language->getID());      $Qstatus->execute();      if ($Qstatus->numberOfRows() === 1) {        $this->_status = $Qstatus->value('orders_status_name');      } else {        $this->_status = $this->_status_id;      }    }    function _getStatusHistory() {      global $osC_Database, $osC_Language;      $history_array = array();      $Qhistory = $osC_Database->query('select osh.orders_status_id, osh.date_added, osh.customer_notified, osh.comments, os.orders_status_name from :table_orders_status_history osh left join :table_orders_status os on (osh.orders_status_id = os.orders_status_id and os.language_id = :language_id) where osh.orders_id = :orders_id order by osh.date_added');      $Qhistory->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);      $Qhistory->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);/* HPDL - DEFAULT_LANGUAGE is the language code, not the language id *///        $Qstatus->bindInt(':language_id', (isset($_SESSION['languages_id']) ? $_SESSION['languages_id'] : DEFAULT_LANGUAGE));      $Qhistory->bindInt(':language_id', $osC_Language->getID());      $Qhistory->bindInt(':orders_id', $this->_order_id);      $Qhistory->execute();      while ($Qhistory->next()) {        $history_array[] = array('status_id' => $Qhistory->valueInt('orders_status_id'),                                 'status' => $Qhistory->value('orders_status_name'),                                 'date_added' => $Qhistory->value('date_added'),                                 'customer_notified' => $Qhistory->valueInt('customer_notified'),                                 'comment' => $Qhistory->valueProtected('comments'));      }      $this->_status_history = $history_array;    }    function _getTransactionHistory() {      global $osC_Database, $osC_Language;      $this->_transaction_history = array();      $Qhistory = $osC_Database->query('select oth.transaction_code, oth.transaction_return_value, oth.transaction_return_status, oth.date_added, ots.status_name from :table_orders_transactions_history oth left join :table_orders_transactions_status ots on (oth.transaction_code = ots.id and ots.language_id = :language_id) where oth.orders_id = :orders_id order by oth.date_added');      $Qhistory->bindTable(':table_orders_transactions_history', TABLE_ORDERS_TRANSACTIONS_HISTORY);      $Qhistory->bindTable(':table_orders_transactions_status', TABLE_ORDERS_TRANSACTIONS_STATUS);      $Qhistory->bindInt(':language_id', $osC_Language->getID());      $Qhistory->bindInt(':orders_id', $this->_order_id);      $Qhistory->execute();      while ($Qhistory->next()) {        $this->_transaction_history[] = array('status_id' => $Qhistory->valueInt('transaction_code'),                                              'status' => $Qhistory->value('status_name'),                                              'return_value' => $Qhistory->valueProtected('transaction_return_value'),                                              'return_status' => $Qhistory->valueInt('transaction_return_status'),                                              'date_added' => $Qhistory->value('date_added'));      }    }    function _getPostTransactionActions() {      global $osC_Database, $osC_Language;      $this->_post_transaction_actions = array();      if (file_exists('includes/modules/payment/' . $this->_payment_module . '.php')) {        include('includes/classes/payment.php');        include('includes/modules/payment/' . $this->_payment_module . '.php');        if (call_user_func(array('osC_Payment_' . $this->_payment_module, 'isInstalled')) === true) {          $trans_array = array();          foreach ($this->getTransactionHistory() as $history) {            if ($history['return_status'] === 1) {              $trans_array[] = $history['status_id'];            }          }          $transactions = call_user_func(array('osC_Payment_' . $this->_payment_module, 'getPostTransactionActions'), $trans_array);          if (is_array($transactions) && (empty($transactions) === false)) {            $Qactions = $osC_Database->query('select id, status_name from :table_orders_transactions_status where language_id = :language_id and id in :id order by status_name');            $Qactions->bindTable(':table_orders_transactions_status', TABLE_ORDERS_TRANSACTIONS_STATUS);            $Qactions->bindInt(':language_id', $osC_Language->getID());            $Qactions->bindRaw(':id', '(' . implode(', ', array_keys($transactions)) . ')');            $Qactions->execute();            $trans_code_array = array();            while ($Qactions->next()) {              $this->_post_transaction_actions[] = array('id' => $transactions[$Qactions->valueInt('id')],                                                         'text' => $Qactions->value('status_name'));            }          }        }      }    }    function _getProducts() {      global $osC_Database;      $products_array = array();      $key = 0;      $Qproducts = $osC_Database->query('select orders_products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price from :table_orders_products where orders_id = :orders_id');      $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);      $Qproducts->bindInt(':orders_id', $this->_order_id);      $Qproducts->execute();      while ($Qproducts->next()) {        $products_array[$key] = array('quantity' => $Qproducts->valueInt('products_quantity'),                                      'name' => $Qproducts->value('products_name'),                                      'model' => $Qproducts->value('products_model'),                                      'tax' => $Qproducts->value('products_tax'),                                      'price' => $Qproducts->value('products_price'),                                      'final_price' => $Qproducts->value('final_price'));        $Qattributes = $osC_Database->query('select products_options, products_options_values, options_values_price, price_prefix from :table_orders_products_attributes where orders_id = :orders_id and orders_products_id = :orders_products_id');        $Qattributes->bindTable(':table_orders_products_attributes', TABLE_ORDERS_PRODUCTS_ATTRIBUTES);        $Qattributes->bindInt(':orders_id', $this->_order_id);        $Qattributes->bindInt(':orders_products_id', $Qproducts->valueInt('orders_products_id'));        $Qattributes->execute();        if ($Qattributes->numberOfRows() > 0) {          while ($Qattributes->next()) {            $products_array[$key]['attributes'][] = array('option' => $Qattributes->value('products_options'),                                                          'value' => $Qattributes->value('products_options_values'),                                                          'prefix' => $Qattributes->value('price_prefix'),                                                          'price' => $Qattributes->value('options_values_price'));          }        }        $key++;      }      $this->_products = $products_array;    }    function _getTotals() {      global $osC_Database;      $totals_array = array();      $Qtotals = $osC_Database->query('select title, text, value, class from :table_orders_total where orders_id = :orders_id order by sort_order');      $Qtotals->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL);      $Qtotals->bindInt(':orders_id', $this->_order_id);      $Qtotals->execute();      while ($Qtotals->next()) {        $totals_array[] = array('title' => $Qtotals->value('title'),                                'text' => $Qtotals->value('text'),                                'value' => $Qtotals->value('value'),                                'class' => $Qtotals->value('class'));      }      $this->_totals = $totals_array;    }// public methods    function isValid() {      if ($this->_valid_order === true) {        return true;      } else {        return false;      }    }    function getOrderID() {      return $this->_order_id;    }    function getCustomer($id = '') {      if (empty($id)) {        return $this->_customer;      } elseif (isset($this->_customer[$id])) {        return $this->_customer[$id];      }      return false;    }    function getDelivery($id = '') {      if (empty($id)) {        return $this->_delivery;      } elseif (isset($this->_delivery[$id])) {        return $this->_delivery[$id];      }      return false;    }    function getBilling($id = '') {      if (empty($id)) {        return $this->_billing;      } elseif (isset($this->_billing[$id])) {

⌨️ 快捷键说明

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