| 1 |
<?php |
| 2 |
namespace LWS\WOOREWARDS\PointsFlow\Methods; |
| 3 |
|
| 4 |
// don't call the file directly |
| 5 |
if( !defined( 'ABSPATH' ) ) exit(); |
| 6 |
|
| 7 |
/** Get the total points for users. |
| 8 |
* that will be rounded (floor) at import in MyRewards (points are integer). */ |
| 9 |
class Yith extends \LWS\WOOREWARDS\PointsFlow\ExportMethod |
| 10 |
{ |
| 11 |
/** @return (array) the json that will be send, |
| 12 |
* An array with each entries as {email, points} */ |
| 13 |
public function export($value, $arg) |
| 14 |
{ |
| 15 |
global $wpdb; |
| 16 |
$table = $wpdb->prefix . 'yith_ywpar_points_log'; |
| 17 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter -- third-party table name |
| 18 |
$results = $wpdb->get_results("SELECT u.user_email as `email`, SUM((yith.amount)) as `points` FROM {$table} as yith INNER JOIN {$wpdb->users} as u ON u.ID=yith.user_id GROUP BY yith.user_id"); |
| 19 |
if ($wpdb->last_error) { |
| 20 |
\wp_die("Yith Points and Rewards must be installed and active", 410); |
| 21 |
} |
| 22 |
return $results; |
| 23 |
} |
| 24 |
|
| 25 |
/** @return (string) human readable name */ |
| 26 |
public function getTitle() |
| 27 |
{ |
| 28 |
return __("Yith Points and rewards", 'woorewards-lite'); |
| 29 |
} |
| 30 |
} |