Completed
Push — master ( bcf6c3...37bd96 )
by
unknown
13s queued 10s
created

getPromotedAmount()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
c 0
b 0
f 0
nc 3
nop 0
dl 0
loc 11
rs 10
1
<?php
2
function requireWPPluginFunctions()
3
{
4
    if (! function_exists('is_plugin_active')) {
5
        require_once(ABSPATH . 'wp-admin/includes/plugin.php');
0 ignored issues
show
Bug introduced by
The constant ABSPATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
6
    }
7
}
8
9
requireWPPluginFunctions();
10
11
12
/**
13
 * Get lowercase config value from WP DB
14
 *
15
 * @param string $configKey
16
 *
17
 * @return string
18
 * @global wpdb  $wpdb WordPress database abstraction object.
19
 */
20
function getConfigValue($configKey)
21
{
22
    global $wpdb;
23
    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
24
    $value     = $wpdb->get_var($wpdb->prepare("SELECT value FROM $tableName WHERE config= %s ", $configKey));
25
26
    return $value;
27
}
28
29
/**
30
 * Check if table exists in WordPress DB
31
 *
32
 * @param string $tableToCheck
33
 *
34
 * @return bool
35
 * @see wpdb::get_var()
36
 */
37
function isPgTableCreated($tableToCheck)
38
{
39
    global $wpdb;
40
    $tableName = $wpdb->prefix . $tableToCheck;
41
    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) {
42
        return true;
43
    }
44
45
    return false;
46
}
47
48
/**
49
 * Check if orders table exists
50
 */
51
function createPgCartTable()
52
{
53
    global $wpdb;
54
    $tableName       = $wpdb->prefix . PG_CART_PROCESS_TABLE;
55
    $charset_collate = $wpdb->get_charset_collate();
56
    $sql             = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50),  
57
                  UNIQUE KEY id (id)) $charset_collate";
58
59
    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
0 ignored issues
show
Bug introduced by
The constant ABSPATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
60
    dbDelta($sql);
0 ignored issues
show
Bug introduced by
The function dbDelta was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

60
    /** @scrutinizer ignore-call */ 
61
    dbDelta($sql);
Loading history...
61
}
62
63
function createLogsTable()
64
{
65
    global $wpdb;
66
    $charset_collate = $wpdb->get_charset_collate();
67
    $LogsTableName   = $wpdb->prefix . PG_LOGS_TABLE_NAME;
68
    $sqlQuery        = "CREATE TABLE $LogsTableName ( 
69
    id int NOT NULL AUTO_INCREMENT,
70
    log text NOT NULL, 
71
    createdAt timestamp DEFAULT CURRENT_TIMESTAMP,
72
    UNIQUE KEY id (id)) 
73
    $charset_collate";
74
    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
0 ignored issues
show
Bug introduced by
The constant ABSPATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
75
    dbDelta($sqlQuery);
0 ignored issues
show
Bug introduced by
The function dbDelta was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

75
    /** @scrutinizer ignore-call */ 
76
    dbDelta($sqlQuery);
Loading history...
76
}
77
78
/**
79
 * @param null $exception
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $exception is correct as it would always require null to be passed?
Loading history...
80
 * @param null $message
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $message is correct as it would always require null to be passed?
Loading history...
81
 */
82
function insertLogEntry($exception = null, $message = null)
83
{
84
    global $wpdb;
85
    if (! isPgTableCreated(PG_LOGS_TABLE_NAME)) {
86
        createLogsTable();
87
    }
88
    $logEntry = new Pagantis\ModuleUtils\Model\Log\LogEntry();
89
    if ($exception instanceof \Exception) {
90
        $logEntry = $logEntry->error($exception);
91
    } else {
92
        $logEntry = $logEntry->info($message);
93
    }
94
    $tableName = $wpdb->prefix . PG_LOGS_TABLE_NAME;
95
    $wpdb->insert($tableName, array('log' => $logEntry->toJson()));
96
}
97
98
/**
99
 * @return bool
100
 */
101
function areDecimalSeparatorEqual()
102
{
103
    $pgDecimalSeparator = getPgSimulatorDecimalSeparatorConfig();
104
    $wc_decimal_sep     = get_option('woocommerce_price_decimal_sep');
0 ignored issues
show
Bug introduced by
The function get_option was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

104
    $wc_decimal_sep     = /** @scrutinizer ignore-call */ get_option('woocommerce_price_decimal_sep');
Loading history...
105
    if (stripslashes($wc_decimal_sep) == stripslashes($pgDecimalSeparator)) {
106
        return true;
107
    } else {
108
        return false;
109
    }
110
}
111
112
113
/**
114
 * @return bool
115
 */
116
function areThousandsSeparatorEqual()
117
{
118
    $pgThousandSeparator = getPgSimulatorThousandsSeparator();
119
    $wc_price_thousand   = get_option('woocommerce_price_thousand_sep');
0 ignored issues
show
Bug introduced by
The function get_option was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

119
    $wc_price_thousand   = /** @scrutinizer ignore-call */ get_option('woocommerce_price_thousand_sep');
Loading history...
120
    if (stripslashes($wc_price_thousand) == stripslashes($pgThousandSeparator)) {
121
        return true;
122
    } else {
123
        return false;
124
    }
125
}
126
127
/**
128
 * @return array|object|null
129
 */
130
function getPgSimulatorThousandsSeparator()
131
{
132
    global $wpdb;
133
    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
134
    $query     = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'";
135
    $result    = $wpdb->get_row($query, ARRAY_A);
0 ignored issues
show
Bug introduced by
The constant ARRAY_A was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
136
137
    return $result['value'];
138
}
139
140
/**
141
 * @return array|object|null
142
 */
143
function getPgSimulatorDecimalSeparatorConfig()
144
{
145
    global $wpdb;
146
    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
147
    $query     = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'";
148
    $result    = $wpdb->get_row($query, ARRAY_A);
0 ignored issues
show
Bug introduced by
The constant ARRAY_A was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
149
150
    return $result['value'];
151
}
152
153
function updateThousandsSeparatorDbConfig()
154
{
155
    global $wpdb;
156
    if (areThousandsSeparatorEqual()) {
157
        return;
158
    }
159
    $tableName         = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
160
    $thousandSeparator = get_option('woocommerce_price_thousand_sep');
0 ignored issues
show
Bug introduced by
The function get_option was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

160
    $thousandSeparator = /** @scrutinizer ignore-call */ get_option('woocommerce_price_thousand_sep');
Loading history...
161
    $wpdb->update(
162
        $tableName,
163
        array('value' => $thousandSeparator),
164
        array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'),
165
        array('%s'),
166
        array('%s')
167
    );
168
}
169
170
function updateDecimalSeparatorDbConfig()
171
{
172
    global $wpdb;
173
    if (areDecimalSeparatorEqual()) {
174
        return;
175
    }
176
    $tableName        = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
177
    $decimalSeparator = get_option('woocommerce_price_decimal_sep');
0 ignored issues
show
Bug introduced by
The function get_option was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

177
    $decimalSeparator = /** @scrutinizer ignore-call */ get_option('woocommerce_price_decimal_sep');
Loading history...
178
    $wpdb->update(
179
        $tableName,
180
        array('value' => $decimalSeparator),
181
        array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'),
182
        array('%s'),
183
        array('%s')
184
    );
185
}
186
187
188
/**
189
 * @param $simulatorType
190
 * @param $validSimulatorTypes array
191
 *
192
 * @return bool
193
 */
194
function isSimulatorTypeValid($simulatorType, $validSimulatorTypes)
195
{
196
    if (! in_array($simulatorType, $validSimulatorTypes)) {
197
        return false;
198
    }
199
200
    return true;
201
}
202
203
/**
204
 * @param $currentTemplateName
205
 *
206
 * @param $validTemplateNames array
207
 *
208
 * @return bool
209
 */
210
function isTemplatePresent($currentTemplateName, $validTemplateNames)
211
{
212
    if (in_array($currentTemplateName, $validTemplateNames)) {
213
        return true;
214
    }
215
216
    return false;
217
}
218
219
220
function areMerchantKeysSet()
221
{
222
    $settings   = get_option('woocommerce_pagantis_settings');
0 ignored issues
show
Bug introduced by
The function get_option was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

222
    $settings   = /** @scrutinizer ignore-call */ get_option('woocommerce_pagantis_settings');
Loading history...
223
    $publicKey  = ! empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : '';
224
    $privateKey = ! empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : '';
225
    if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) {
226
        return false;
227
    }
228
229
    return true;
230
}
231
232
function areMerchantKeysSet4x()
233
{
234
    $settings   = get_option('woocommerce_pagantis_settings');
0 ignored issues
show
Bug introduced by
The function get_option was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

234
    $settings   = /** @scrutinizer ignore-call */ get_option('woocommerce_pagantis_settings');
Loading history...
235
    $publicKey  = ! empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : '';
236
    $privateKey = ! empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : '';
237
    if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) {
238
        return false;
239
    }
240
241
    return true;
242
}
243
244
function isSimulatorEnabled()
245
{
246
    $settings = get_option('woocommerce_pagantis_settings');
0 ignored issues
show
Bug introduced by
The function get_option was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

246
    $settings = /** @scrutinizer ignore-call */ get_option('woocommerce_pagantis_settings');
Loading history...
247
    if ((! empty($settings['simulator']) && 'yes' === $settings['simulator']) ? true : false) {
248
        return true;
249
    }
250
251
    return false;
252
}
253
254
function isPluginEnabled()
255
{
256
    $settings = get_option('woocommerce_pagantis_settings');
0 ignored issues
show
Bug introduced by
The function get_option was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

256
    $settings = /** @scrutinizer ignore-call */ get_option('woocommerce_pagantis_settings');
Loading history...
257
258
    return (! empty($settings['enabled']) && 'yes' === $settings['enabled']);
259
}
260
261
function isPluginEnabled4x()
262
{
263
    $settings = get_option('woocommerce_pagantis_settings');
0 ignored issues
show
Bug introduced by
The function get_option was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

263
    $settings = /** @scrutinizer ignore-call */ get_option('woocommerce_pagantis_settings');
Loading history...
264
    return (! empty($settings['enabled_4x']) && 'yes' === $settings['enabled_4x']);
265
}
266
267
268
function isCountryShopContextValid()
269
{
270
    $locale           = strtolower(strstr(get_locale(), '_', true));
0 ignored issues
show
Bug introduced by
The function get_locale was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

270
    $locale           = strtolower(strstr(/** @scrutinizer ignore-call */ get_locale(), '_', true));
Loading history...
271
    $allowedCountries = maybe_unserialize(getConfigValue('PAGANTIS_ALLOWED_COUNTRIES'));
0 ignored issues
show
Bug introduced by
The function maybe_unserialize was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

271
    $allowedCountries = /** @scrutinizer ignore-call */ maybe_unserialize(getConfigValue('PAGANTIS_ALLOWED_COUNTRIES'));
Loading history...
272
    if (! in_array(strtolower($locale), $allowedCountries)) {
273
        return false;
274
    }
275
276
    return true;
277
}
278
279
/**
280
 * @return bool
281
 */
282
function isProductAmountValid()
283
{
284
    $minAmount = getConfigValue('PAGANTIS_DISPLAY_MIN_AMOUNT');
285
    $maxAmount = getConfigValue('PAGANTIS_DISPLAY_MAX_AMOUNT');
286
    global $product;
287
    if (method_exists($product, 'get_price')) {
288
        $productPrice = $product->get_price();
289
        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0'));
290
        if ($validAmount) {
291
            return true;
292
        }
293
    }
294
295
    return false;
296
}
297
298
/**
299
 * @return bool
300
 */
301
function isProductAmountValid4x()
302
{
303
    $minAmount = getConfigValue('PAGANTIS_DISPLAY_MIN_AMOUNT_4x');
304
    $maxAmount = getConfigValue('PAGANTIS_DISPLAY_MAX_AMOUNT_4x');
305
    global $product;
306
    if (method_exists($product, 'get_price')) {
307
        $productPrice = $product->get_price();
308
        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0'));
309
        if ($validAmount) {
310
            return true;
311
        }
312
    }
313
314
    return false;
315
}
316
function getAllowedCurrencies()
317
{
318
    return array("EUR");
319
}
320
321
/**
322
 * @return array
323
 */
324
function getExtraConfig()
325
{
326
    global $wpdb;
327
    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
328
    $response  = array();
329
    $dbResult  = $wpdb->get_results("select config, value from $tableName", ARRAY_A);
0 ignored issues
show
Bug introduced by
The constant ARRAY_A was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
330
    foreach ($dbResult as $value) {
331
        $response[$value['config']] = $value['value'];
332
    }
333
334
    return $response;
335
}
336
337
function getModuleComposerVersion($moduleAbsolutePath)
338
{
339
    $maybe_composer_json = $moduleAbsolutePath . 'composer.json';
340
    if (! file_exists($maybe_composer_json) && ! is_readable($maybe_composer_json)) {
341
        return null;
342
    }
343
    $composer = json_decode(file_get_contents($maybe_composer_json));
344
    if (empty($composer->version)) {
345
        return null;
346
    }
347
348
    return $composer->version;
349
}
350
351
352
/**
353
 * @param $order
354
 *
355
 * @return null
356
 */
357
function getNationalId($order)
358
{
359
    foreach ((array)$order->get_meta_data() as $mdObject) {
360
        $data = $mdObject->get_data();
361
        if ($data['key'] == 'vat_number') {
362
            return $data['value'];
363
        }
364
    }
365
366
    return null;
367
}
368
369
/**
370
 * @param $order
371
 *
372
 * @return mixed
373
 */
374
function getTaxId($order)
375
{
376
    foreach ((array)$order->get_meta_data() as $mdObject) {
377
        $data = $mdObject->get_data();
378
        if ($data['key'] == 'billing_cfpiva') {
379
            return $data['value'];
380
        }
381
    }
382
}
383
384
385
/**
386
 * @param $product_id
387
 *
388
 * @return string
389
 */
390
function isProductPromoted($product_id)
391
{
392
    $metaProduct = get_post_meta($product_id);
0 ignored issues
show
Bug introduced by
The function get_post_meta was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

392
    $metaProduct = /** @scrutinizer ignore-call */ get_post_meta($product_id);
Loading history...
393
394
    return (array_key_exists('custom_product_pagantis_promoted', $metaProduct)
395
            && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false';
396
}
397
398
/**
399
 * @return int
400
 */
401
function getPromotedAmount()
402
{
403
    $promotedAmount = 0;
404
    foreach (WC()->cart->get_cart() as $key => $item) {
0 ignored issues
show
Bug introduced by
The function WC was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

404
    foreach (/** @scrutinizer ignore-call */ WC()->cart->get_cart() as $key => $item) {
Loading history...
405
        $promotedProduct = isProductPromoted($item['product_id']);
406
        if ($promotedProduct == 'true') {
407
            $promotedAmount += $item['line_total'] + $item['line_tax'];
408
        }
409
    }
410
411
    return $promotedAmount;
412
}
413
414
/**
415
 * @param $orderId
416
 * @param $pagantisOrderId
417
 *
418
 * @throws Exception
419
 */
420
function addOrderToCartProcessingQueue($orderId, $pagantisOrderId)
421
{
422
    global $wpdb;
423
    checkCartProcessTable();
424
    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
425
426
    //Check if id exists
427
    $resultsSelect = $wpdb->get_results("SELECT * FROM $tableName WHERE id='$orderId'");
428
    $countResults  = count($resultsSelect);
429
    if ($countResults == 0) {
430
        $wpdb->insert($tableName, array('id' => $orderId, 'order_id' => $pagantisOrderId), array('%d', '%s'));
431
    } else {
432
        $wpdb->update($tableName, array('order_id' => $pagantisOrderId), array('id' => $orderId), array('%s'), array('%d'));
433
    }
434
}
435
436
/**
437
 * Check if orders table exists
438
 */
439
function checkCartProcessTable()
440
{
441
    global $wpdb;
442
    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
443
444
    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
445
        $charset_collate = $wpdb->get_charset_collate();
446
        $sql             = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50),  
447
                  UNIQUE KEY id (id)) $charset_collate";
448
449
        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
0 ignored issues
show
Bug introduced by
The constant ABSPATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
450
        dbDelta($sql);
0 ignored issues
show
Bug introduced by
The function dbDelta was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

450
        /** @scrutinizer ignore-call */ 
451
        dbDelta($sql);
Loading history...
451
    }
452
}
453
454
455
/**
456
 * Get the orders of a customer
457
 *
458
 * @param WP_User $current_user
0 ignored issues
show
Bug introduced by
The type WP_User was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
459
 * @param $billingEmail
460
 *
461
 * @return mixed
462
 * @uses Wordpress Core Post API
463
 */
464
function getOrders($current_user, $billingEmail)
465
{
466
    $sign_up         = '';
467
    $total_orders    = 0;
0 ignored issues
show
Unused Code introduced by
The assignment to $total_orders is dead and can be removed.
Loading history...
468
    $total_amt       = 0;
0 ignored issues
show
Unused Code introduced by
The assignment to $total_amt is dead and can be removed.
Loading history...
469
    $refund_amt      = 0;
0 ignored issues
show
Unused Code introduced by
The assignment to $refund_amt is dead and can be removed.
Loading history...
470
    $total_refunds   = 0;
0 ignored issues
show
Unused Code introduced by
The assignment to $total_refunds is dead and can be removed.
Loading history...
471
    $partial_refunds = 0;
0 ignored issues
show
Unused Code introduced by
The assignment to $partial_refunds is dead and can be removed.
Loading history...
472
    if ($current_user->user_login) {
473
        $is_guest        = "false";
0 ignored issues
show
Unused Code introduced by
The assignment to $is_guest is dead and can be removed.
Loading history...
474
        $sign_up         = substr($current_user->user_registered, 0, 10);
0 ignored issues
show
Unused Code introduced by
The assignment to $sign_up is dead and can be removed.
Loading history...
475
        $customer_orders = get_posts(array(
0 ignored issues
show
Bug introduced by
The function get_posts was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

475
        $customer_orders = /** @scrutinizer ignore-call */ get_posts(array(
Loading history...
476
            'numberposts' => -1,
477
            'meta_key'    => '_customer_user',
478
            'meta_value'  => $current_user->ID,
479
            'post_type'   => array('shop_order'),
480
            'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
481
        ));
482
    } else {
483
        $is_guest        = "true";
484
        $customer_orders = get_posts(array(
485
            'numberposts' => -1,
486
            'meta_key'    => '_billing_email',
487
            'meta_value'  => $billingEmail,
488
            'post_type'   => array('shop_order'),
489
            'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
490
        ));
491
        foreach ($customer_orders as $customer_order) {
492
            if (trim($sign_up) == '' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) {
493
                $sign_up = substr($customer_order->post_date, 0, 10);
494
            }
495
        }
496
    }
497
498
    return $customer_orders;
499
}
500
501
function isPagePaymentPage()
502
{
503
    return (is_checkout() && ! is_order_received_page()) || is_checkout_pay_page();
0 ignored issues
show
Bug introduced by
The function is_order_received_page was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

503
    return (is_checkout() && ! /** @scrutinizer ignore-call */ is_order_received_page()) || is_checkout_pay_page();
Loading history...
Bug introduced by
The function is_checkout_pay_page was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

503
    return (is_checkout() && ! is_order_received_page()) || /** @scrutinizer ignore-call */ is_checkout_pay_page();
Loading history...
Bug introduced by
The function is_checkout was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

503
    return (/** @scrutinizer ignore-call */ is_checkout() && ! is_order_received_page()) || is_checkout_pay_page();
Loading history...
504
}
505