zen cart 订单搜索修改

2010-09-12 23:27 来源:www.chinab4c.com 作者:admin

    zen cart这个系统。确实非常强大.zen cart 订单搜索修改主要是为了增加zen cart会员中心订单搜索功能.道理很简单.zen cart和ecshop一样.都不方便在会员中心搜索订单.如果一个会员订单多了。那么就非常麻烦.通过zen cart 订单搜索插件,分析 zencart订单结构.我们可以让zen cart会员中心更加强大。

1:zencart
includes/modules/pages/account_history/header_php.php


if(isset($_GET['order_sn']) && $_GET['order_sn']){
 
 $where.=" and o.orders_id = '".$_GET['order_sn']."'";
 
}
if(isset($_GET['delivery_name']) && $_GET['delivery_name']){
 
 $where.=" and o.delivery_name = '".$_GET['delivery_name']."'";
 
}

 

$orders_total = zen_count_customer_orders('',true,$where);

 $history_query_raw = "SELECT o.orders_id, o.date_purchased, o.delivery_name,
                               o.billing_name, ot.text as order_total, s.orders_status_name
                        FROM   " . TABLE_ORDERS . " o, " . TABLE_ORDERS_TOTAL . " ot, " . TABLE_ORDERS_STATUS . " s
                        WHERE      o.customers_id = :customersID
                        AND        o.orders_id = ot.orders_id
                        AND        ot.class = 'ot_total'
                        $where
                        AND        o.orders_status = s.orders_status_id
                        AND        s.language_id = :languagesID
                        ORDER BY   orders_id DESC";

2:includes/templates/template_default/templates/tpl_account_history_default.php


<form action="http://localhost/zen/index.php?main_page=account_history" method="get">
order_sn:<input type="text" name="order_sn">
<br>

delivery_name:<input type="text" name="delivery_name">


<input type="submit" value="search">
</form>

3:incudes/functions/functions_customers.php

 

  function zen_count_customer_orders($id = '', $check_session = true,$where ='') {
    global $db;

    if (is_numeric($id) == false) {
      if ($_SESSION['customer_id']) {
        $id = $_SESSION['customer_id'];
      } else {
        return 0;
      }
    }

    if ($check_session == true) {
      if ( ($_SESSION['customer_id'] == false) || ($id != $_SESSION['customer_id']) ) {
        return 0;
      }
    }
  
    $orders_check_query = "select count(*) as total
                           from " . TABLE_ORDERS . " o
                           where o.customers_id = '" . (int)$id . "' $where";
  
    $orders_check = $db->Execute($orders_check_query);

    return $orders_check->fields['total'];
  }

相关插件:

    ecshop会员中心订单搜索

来源:http://www.chinab4c.com