wp-pay-gateways /
mollie
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Mollie customer query. |
||
| 4 | * |
||
| 5 | * @author Pronamic <[email protected]> |
||
| 6 | * @copyright 2005-2020 Pronamic |
||
| 7 | * @license GPL-3.0-or-later |
||
| 8 | * @package Pronamic\WordPress\Pay |
||
| 9 | */ |
||
| 10 | |||
| 11 | namespace Pronamic\WordPress\Pay\Gateways\Mollie; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Title: Mollie customer query |
||
| 15 | * Description: |
||
| 16 | * Copyright: 2005-2020 Pronamic |
||
| 17 | * Company: Pronamic |
||
| 18 | * |
||
| 19 | * @author Remco Tolsma |
||
| 20 | * @version 2.1.0 |
||
| 21 | * @since 2.1.0 |
||
| 22 | */ |
||
| 23 | class CustomerQuery { |
||
| 24 | /** |
||
| 25 | * Construct customer query. |
||
| 26 | * |
||
| 27 | * @param array $args Query arguments. |
||
| 28 | */ |
||
| 29 | 24 | public function __construct( $args = array() ) { |
|
| 30 | 24 | $this->args = \wp_parse_args( |
|
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 31 | 24 | $args, |
|
| 32 | array( |
||
| 33 | 24 | 'user_id' => null, |
|
| 34 | 'organization_id' => null, |
||
| 35 | ) |
||
| 36 | ); |
||
| 37 | 24 | } |
|
| 38 | |||
| 39 | /** |
||
| 40 | * Get customers. |
||
| 41 | * |
||
| 42 | * @return array |
||
| 43 | */ |
||
| 44 | 24 | public function get_customers() { |
|
| 45 | 24 | global $wpdb; |
|
| 46 | |||
| 47 | 24 | $where = '1 = 1'; |
|
| 48 | |||
| 49 | 24 | if ( array_key_exists( 'user_id', $this->args ) ) { |
|
| 50 | 24 | $where .= $wpdb->prepare( ' AND mollie_customer_user.user_id = %d', $this->args['user_id'] ); |
|
| 51 | } |
||
| 52 | |||
| 53 | $query = " |
||
| 54 | SELECT |
||
| 55 | mollie_customer.mollie_id, |
||
| 56 | mollie_customer.test_mode, |
||
| 57 | mollie_customer.name, |
||
| 58 | mollie_customer.email |
||
| 59 | FROM |
||
| 60 | 24 | $wpdb->pronamic_pay_mollie_customer_users AS mollie_customer_user |
|
| 61 | INNER JOIN |
||
| 62 | 24 | $wpdb->pronamic_pay_mollie_customers AS mollie_customer |
|
| 63 | ON mollie_customer_user.customer_id = mollie_customer.id |
||
| 64 | WHERE |
||
| 65 | 24 | $where |
|
| 66 | ; |
||
| 67 | "; |
||
| 68 | |||
| 69 | // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Query is prepared. |
||
| 70 | 24 | return $wpdb->get_results( $query ); |
|
| 71 | } |
||
| 72 | } |
||
| 73 |