Bigcommerce: Add reservation function

Source: Internet
Author: User

Requirements:
(1) Search for all orders in which the SKU contains the prefix "DE-" or "AG-". If the prefix is "DE-", separate the included products and add an order storage product;
(2) Order List page: use different colors, including "DE-" or "AG-" to display a color for easy viewing


Development procedure


1. Add a style
. OrderStatus_DE {
Background-color: # 04c23a;
Border-color: # 04c23a;
}
. OrderStatus_AG {
Background-color: #704e04;
Border-color: #704e04;
}




+++ Modify the database +++ ++
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. Quick search function Modification


Modified file:
A) admin/shortdes/class. orders. php
Add filter conditions in the BuildWhereFromVars () method
// Find the SKU that contains 'de-'or '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
Find: & nbsp; {% lang 'shippingmethod' %}: add the option below <tr>
<Tr>
<Td class = "FieldLabel">
& Nbsp; 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
New
ChoosePreSKU = "-- Choose SKU contain DE-or AG ---"












3. Order List separation Order


A) admin/shortdes/class. orders. php
In the ManageOrdersGrid () method,


Search: while ($ row = $ GLOBALS ['isc _ CLASS_DB ']-> Fetch ($ orderResult )){


Add:
// Arlinger info 2013-9-24
$ GLOBALS ['orderstatus _ de'] = "";
$ GLOBALS ['orderstatus _ AQ '] = "";
$ SkuArray = array ();
// End arlinger info 2013-9-24






Search: $ GLOBALS ['mermerid'] = $ row ['ordcustid'];
Add:


// Arlinger info 2013-9-23
// Find the product SKU under this Order
$ QuerySku = "SELECT ordprodsku FROM isc_order_products WHERE orderorderid =". $ row ['orderid']. "";
$ ResultSku = $ GLOBALS ['isc _ CLASS_DB ']-> Query ($ querySku );

// Obtain the product 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']);
}


// Differentiate colors
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








 
Add the code above the return in the last line of this method:




// 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 ."");

// Separate order, and re-create an order for products that contain 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/> ";
// Search for the ID number that has just been separated and added to the new order
$ 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 )){


// Find another orderid to be added
$ 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 ++;

}

}
}
// Update the price and quantity of the current product order
$ This-> Update_New_Order_By_OrderID ();
// End arlinger info 2013-9-23














B) add two methods at the bottom of the file: Update_New_Order_By_OrderID () and Add_New_Order_ByProductSKU ()












Procedure
Admin/shortdes/class. orders. php processes all order-related operations and selects different operations based on the ToDo parameter. For example, "ToDo = addOrder" is used to add an order,
The default operation is ViewOrders.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.