LLMS_Analytics_Coupons_Widget
Coupons analytics widget class
Description Description
Locates number of active / completed orders from a given date range by a given group of students.
Source Source
File: includes/admin/reporting/widgets/class.llms.analytics.widget.coupons.php
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | class LLMS_Analytics_Coupons_Widget extends LLMS_Analytics_Widget { public $charts = true; /** * Retrieve data for chart * * @return array * @since 3.0.0 * @version 3.0.0 */ protected function get_chart_data() { return array ( 'type' => 'count' , 'header' => array ( 'id' => 'coupons' , 'label' => __( '# of Coupons Used' , 'lifterlms' ), 'type' => 'number' , ), ); } /** * Setup the query * * @return void * @since 3.0.0 * @version 3.0.0 */ public function set_query() { global $wpdb ; $this ->set_order_data_query( array ( 'query_function' => 'get_results' , 'select' => array ( 'orders.post_date AS date' , ), 'joins' => array ( "JOIN {$wpdb->postmeta} AS coupons ON orders.ID = coupons.post_id" , ), 'statuses' => array ( 'llms-active' , 'llms-completed' , ), 'wheres' => array ( " AND coupons.meta_key = '_llms_coupon_used'" , " AND coupons.meta_value = 'yes'" , ), ) ); } /** * Format the response * * @return int * @since 3.0.0 * @version 3.18.0 */ protected function format_response() { if ( ! $this ->is_error() ) { return count ( $this ->get_results() ); } } } |
Expand full source code Collapse full source code View on GitHub
Methods Methods
- format_response — Format the response
- get_chart_data — Retrieve data for chart
- set_query — Setup the query
Changelog Changelog
Version | Description |
---|---|
3.18.0 | Unknown. |
3.0.0 | Introduced. |