LLMS_Analytics_Discounts_Widget

LLMS_Analytics_Discounts_Widget class


Description Description

Totals all coupon discounts applied to orders in the given filters.


Top ↑

Source Source

File: includes/admin/reporting/widgets/class.llms.analytics.widget.discounts.php

class LLMS_Analytics_Discounts_Widget extends LLMS_Analytics_Widget {

	public function set_query() {

		global $wpdb;

		$this->set_order_data_query(
			array(
				'query_function' => 'get_var',
				'select'         => array(
					'SUM( cp_val.meta_value )',
				),
				'joins'          => array(
					"JOIN {$wpdb->postmeta} AS cp ON orders.ID = cp.post_id",
					"JOIN {$wpdb->postmeta} AS cp_val ON orders.ID = cp_val.post_id",
				),
				'statuses'       => array(
					'llms-active',
					'llms-completed',
				),
				'wheres'         => array(
					" AND cp.meta_key = '_llms_coupon_used'",
					" AND cp.meta_value = 'yes'",
					" AND cp_val.meta_key = '_llms_coupon_value'",
				),
			)
		);

	}

	protected function format_response() {

		if ( ! $this->is_error() ) {

			return llms_price_raw( floatval( $this->get_results() ) );

		}

	}

}


Top ↑

Methods Methods


Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.