Bigcommerce: 添加预定功能
需求:
(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