Gocodebox_Banner_Notifier::notification_test_llms_revenue( bool $value, array $data )
LifterLMS revenue test.
Parameters Parameters
- $value
-
(bool) (Required) The current test value.
- $data
-
(array) (Required) Array from the notification with [0] comparison operator and [1] revenue.<br>Optionally $data can contain a third parameter to also check the currency code.
Source Source
File: libraries/banner-notifications/src/notifications.php
function notification_test_llms_revenue( $value, $data ) {
global $wpdb;
static $revenue;
if ( ! is_array( $data ) || ! isset( $data[0] ) || ! isset( $data[1] ) ) {
return false;
}
if ( ! isset( $revenue ) ) {
$sql_query = "SELECT SUM(sales.meta_value - COALESCE(refunds.meta_value, 0)) AS amount
FROM {$wpdb->posts} AS txns
JOIN {$wpdb->postmeta} AS sales ON sales.post_id = txns.ID AND sales.meta_key = '_llms_amount'
LEFT JOIN {$wpdb->postmeta} AS refunds ON refunds.post_id = txns.ID AND refunds.meta_key = '_llms_refund_amount'
WHERE
( txns.post_status = 'llms-txn-succeeded' OR txns.post_status = 'llms-txn-refunded' )
AND txns.post_type = 'llms_transaction'
;";
$revenue = $wpdb->get_var( $sql_query );
}
return $this->int_compare( $revenue, $data[1], $data[0] );
}
Expand full source code Collapse full source code View on GitHub