Ecshop shows the number of items sold (January, February, March, half a year)

Source: Internet
Author: User
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.

 

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.