需求:
(1)尋找訂單商品中SKU包含前置詞“DE-”或者“AG-”的所有訂單,如果包含,將包含的產品獨立出來並新增一個訂單儲存這個產品;
(2)訂單列表頁:用不同的顏色區分,包含“DE-”或者“AG-”各自顯示一種顏色,便於查看
開發步驟
1.添加樣式
.OrderStatus_DE {
background-color: #04c23a;
border-color: #04c23a;
}
.OrderStatus_AG {
background-color: #704e04;
border-color: #704e04;
}
++++++修改資料庫++++++++
ALTER TABLE `isc_orders` ADD `updateprice` INT( 10 ) NULL DEFAULT '0'
ALTER TABLE `isc_orders` ADD `updateorder` INT( 10 ) NULL DEFAULT '0'
ALTER TABLE `isc_order_products` ADD `updateorderproduct` INT( 10 ) NULL DEFAULT '0'
2.快捷搜尋的功能修改
修改的檔案:
a)admin/includes/class.orders.php
在BuildWhereFromVars()方法中新增過濾條件
// 尋找SKU中包含‘DE-’或者‘AG-’
if(isset($array['preSKU'])) {
$queryWhere .= " AND (
SELECT sp.orderprodid
FROM [|PREFIX|]order_products sp
WHERE sp.ordprodsku LIKE '".$GLOBALS['ISC_CLASS_DB']->Quote($array['preSKU'])."%' AND sp.orderorderid=o.orderid
LIMIT 1
)";
}
b)admin/templates/orders.search.tpl
尋找: {% lang 'ShippingMethod' %}: 在這個<tr>下面新增選項
<tr>
<td class="FieldLabel">
DE ord AG Search:
</td>
<td>
<select id="newCondition" name="preSKU" class="Field250">
<option value="">{% lang 'ChoosePreSKU' %}</option>
<option value="DE-">SKU contain "DE-"</option>
<option value="AG-">SKU contain "AG-"</option>
</select>
</td>
</tr>
c)/language/en/admin/orders.ini
新增
ChoosePreSKU = "-- Choose SKU contain DE- or AG- --"
3.Order列表分離訂單
a)admin/includes/class.orders.php
在ManageOrdersGrid()方法中,
尋找:while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($orderResult)) {
在上面添加:
//arlinger info 2013-9-24
$GLOBALS['OrderStatus_DE']="";
$GLOBALS['OrderStatus_AQ']="";
$skuArray=array();
//end arlinger info 2013-9-24
尋找:$GLOBALS['CustomerId'] = $row['ordcustid'];
在上面添加:
//arlinger info 2013-9-23
//尋找這個訂單下的產品SKU
$querySku = "SELECT ordprodsku FROM isc_order_products WHERE orderorderid=" . $row['orderid'] . "";
$resultSku = $GLOBALS['ISC_CLASS_DB']->Query($querySku);
//擷取產品sku
while ($rowSku = $GLOBALS['ISC_CLASS_DB']->Fetch($resultSku)) {
if(substr($rowSku['ordprodsku'], 0, 3) == "DE-" || substr($rowSku['ordprodsku'], 0, 3)=="AQ-"){
$skuArray[] =array( "sku"=>$rowSku['ordprodsku'],"oid"=>$row['orderid']);
}
//區分顏色
if(substr($rowSku['ordprodsku'], 0, 3) == "AQ-"){
$GLOBALS['OrderStatus_AQ'] = "OrderStatus_AQ";
}else{
$GLOBALS['OrderStatus_AQ'] = "OrderStatus_None";
}
if(substr($rowSku['ordprodsku'], 0, 3) == "DE-"){
$GLOBALS['OrderStatus_DE'] = "OrderStatus_DE";
}else{
$GLOBALS['OrderStatus_DE'] = "OrderStatus_None";
}
}
//end arlinger info 2013-9-23
在這個方法最後一行return上面添加代碼:
//arlinger info 2013-9-23
$id_k="";
$sku_v="";
$i=1;
$j=0;
while(list($key,$value) = each($skuArray)){
while(list($k,$v) = each($value))
{
// echo $i."==>".$k."===--->".$v."<br>";
if($i % 2 == 1){$sku_v=$v;}
if($i% 2 == 0){$id_k=$v;}
$i++;
}
if($id_k & $sku_v){
$qCount = "SELECT count(orderprodid) FROM [|PREFIX|]order_products WHERE ordprodsku!='".$sku_v."' AND orderorderid =". $id_k."";
$rowCount = $GLOBALS['ISC_CLASS_DB']->FetchOne($qCount);
//echo $qCount;
if($rowCount!=0){
echo $id_k."2222".$sku_v."=====<br/>";
$updatedMain = array(
"updateprice" => 1
);
$GLOBALS['ISC_CLASS_DB']->UpdateQuery("orders", $updatedMain, "orderid=" . $id_k . "");
//分離order,包含DE-的產品重建立立一個訂單
$this->Add_New_Order_ByProductSKU($id_k,$sku_v);
if($id_k & $sku_v ){
if( $j%2 == 1 ){
echo $id_k."2222".$sku_v."=====<br/>";
//尋找剛分離出來並添加新訂單的id號
$qOrderId = "SELECT orddate,ordcustid, total_ex_tax, shipping_cost_ex_tax FROM [|PREFIX|]orders WHERE orderid=" . $id_k . "";
$rowOrderId = $GLOBALS['ISC_CLASS_DB']->Query($qOrderId);
while ($rowID = $GLOBALS['ISC_CLASS_DB']->Fetch($rowOrderId)) {
//尋找另一個需要添加的orderid
$qOrderId2 = "SELECT orderid FROM [|PREFIX|]orders WHERE ordcustid='" . $rowID['ordcustid'] . "' AND total_ex_tax='" . $rowID['total_ex_tax'] . "' AND orderid!=".$id_k."";
$rowOrderId2 = $GLOBALS['ISC_CLASS_DB']->FetchOne($qOrderId2);
//echo $rowOrderId2;
$updatedOrderId = array(
"orderorderid" => $rowOrderId2,
"updateorderproduct" => 3
);
$GLOBALS['ISC_CLASS_DB']->UpdateQuery("order_products", $updatedOrderId, "orderorderid=" . $id_k . " AND ordprodsku='" .$sku_v. "' AND updateorderproduct=1");
}
}
}
$j++;
}
}
}
//更新當前的產品order的價格和數量
$this->Update_New_Order_By_OrderID();
//end arlinger info 2013-9-23
b)在檔案的最底部添加倆個方法:Update_New_Order_By_OrderID()和Add_New_Order_ByProductSKU()
程式流程
admin/includes/class.orders.php處理所有與訂單相關操作,根據ToDo參數選擇不同的操作,例如“ToDo=addOrder”是添加訂單,
預設操作是ViewOrders