Put the code on the lib_main.php.
/*get Valid order information*/function Sales_goods_order ($goods _id) {$sql='Select order_id from'. $GLOBALS ['ECS']->table ('Order_goods').'where goods_id='. $goods _id;/*Order_goods Extract order_id*/$res= $GLOBALS ['DB']->GetAll ($sql); foreach($res as$k =$v) {er _id_arr[]= $v ['order_id']; } er _status='1,5';/*1: Split, 5: Confirm that any one of the conditions is met, calculate sales*/er _id= Implode (',', er _id_arr); $sql='SELECT * from'. $GLOBALS ['ECS']->table ('Order_info').'where Order_status in ('. er _status.') and order_id in ('. er _id.')'; $result= $GLOBALS ['DB']->GetAll ($sql); return$result;/*return valid order information*/}/*get a valid order sales statistics for a product*/function Sales_goods_number ($goods _id) {returncount (Sales_goods_order ($goods _id));}
Ecshop get all order information or sales for a product