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

📄 ps_checkout.inc

📁 php做的网上商店系统。简单易懂
💻 INC
📖 第 1 页 / 共 3 页
字号:
      $db->query($q);      if($db->next_record()) {         echo "<TABLE width=100% border=0 cellspacing=0 cellpadding=1>";         echo "<TR>";         echo "<TD ALIGN=center>";         echo "<font face=arial,helvetica size=\"-1\">";         if ($db->f("address_type_name") != "会员") {           echo "<b>" . $db->f("address_type_name") . "</b><br>";         }         echo $db->f("title") . " ";         echo $db->f("first_name") . " ";         echo $db->f("middle_name") . " ";         echo $db->f("last_name") . " ";         echo "<BR>";         if ($db->f("company")) {           echo $db->f("company");           echo "<BR>";         }         echo $db->f("address_1");         if ($db->f("address_2")) {            echo "<BR>";            echo $db->f("address_2");         }         echo "<BR>";         echo $db->f("city");         echo ", ";         echo $db->f("state") . " ";         echo $db->f("zip");         echo "<BR>";         echo "Phone:";         echo $db->f("phone_1");         echo "<BR>";         echo "Fax:";         echo $db->f("fax");         echo "</FONT>";         echo "</TD>";         echo "</TR>";         echo "</TABLE>";      }      return True;   }  /**************************************************************************  ** name: add()  ** created by: gday  ** description:  Store the order information in the database  ** parameters: $d  ** returns:  True - order information stored  **          False - Failure in storing the order information  ***************************************************************************/   function add(&$d) {     global $auth,       $HTTP_POST_VARS,       $cart,       $ps_vendor_id;       eval(load_class("store", "ps_payment_method"));       $ps_payment_method = new ps_payment_method;       eval(load_class("product", "ps_product"));       $ps_product= new ps_product;       eval(load_class("shop", "ps_cart"));       $ps_cart = new ps_cart;     $db = new ps_DB;               if (!$this->validate_form($d)) {       return False;     }          if (!$this->validate_add($d)) {       return False;     }     $order_number = $this->get_order_number();     $order_subtotal = $this->calc_order_subtotal($d);     $order_tax = $this->calc_order_tax($order_subtotal, $d);     $order_shipping = $this->calc_order_shipping($d);     $order_shipping_tax = $this->calc_order_shipping_tax($d);          $timestamp = time();          $order_total = $order_subtotal + $order_tax + $order_shipping + $order_shipping_tax;     $order_total = sprintf("%.2f", $order_total);     // Check to see if Cybercash Processing is wanted for this payment method     if (($ps_payment_method->get_field($d["payment_method_id"], "enable_processor") == "Y") && CC_ENABLE) {       if (!$this->cybercash_process($order_number, $order_total, $d)) {	 return False;       }     }     else {       $d["order_payment_log"] = "因为你的付款信息还没有收到,我们将在稍后处理.<BR>";     }          /* Insert the main order information */     $q = "INSERT INTO orders ";     $q .= "(user_id, vendor_id, order_number, user_info_id, ";     $q .= "ship_method_id, order_subtotal, order_tax, order_shipping, ";     $q .= "order_shipping_tax, order_currency, order_status, cdate, ";     $q .= "mdate) ";     $q .= "VALUES (";     $q .= "'" . $auth["user_id"] . "', ";     $q .= $ps_vendor_id . ", ";       $q .= "'" . $order_number . "', ";     $q .= $d["ship_to_info_id"] . ", '";     $q .= $d["ship_method_id"] . "', ";     $q .= $order_subtotal . ", ";     $q .= $order_tax . ", ";      $q .= $order_shipping . ", ";     $q .= $order_shipping_tax . ", ";     $q .= "'', "; /* Currency is at the product level - line item */     $q .= "'P', ";     $q .= $timestamp . ", ";     $q .= $timestamp;     $q .= ")";          $db->query($q);     $db->next_record();          /* Get the order id just stored */          $q = "SELECT order_id FROM orders WHERE order_number = ";     $q .= "'" . $order_number . "'";          $db->query($q);     $db->next_record();          $order_id = $db->f("order_id");          /* Insert the Order payment info */          $payment_number = ereg_replace(" |-", "", $d["order_payment_number"]);          // Payment number is encrypted using mySQL ENCODE function.     $q = "INSERT INTO order_payment ";     $q .= "(order_id, payment_method_id, order_payment_number, ";     $q .= "order_payment_expire, order_payment_log, order_payment_name) ";     $q .= "VALUES (";     $q .= $order_id . ", ";     $q .= "'" . $d["payment_method_id"] . "', ";     $q .= "ENCODE(\"$payment_number\",\"" . ENCODE_KEY . "\"), ";     $q .= "'" . $d["order_payment_expire"] . "',";     $q .= "'" . $d["order_payment_log"] . "',";     $q .= "'" . $d["order_payment_name"] . "'";     $q .= ")";     $db->query($q);     $db->next_record();          /* Insert the order line items; one row per product in the cart */     for($i = 0; $i < $cart["idx"]; $i++) {              $product_price_arr = $ps_product->get_price($cart[$i]["product_id"]);              $product_price = $product_price_arr["product_price"];              $vendor_id = $ps_vendor_id;              $product_currency = $product_price_arr["product_currency"];              $q = "INSERT INTO order_item ";       $q .= "(order_id, user_info_id, vendor_id, ";       $q .= "product_id, product_quantity, product_item_price, ";       $q .= "order_item_currency, order_status, cdate, mdate) ";       $q .= "VALUES ('";       $q .= $order_id . "', '";       $q .= $d["ship_to_info_id"] . "', '";       $q .= $vendor_id . "', '";       $q .= $cart[$i]["product_id"] . "', '";       $q .= $cart[$i]["quantity"] . "', '";       $q .= $product_price . "', '";       $q .= $product_currency . "', ";       $q .= "'P','";       $q .= $timestamp . "','";       $q .= $timestamp . "'";       $q .= ")";              $db->query($q);       $db->next_record();     }           // Export the order_id so the checkout complete page can get it     $d["order_id"] = $order_id;          // Unset the payment_method variables           $d["payment_method_id"] = "";     $d["order_payment_number"] = "";     $d["order_payment_expire"] = "";     $d["order_payment_name"] = "";          $HTTP_POST_VARS["payment_method_id"] = "";     $HTTP_POST_VARS["order_payment_number"] = "";              $HTTP_POST_VARS["order_payment_expire"] = "";     $HTTP_POST_VARS["order_payment_name"] = "";          // Send the e-mail confirmation messages     $this->email_receipt($order_id);     // Reset the cart      $ps_cart->reset();          return True;   }  /**************************************************************************  ** name: get_order_number()  ** created by: gday  ** description:  Create an order number using the session id, session  **               name, and the current unix timestamp.  ** parameters:   ** returns: unique order_number  ***************************************************************************/   function get_order_number() {      global $sess;      /* Generated a unique order number */      $str = (string)$sess->id;      $str .= (string)$sess->name;      $str .= (string)time();      $order_number = md5($str);   return($order_number);   }  /**************************************************************************  ** name: calc_order_subtotal()  ** created by: gday  ** description:  Calculate the order subtotal for the current order.    **               Does not include tax or shipping charges.  ** parameters: $d  ** returns: sub total for this order  ***************************************************************************/   function calc_order_subtotal($d) {      global $auth, $cart;      $subtotal = 0.0;       eval(load_class("product", "ps_product"));       $ps_product= new ps_product;           $db = new ps_DB;       for($i = 0; $i < $cart["idx"]; $i++) {            $product_price_arr = $ps_product->get_price($cart[$i]["product_id"]);            $subtotal += $product_price_arr["product_price"] * $cart[$i]["quantity"];      }               return($subtotal);    }  /**************************************************************************  ** name: calc_order_tax()  ** created by: pablo  ** description:Calculate the tax charges for the current order.  This is   **             calculating tax based on the ship-to address.  ** parameters: $d  **             $order_subtotal - sub total for the order  ** returns: Tax for the current order  ***************************************************************************/   function calc_order_tax($order_subtotal, $d) {      global $ps_vendor_id;      $db = new ps_DB;              eval(load_class("tax", "ps_tax"));       $ps_tax= new ps_tax;           $q = "SELECT province,country FROM user_info WHERE user_info_id='";      $q .= $d["ship_to_info_id"] . "'";      $db->query($q);      $db->next_record();       $state = $db->f("state");      $country = $db->f("country");          $q = "SELECT * FROM tax_rate WHERE tax_country='$country' ";      $q .= "AND tax_state='$state'";       $db->query($q);      if ($db->next_record()) {         $rate = $order_subtotal * $db->f("tax_rate");         return $rate;      }      else         return(0);   }  /**************************************************************************  ** name: calc_order_shipping()  ** created by: pablo  ** description:  Calculate the shipping charges for the current order  ** parameters: $d  ** returns: Shipping costs for this order  ***************************************************************************/   function calc_order_shipping($d) {       eval(load_class("ISshipping", "ps_intershipper"));       $ps_intershipper= new ps_intershipper;      if (IS_ENABLE) {        if(!($shipping = $ps_intershipper->fetch_quote($d)))           return(0);        reset($shipping);        while (list($key,$val)=each($shipping)) {          if (strcmp(trim($key),trim($d["ship_method_id"])) == 0)            $quote = $shipping[$key]["rate"];        }        return($quote);      }      else {        return(0);      }   }        /**************************************************************************  ** name: calc_order_shipping_tax()  ** created by: gday  ** description:  Calculate the tax for the shipping of the current order  ** parameters: $d  ** returns: Tax for the shipping of this order  ***************************************************************************/   function calc_order_shipping_tax($d) {       /* 01/25/2000 - Dummy function for now */      return(0);   }      /**************************************************************************  ** name: get_vendor_currency()

⌨️ 快捷键说明

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