order.php

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

PHP
725
字号
              $Qopd->bindTable(':table_orders_products_download', TABLE_ORDERS_PRODUCTS_DOWNLOAD);              $Qopd->bindInt(':orders_id', $insert_id);              $Qopd->bindInt(':orders_products_id', $order_products_id);              $Qopd->bindValue(':orders_products_filename', $Qattributes->value('products_attributes_filename'));              $Qopd->bindValue(':download_maxdays', $Qattributes->value('products_attributes_maxdays'));              $Qopd->bindValue(':download_count', $Qattributes->value('products_attributes_maxcount'));              $Qopd->execute();            }          }        }      }      $_SESSION['prepOrderID'] = $osC_ShoppingCart->getCartID() . '-' . $insert_id;      return $insert_id;    }    function process($order_id, $status_id = '') {      global $osC_Database;      if (empty($status_id) || (is_numeric($status_id) === false)) {        $status_id = DEFAULT_ORDERS_STATUS_ID;      }      $Qstatus = $osC_Database->query('insert into :table_orders_status_history (orders_id, orders_status_id, date_added, customer_notified, comments) values (:orders_id, :orders_status_id, now(), :customer_notified, :comments)');      $Qstatus->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);      $Qstatus->bindInt(':orders_id', $order_id);      $Qstatus->bindInt(':orders_status_id', $status_id);      $Qstatus->bindInt(':customer_notified', (SEND_EMAILS == '1') ? '1' : '0');      $Qstatus->bindValue(':comments', '');      $Qstatus->execute();      $Qupdate = $osC_Database->query('update :table_orders set orders_status = :orders_status where orders_id = :orders_id');      $Qupdate->bindTable(':table_orders', TABLE_ORDERS);      $Qupdate->bindInt(':orders_status', $status_id);      $Qupdate->bindInt(':orders_id', $order_id);      $Qupdate->execute();      $Qproducts = $osC_Database->query('select products_id, products_quantity from :table_orders_products where orders_id = :orders_id');      $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);      $Qproducts->bindInt(':orders_id', $order_id);      $Qproducts->execute();      while ($Qproducts->next()) {        if (STOCK_LIMITED == '1') {/********** HPDL ; still uses logic from the shopping cart class          if (DOWNLOAD_ENABLED == '1') {            $Qstock = $osC_Database->query('select products_quantity, pad.products_attributes_filename from :table_products p left join :table_products_attributes pa on (p.products_id = pa.products_id) left join :table_products_attributes_download pad on (pa.products_attributes_id = pad.products_attributes_id) where p.products_id = :products_id');            $Qstock->bindTable(':table_products', TABLE_PRODUCTS);            $Qstock->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);            $Qstock->bindTable(':table_products_attributes_download', TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD);            $Qstock->bindInt(':products_id', $Qproducts->valueInt('products_id'));// Will work with only one option for downloadable products otherwise, we have to build the query dynamically with a loop            if ($osC_ShoppingCart->hasAttributes($products['id'])) {              $products_attributes = $osC_ShoppingCart->getAttributes($products['id']);              $products_attributes = array_shift($products_attributes);              $Qstock->appendQuery('and pa.options_id = :options_id and pa.options_values_id = :options_values_id');              $Qstock->bindInt(':options_id', $products_attributes['options_id']);              $Qstock->bindInt(':options_values_id', $products_attributes['options_values_id']);            }          } else {************/            $Qstock = $osC_Database->query('select products_quantity from :table_products where products_id = :products_id');            $Qstock->bindTable(':table_products', TABLE_PRODUCTS);            $Qstock->bindInt(':products_id', $Qproducts->valueInt('products_id'));// HPDL          }          $Qstock->execute();          if ($Qstock->numberOfRows() > 0) {            $stock_left = $Qstock->valueInt('products_quantity');// do not decrement quantities if products_attributes_filename exists// HPDL            if ((DOWNLOAD_ENABLED == '-1') || ((DOWNLOAD_ENABLED == '1') && (strlen($Qstock->value('products_attributes_filename')) < 1))) {              $stock_left = $stock_left - $Qproducts->valueInt('products_quantity');              $Qupdate = $osC_Database->query('update :table_products set products_quantity = :products_quantity where products_id = :products_id');              $Qupdate->bindTable(':table_products', TABLE_PRODUCTS);              $Qupdate->bindInt(':products_quantity', $stock_left);              $Qupdate->bindInt(':products_id', $Qproducts->valueInt('products_id'));              $Qupdate->execute();// HPDL            }            if ((STOCK_ALLOW_CHECKOUT == '-1') && ($stock_left < 1)) {              $Qupdate = $osC_Database->query('update :table_products set products_status = 0 where products_id = :products_id');              $Qupdate->bindTable(':table_products', TABLE_PRODUCTS);              $Qupdate->bindInt(':products_id', $Qproducts->valueInt('products_id'));              $Qupdate->execute();            }          }        }// Update products_ordered (for bestsellers list)        $Qupdate = $osC_Database->query('update :table_products set products_ordered = products_ordered + :products_ordered where products_id = :products_id');        $Qupdate->bindTable(':table_products', TABLE_PRODUCTS);        $Qupdate->bindInt(':products_ordered', $Qproducts->valueInt('products_quantity'));        $Qupdate->bindInt(':products_id', $Qproducts->valueInt('products_id'));        $Qupdate->execute();      }      osC_Order::sendEmail($order_id);      unset($_SESSION['prepOrderID']);    }    function sendEmail($id) {      global $osC_Database, $osC_Language, $osC_Currencies;      $Qorder = $osC_Database->query('select * from :table_orders where orders_id = :orders_id limit 1');      $Qorder->bindTable(':table_orders', TABLE_ORDERS);      $Qorder->bindInt(':orders_id', $id);      $Qorder->execute();      if ($Qorder->numberOfRows() === 1) {        $email_order = STORE_NAME . "\n" .                       $osC_Language->get('email_order_separator') . "\n" .                       sprintf($osC_Language->get('email_order_order_number'), $id) . "\n" .                       sprintf($osC_Language->get('email_order_invoice_url'), osc_href_link(FILENAME_ACCOUNT, 'orders=' . $id, 'SSL', false, true, true)) . "\n" .                       sprintf($osC_Language->get('email_order_date_ordered'), osC_DateTime::getLong()) . "\n\n" .                       $osC_Language->get('email_order_products') . "\n" .                       $osC_Language->get('email_order_separator') . "\n";        $Qproducts = $osC_Database->query('select orders_products_id, products_model, products_name, final_price, products_tax, products_quantity from :table_orders_products where orders_id = :orders_id order by orders_products_id');        $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);        $Qproducts->bindInt(':orders_id', $id);        $Qproducts->execute();        while ($Qproducts->next()) {          $email_order .= $Qproducts->valueInt('products_quantity') . ' x ' . $Qproducts->value('products_name') . ' (' . $Qproducts->value('products_model') . ') = ' . $osC_Currencies->displayPriceWithTaxRate($Qproducts->value('final_price'), $Qproducts->value('products_tax'), $Qproducts->valueInt('products_quantity'), $Qorder->value('currency'), $Qorder->value('currency_value')) . "\n";          $Qattributes = $osC_Database->query('select products_options, products_options_values from :table_orders_products_attributes where orders_id = :orders_id and orders_products_id = :orders_products_id order by orders_products_attributes_id');          $Qattributes->bindTable(':table_orders_products_attributes', TABLE_ORDERS_PRODUCTS_ATTRIBUTES);          $Qattributes->bindInt(':orders_id', $id);          $Qattributes->bindInt(':orders_products_id', $Qproducts->valueInt('orders_products_id'));          $Qattributes->execute();          while ($Qattributes->next()) {            $email_order .= "\t" . $Qattributes->value('products_options') . ': ' . $Qattributes->value('products_options_values') . "\n";          }        }        unset($Qproducts);        unset($Qattributes);        $email_order .= $osC_Language->get('email_order_separator') . "\n";        $Qtotals = $osC_Database->query('select title, text 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', $id);        $Qtotals->execute();        while ($Qtotals->next()) {          $email_order .= strip_tags($Qtotals->value('title') . ' ' . $Qtotals->value('text')) . "\n";        }        unset($Qtotals);        if ( (osc_empty($Qorder->value('delivery_name') === false)) && (osc_empty($Qorder->value('street_address') === false)) ) {          $address = array('name' => $Qorder->value('delivery_name'),                           'company' => $Qorder->value('delivery_company'),                           'street_address' => $Qorder->value('delivery_street_address'),                           'suburb' => $Qorder->value('delivery_suburb'),                           'city' => $Qorder->value('delivery_city'),                           'state' => $Qorder->value('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'),                           'postcode' => $Qorder->value('delivery_postcode'),                           'format' => $Qorder->value('delivery_address_format'));          $email_order .= "\n" . $osC_Language->get('email_order_delivery_address') . "\n" .                          $osC_Language->get('email_order_separator') . "\n" .                          osC_Address::format($address, "\n") . "\n";          unset($address);        }        $address = array('name' => $Qorder->value('billing_name'),                         'company' => $Qorder->value('billing_company'),                         'street_address' => $Qorder->value('billing_street_address'),                         'suburb' => $Qorder->value('billing_suburb'),                         'city' => $Qorder->value('billing_city'),                         'state' => $Qorder->value('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'),                         'postcode' => $Qorder->value('billing_postcode'),                         'format' => $Qorder->value('billing_address_format'));        $email_order .= "\n" . $osC_Language->get('email_order_billing_address') . "\n" .                        $osC_Language->get('email_order_separator') . "\n" .                        osC_Address::format($address, "\n") . "\n\n";        unset($address);        $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', $Qorder->valueInt('orders_status'));        $Qstatus->bindInt(':language_id', $osC_Language->getID());        $Qstatus->execute();        $email_order .= sprintf($osC_Language->get('email_order_status'), $Qstatus->value('orders_status_name')) . "\n" .                        $osC_Language->get('email_order_separator') . "\n";        unset($Qstatus);        $Qstatuses = $osC_Database->query('select date_added, comments from :table_orders_status_history where orders_id = :orders_id and comments != "" order by orders_status_history_id');        $Qstatuses->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);        $Qstatuses->bindInt(':orders_id', $id);        $Qstatuses->execute();        while ($Qstatuses->next()) {          $email_order .= osC_DateTime::getLong($Qstatuses->value('date_added')) . "\n\t" . wordwrap(str_replace("\n", "\n\t", $Qstatuses->value('comments')), 60, "\n\t", 1) . "\n\n";        }        unset($Qstatuses);//        if (is_object($GLOBALS[$payment])) {//          $email_order .= $osC_Language->get('email_order_payment_method') . "\n" .//                          $osC_Language->get('email_order_separator') . "\n";//          $email_order .= $osC_ShoppingCart->getBillingMethod('title') . "\n\n";//          if (isset($GLOBALS[$payment]->email_footer)) {//            $email_order .= $GLOBALS[$payment]->email_footer . "\n\n";//          }//        }        osc_email($Qorder->value('customers_name'), $Qorder->value('customers_email_address'), $osC_Language->get('email_order_subject'), $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);// send emails to other people        if (SEND_EXTRA_ORDER_EMAILS_TO != '') {          osc_email('', SEND_EXTRA_ORDER_EMAILS_TO, $osC_Language->get('email_order_subject'), $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);        }      }      unset($Qorder);    }

⌨️ 快捷键说明

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