The code is as follows: |
Copy code |
$ Smarty-> assign ('goods _ count', get_goods_coun ($ goods_id ));, |
Finally, you can directly call {$ goods_count} in the template file goods. dwt.
The code is as follows: |
Copy code |
/** * Obtain the total number of products sold * * @ Access public * @ Param integer $ goods_id * @ Return integer */ Function get_goods_count ($ goods_id) { /* Statistical period $ Period = intval ($ GLOBALS ['_ CFG'] ['top10 _ time']); If ($ period = 1) // one year { $ Ext = "AND o. add_time> '". local_strtotime ('-1 years ')."'"; } Elseif ($ period = 2) // half a year { $ Ext = "AND o. add_time> '". local_strtotime ('-6 months ')."'"; } Elseif ($ period = 3) // three months { $ Ext = "AND o. add_time> '". local_strtotime ('-3 months ')."'"; } Elseif ($ period = 4) // one month { $ Ext = "AND o. add_time> '". local_strtotime ('-1 months ')."'"; } Else { $ Ext = ''; }*/ /* Query the sales volume of this item */ $ SQL = 'SELECT IFNULL (SUM (g. goods_number), 0 )'. 'From'. $ GLOBALS ['ecs']-> table ('Order _ info'). 'As o ,'. $ GLOBALS ['ecs']-> table ('Order _ goods '). 'As G '. "WHERE o. order_id = g. order_id ". "AND o. order_status = '". OS _CONFIRMED ."'". "AND o. shipping_status". db_create_in (array (SS_SHIPPED, SS_RECEIVED )). "AND o. pay_status". db_create_in (array (PS_PAYED, PS_PAYING )). "AND g. goods_id = '$ goods_id '"; $ Sales_count = $ GLOBALS ['DB']-> getOne ($ SQL ); Return $ sales_count; } |
Removes the comment within a specified period of time.