Passed
Pull Request — master (#82)
by
unknown
03:14
created
includes/pg-functions.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@  discard block
 block discarded – undo
4 4
 
5 5
 function requireWPPluginFunctions()
6 6
 {
7
-    if ( ! function_exists('is_plugin_active')) {
8
-        require_once(ABSPATH . 'wp-admin/includes/plugin.php');
7
+    if (!function_exists('is_plugin_active')) {
8
+        require_once(ABSPATH.'wp-admin/includes/plugin.php');
9 9
     }
10 10
 }
11 11
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 function getConfigValue($configKey)
24 24
 {
25 25
     global $wpdb;
26
-    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
26
+    $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
27 27
     $value     = $wpdb->get_var($wpdb->prepare("SELECT value FROM $tableName WHERE config= %s ", $configKey));
28 28
 
29 29
     return $value;
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 function isPgTableCreated($tableToCheck)
41 41
 {
42 42
     global $wpdb;
43
-    $tableName = $wpdb->prefix . $tableToCheck;
44
-    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) {
43
+    $tableName = $wpdb->prefix.$tableToCheck;
44
+    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")==$tableName) {
45 45
         return true;
46 46
     }
47 47
 
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
 {
54 54
     global $wpdb;
55 55
     $charset_collate = $wpdb->get_charset_collate();
56
-    $LogsTableName   = $wpdb->prefix . PG_LOGS_TABLE_NAME;
56
+    $LogsTableName   = $wpdb->prefix.PG_LOGS_TABLE_NAME;
57 57
     $sqlQuery        = "CREATE TABLE $LogsTableName ( 
58 58
     id int NOT NULL AUTO_INCREMENT,
59 59
     log text NOT NULL, 
60 60
     createdAt timestamp DEFAULT CURRENT_TIMESTAMP,
61 61
     UNIQUE KEY id (id)) 
62 62
     $charset_collate";
63
-    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
63
+    require_once(ABSPATH.'wp-admin/includes/upgrade.php');
64 64
     dbDelta($sqlQuery);
65 65
 }
66 66
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 function insertLogEntry($exception = null, $message = null)
72 72
 {
73 73
     global $wpdb;
74
-    if ( ! isPgTableCreated(PG_LOGS_TABLE_NAME)) {
74
+    if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) {
75 75
         createLogsTable();
76 76
     }
77 77
     $logEntry = new Pagantis\ModuleUtils\Model\Log\LogEntry();
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     } else {
81 81
         $logEntry = $logEntry->info($message);
82 82
     }
83
-    $tableName = $wpdb->prefix . PG_LOGS_TABLE_NAME;
83
+    $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME;
84 84
     $wpdb->insert($tableName, array('log' => $logEntry->toJson()));
85 85
 }
86 86
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 {
92 92
     $pgDecimalSeparator = getPgSimulatorDecimalSeparatorConfig();
93 93
     $wc_decimal_sep     = get_option('woocommerce_price_decimal_sep');
94
-    if (stripslashes($wc_decimal_sep) == stripslashes($pgDecimalSeparator)) {
94
+    if (stripslashes($wc_decimal_sep)==stripslashes($pgDecimalSeparator)) {
95 95
         return true;
96 96
     } else {
97 97
         return false;
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 {
107 107
     $pgThousandSeparator = getPgSimulatorThousandsSeparator();
108 108
     $wc_price_thousand   = get_option('woocommerce_price_thousand_sep');
109
-    if (stripslashes($wc_price_thousand) == stripslashes($pgThousandSeparator)) {
109
+    if (stripslashes($wc_price_thousand)==stripslashes($pgThousandSeparator)) {
110 110
         return true;
111 111
     } else {
112 112
         return false;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 function getPgSimulatorThousandsSeparator()
120 120
 {
121 121
     global $wpdb;
122
-    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
122
+    $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
123 123
     $query     = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'";
124 124
     $result    = $wpdb->get_row($query, ARRAY_A);
125 125
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 function getPgSimulatorDecimalSeparatorConfig()
133 133
 {
134 134
     global $wpdb;
135
-    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
135
+    $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
136 136
     $query     = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'";
137 137
     $result    = $wpdb->get_row($query, ARRAY_A);
138 138
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     if (areThousandsSeparatorEqual()) {
146 146
         return;
147 147
     }
148
-    $tableName         = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
148
+    $tableName         = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
149 149
     $thousandSeparator = get_option('woocommerce_price_thousand_sep');
150 150
     $wpdb->update($tableName, array('value' => $thousandSeparator), array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'),
151 151
         array('%s'), array('%s'));
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     if (areDecimalSeparatorEqual()) {
158 158
         return;
159 159
     }
160
-    $tableName        = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
160
+    $tableName        = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
161 161
     $decimalSeparator = get_option('woocommerce_price_decimal_sep');
162 162
     $wpdb->update($tableName, array('value' => $decimalSeparator), array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'),
163 163
         array('%s'), array('%s'));
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
  */
173 173
 function isSimulatorTypeValid($simulatorType, $validSimulatorTypes)
174 174
 {
175
-    if ( ! in_array($simulatorType, $validSimulatorTypes)) {
175
+    if (!in_array($simulatorType, $validSimulatorTypes)) {
176 176
         return false;
177 177
     }
178 178
 
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 function areMerchantKeysSet()
200 200
 {
201 201
     $settings   = get_option('woocommerce_pagantis_settings');
202
-    $publicKey  = ! empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : '';
203
-    $privateKey = ! empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : '';
202
+    $publicKey  = !empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : '';
203
+    $privateKey = !empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : '';
204 204
     if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) {
205 205
         return false;
206 206
     }
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
 function areMerchantKeysSet4x()
212 212
 {
213 213
     $settings   = get_option('woocommerce_pagantis_settings');
214
-    $publicKey  = ! empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : '';
215
-    $privateKey = ! empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : '';
214
+    $publicKey  = !empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : '';
215
+    $privateKey = !empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : '';
216 216
     if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) {
217 217
         return false;
218 218
     }
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 function isSimulatorEnabled()
224 224
 {
225 225
     $settings = get_option('woocommerce_pagantis_settings');
226
-    if (( ! empty($settings['simulator']) && 'yes' === $settings['simulator']) ? true : false) {
226
+    if ((!empty($settings['simulator']) && 'yes'===$settings['simulator']) ? true : false) {
227 227
         return true;
228 228
     }
229 229
 
@@ -234,14 +234,14 @@  discard block
 block discarded – undo
234 234
 {
235 235
     $settings = get_option('woocommerce_pagantis_settings');
236 236
 
237
-    return ( ! empty($settings['enabled']) && 'yes' === $settings['enabled']);
237
+    return (!empty($settings['enabled']) && 'yes'===$settings['enabled']);
238 238
 }
239 239
 
240 240
 function isPluginEnabled4x()
241 241
 {
242 242
     $settings = get_option('woocommerce_pagantis_settings');
243 243
 
244
-    return ( ! empty($settings['enabled_4x']) && 'yes' === $settings['enabled_4x']);
244
+    return (!empty($settings['enabled_4x']) && 'yes'===$settings['enabled_4x']);
245 245
 }
246 246
 
247 247
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 {
250 250
     $locale           = strtolower(strstr(get_locale(), '_', true));
251 251
     $allowedCountries = maybe_unserialize(getConfigValue('PAGANTIS_ALLOWED_COUNTRIES'));
252
-    if ( ! in_array(strtolower($locale), $allowedCountries)) {
252
+    if (!in_array(strtolower($locale), $allowedCountries)) {
253 253
         return false;
254 254
     }
255 255
 
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
     global $product;
267 267
     if (method_exists($product, 'get_price')) {
268 268
         $productPrice = $product->get_price();
269
-        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0'));
269
+        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0'));
270 270
         if ($validAmount) {
271 271
             return true;
272 272
         }
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
     global $product;
286 286
     if (method_exists($product, 'get_price')) {
287 287
         $productPrice = $product->get_price();
288
-        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0'));
288
+        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0'));
289 289
         if ($validAmount) {
290 290
             return true;
291 291
         }
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 function getExtraConfig()
306 306
 {
307 307
     global $wpdb;
308
-    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
308
+    $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
309 309
     $response  = array();
310 310
     $dbResult  = $wpdb->get_results("select config, value from $tableName", ARRAY_A);
311 311
     foreach ($dbResult as $value) {
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
 function getModuleVersion()
319 319
 {
320
-    $mainFile = plugin_dir_path(PG_WC_MAIN_FILE) . '/WC_Pagantis.php';
320
+    $mainFile = plugin_dir_path(PG_WC_MAIN_FILE).'/WC_Pagantis.php';
321 321
     $version  = get_file_data($mainFile, array('Version' => 'Version'), false);
322 322
 
323 323
     return $version['Version'];
@@ -330,9 +330,9 @@  discard block
 block discarded – undo
330 330
  */
331 331
 function getNationalId($order)
332 332
 {
333
-    foreach ((array)$order->get_meta_data() as $mdObject) {
333
+    foreach ((array) $order->get_meta_data() as $mdObject) {
334 334
         $data = $mdObject->get_data();
335
-        if ($data['key'] == 'vat_number') {
335
+        if ($data['key']=='vat_number') {
336 336
             return $data['value'];
337 337
         }
338 338
     }
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
  */
348 348
 function getTaxId($order)
349 349
 {
350
-    foreach ((array)$order->get_meta_data() as $mdObject) {
350
+    foreach ((array) $order->get_meta_data() as $mdObject) {
351 351
         $data = $mdObject->get_data();
352
-        if ($data['key'] == 'billing_cfpiva') {
352
+        if ($data['key']=='billing_cfpiva') {
353 353
             return $data['value'];
354 354
         }
355 355
     }
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
     $metaProduct = get_post_meta($product_id);
367 367
 
368 368
     return (array_key_exists('custom_product_pagantis_promoted', $metaProduct)
369
-            && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false';
369
+            && $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false';
370 370
 }
371 371
 
372 372
 /**
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
     $promotedAmount = 0;
378 378
     foreach (WC()->cart->get_cart() as $key => $item) {
379 379
         $promotedProduct = isProductPromoted($item['product_id']);
380
-        if ($promotedProduct == 'true') {
380
+        if ($promotedProduct=='true') {
381 381
             $promotedAmount += $item['line_total'] + $item['line_tax'];
382 382
         }
383 383
     }
@@ -396,8 +396,8 @@  discard block
 block discarded – undo
396 396
 function addOrderToCartProcessingQueue($cartHash, $pagantisOrderId, $wcOrderID, $origin = null, $token = null)
397 397
 {
398 398
     global $wpdb;
399
-    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
400
-    if ( ! is_null($token)) {
399
+    $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
400
+    if (!is_null($token)) {
401 401
         $wpdb->insert($tableName, array(
402 402
             'id'          => $cartHash,
403 403
             'order_id'    => $pagantisOrderId,
@@ -417,10 +417,10 @@  discard block
 block discarded – undo
417 417
 function alterCartProcessingTable()
418 418
 {
419 419
     global $wpdb;
420
-    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
421
-    if ( ! $wpdb->get_var("SHOW COLUMNS FROM `{$tableName}` LIKE 'token'")) {
420
+    $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
421
+    if (!$wpdb->get_var("SHOW COLUMNS FROM `{$tableName}` LIKE 'token'")) {
422 422
         $wpdb->query("ALTER TABLE $tableName ADD COLUMN origin VARCHAR(50) NOT NULL,`token` VARCHAR(32) NOT NULL AFTER `wc_order_id`");
423
-        pagantisLogger::log(PG_CART_PROCESS_TABLE . " ALTERED " .  "on " . __LINE__ . " in " . __FILE__);
423
+        pagantisLogger::log(PG_CART_PROCESS_TABLE." ALTERED "."on ".__LINE__." in ".__FILE__);
424 424
         $wpdb->query("ALTER TABLE $tableName DROP PRIMARY KEY, ADD PRIMARY KEY(`id`, `token`)");
425 425
     }
426 426
     wp_cache_flush();
@@ -432,10 +432,10 @@  discard block
 block discarded – undo
432 432
 function createCartProcessingTable()
433 433
 {
434 434
     global $wpdb;
435
-    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
435
+    $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
436 436
 
437
-    if ( ! isPgTableCreated(PG_CART_PROCESS_TABLE)) {
438
-        pagantisLogger::log(PG_CART_PROCESS_TABLE . " CREATED " .  "on " . __LINE__ . " in " . __FILE__);
437
+    if (!isPgTableCreated(PG_CART_PROCESS_TABLE)) {
438
+        pagantisLogger::log(PG_CART_PROCESS_TABLE." CREATED "."on ".__LINE__." in ".__FILE__);
439 439
         $charset_collate = $wpdb->get_charset_collate();
440 440
         $sql             = "CREATE TABLE $tableName 
441 441
             (id VARCHAR(60) NOT NULL, 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
             token VARCHAR(32) NOT NULL, 
446 446
             PRIMARY KEY(id) ) $charset_collate";
447 447
 
448
-        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
448
+        require_once(ABSPATH.'wp-admin/includes/upgrade.php');
449 449
         dbDelta($sql);
450 450
     }
451 451
 }
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
             'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
488 488
         ));
489 489
         foreach ($customer_orders as $customer_order) {
490
-            if (trim($sign_up) == '' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) {
490
+            if (trim($sign_up)=='' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) {
491 491
                 $sign_up = substr($customer_order->post_date, 0, 10);
492 492
             }
493 493
         }
@@ -500,14 +500,14 @@  discard block
 block discarded – undo
500 500
 function updateCartProcessingTable()
501 501
 {
502 502
     global $wpdb;
503
-    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
503
+    $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
504 504
 
505
-    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
505
+    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
506 506
         $charset_collate = $wpdb->get_charset_collate();
507 507
         $sql             = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), token varchar(32) 
508 508
                   UNIQUE KEY id (id)) $charset_collate";
509 509
 
510
-        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
510
+        require_once(ABSPATH.'wp-admin/includes/upgrade.php');
511 511
         dbDelta($sql);
512 512
     }
513 513
 }
@@ -515,5 +515,5 @@  discard block
 block discarded – undo
515 515
 
516 516
 function isPagePaymentPage()
517 517
 {
518
-    return (is_checkout() && ! is_order_received_page()) || is_checkout_pay_page();
518
+    return (is_checkout() && !is_order_received_page()) || is_checkout_pay_page();
519 519
 }
Please login to merge, or discard this patch.
includes/logger.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -42,23 +42,23 @@  discard block
 block discarded – undo
42 42
             }
43 43
 
44 44
             if (!is_null($start_time)) {
45
-                $formatted_start_time = date_i18n(get_option('date_format') . ' g:ia', $start_time);
45
+                $formatted_start_time = date_i18n(get_option('date_format').' g:ia', $start_time);
46 46
                 $end_time = is_null($end_time) ? current_time('timestamp') : $end_time;
47
-                $formatted_end_time = date_i18n(get_option('date_format') . ' g:ia', $end_time);
47
+                $formatted_end_time = date_i18n(get_option('date_format').' g:ia', $end_time);
48 48
                 $elapsed_time = round(abs($end_time - $start_time) / 60, 2);
49 49
 
50
-                $log_entry = "\n" . '====Pagantis Version: ' . '====' . "\n";
51
-                $log_entry .= '====Start Log ' . $formatted_start_time . '====' . "\n" . $message . "\n";
52
-                $log_entry .= '====End Log ' . $formatted_end_time . ' (' . $elapsed_time . ')====' . "\n\n";
50
+                $log_entry = "\n".'====Pagantis Version: '.'===='."\n";
51
+                $log_entry .= '====Start Log '.$formatted_start_time.'===='."\n".$message."\n";
52
+                $log_entry .= '====End Log '.$formatted_end_time.' ('.$elapsed_time.')===='."\n\n";
53 53
             } else {
54
-                $log_entry = "\n" . '====Pagantis LOG ====' . PHP_EOL;
55
-                $log_entry .= date_i18n('M j, Y @ G:i' , strtotime( 'now' ), true ) . PHP_EOL;
56
-                $log_entry .= json_encode($message, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ) . PHP_EOL;
54
+                $log_entry = "\n".'====Pagantis LOG ===='.PHP_EOL;
55
+                $log_entry .= date_i18n('M j, Y @ G:i', strtotime('now'), true).PHP_EOL;
56
+                $log_entry .= json_encode($message, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT).PHP_EOL;
57 57
                 $log_entry .= PHP_EOL;
58 58
             }
59 59
 
60 60
             if (version_compare(WC_VERSION, 3.0, '<')) {
61
-                self::$logger->add(self::PG_LOG_FILENAME, json_encode($log_entry, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ) );
61
+                self::$logger->add(self::PG_LOG_FILENAME, json_encode($log_entry, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
62 62
             } else {
63 63
                 self::$logger->debug($log_entry, array('source' => self::PG_LOG_FILENAME));
64 64
             }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             $out .= "<pre>";
75 75
         }
76 76
         foreach ($d as $i => $r) {
77
-            if (!$show_first && $i == 0) {
77
+            if (!$show_first && $i==0) {
78 78
                 continue;
79 79
             }
80 80
             // sometimes there is undefined index 'file'
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         $result = '';
106 106
         $length = strlen($str);
107 107
         for ($i = 0; $i < $length; $i++) {
108
-            $result .= ($str[$i] === $lowerCase[$i] ? '' : $delimiter) . $lowerCase[$i];
108
+            $result .= ($str[$i]===$lowerCase[$i] ? '' : $delimiter).$lowerCase[$i];
109 109
         }
110 110
         return $result;
111 111
     }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
     public static function toJson($initialResponse)
125 125
     {
126
-        if (!is_array($initialResponse)){
126
+        if (!is_array($initialResponse)) {
127 127
             return;
128 128
         }
129 129
         $response = self::jsonSerialize($initialResponse);
Please login to merge, or discard this patch.
controllers/notifyController.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -226,11 +226,11 @@
 block discarded – undo
226 226
 
227 227
         if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM
228 228
             $logMessage = "WARNING checkMerchantOrderStatus." .
229
-                          " Merchant order id:".$this->woocommerceOrder->get_id().
230
-                          " Merchant order status:".$this->woocommerceOrder->get_status().
231
-                          " Pagantis order id:".$this->pagantisOrder->getStatus().
232
-                          " Pagantis order status:".$this->pagantisOrder->getId().
233
-                          " Pagantis urlToken: ".$this->token;
229
+                            " Merchant order id:".$this->woocommerceOrder->get_id().
230
+                            " Merchant order status:".$this->woocommerceOrder->get_status().
231
+                            " Pagantis order id:".$this->pagantisOrder->getStatus().
232
+                            " Pagantis order status:".$this->pagantisOrder->getId().
233
+                            " Pagantis urlToken: ".$this->token;
234 234
             
235 235
             $this->insertLog(null, $logMessage);
236 236
             $this->woocommerceOrder->add_order_note($logMessage);
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         try {
69 69
             require_once(__ROOT__.'/vendor/autoload.php');
70 70
             try {
71
-                if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_GET['origin'] == 'notification') {
71
+                if ($_SERVER['REQUEST_METHOD']=='GET' && $_GET['origin']=='notification') {
72 72
                     return $this->buildResponse();
73 73
                 }
74 74
                 $this->checkConcurrency();
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     private function checkConcurrency()
118 118
     {
119 119
         $this->woocommerceOrderId = $_GET['order-received'];
120
-        if ($this->woocommerceOrderId == '') {
120
+        if ($this->woocommerceOrderId=='') {
121 121
             throw new QuoteNotFoundException();
122 122
         }
123 123
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     private function getProductType()
132 132
     {
133
-        if ($_GET['product'] == '') {
133
+        if ($_GET['product']=='') {
134 134
             $this->setProduct(WcPagantisGateway::METHOD_ID);
135 135
         } else {
136 136
             $this->setProduct($_GET['product']);
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         $queryResult = $wpdb->get_row("SELECT order_id FROM $tableName WHERE token='{$this->token}'");
162 162
         $this->pagantisOrderId = $queryResult->order_id;
163 163
 
164
-        if ($this->pagantisOrderId == '') {
164
+        if ($this->pagantisOrderId=='') {
165 165
             throw new NoIdentificationException();
166 166
         }
167 167
     }
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
                 $status = '-';
205 205
             }
206 206
 
207
-            if ($status === Order::STATUS_CONFIRMED) {
207
+            if ($status===Order::STATUS_CONFIRMED) {
208 208
                 return true;
209 209
             }
210 210
             throw new WrongStatusException($status);
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         );
226 226
 
227 227
         if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM
228
-            $logMessage = "WARNING checkMerchantOrderStatus." .
228
+            $logMessage = "WARNING checkMerchantOrderStatus.".
229 229
                           " Merchant order id:".$this->woocommerceOrder->get_id().
230 230
                           " Merchant order status:".$this->woocommerceOrder->get_status().
231 231
                           " Pagantis order id:".$this->pagantisOrder->getStatus().
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
     {
249 249
         $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount();
250 250
         $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total()));
251
-        if ($pagantisAmount != $wcAmount) {
251
+        if ($pagantisAmount!=$wcAmount) {
252 252
             throw new AmountMismatchException($pagantisAmount, $wcAmount);
253 253
         }
254 254
     }
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
             $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId);
273 273
         } catch (\Exception $e) {
274 274
             $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId);
275
-            if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) {
275
+            if ($this->pagantisOrder->getStatus()!==Order::STATUS_CONFIRMED) {
276 276
                 throw new UnknownException($e->getMessage());
277 277
             } else {
278 278
                 $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process';
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
      */
295 295
     private function checkDbTable()
296 296
     {
297
-        if (isPgTableCreated(PG_CART_PROCESS_TABLE)){
297
+        if (isPgTableCreated(PG_CART_PROCESS_TABLE)) {
298 298
             alterCartProcessingTable();
299
-        } else{
299
+        } else {
300 300
             createCartProcessingTable();
301 301
         }
302 302
     }
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
         global $wpdb;
310 310
         $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME;
311 311
 
312
-        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
312
+        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
313 313
             $charset_collate = $wpdb->get_charset_collate();
314 314
             $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, 
315 315
                     createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate";
@@ -366,12 +366,12 @@  discard block
 block discarded – undo
366 366
             $metadataOrder = $this->pagantisOrder->getMetadata();
367 367
             $metadataInfo = null;
368 368
             foreach ($metadataOrder as $metadataKey => $metadataValue) {
369
-                if ($metadataKey == 'promotedProduct') {
370
-                    $metadataInfo.= "/Producto promocionado = $metadataValue";
369
+                if ($metadataKey=='promotedProduct') {
370
+                    $metadataInfo .= "/Producto promocionado = $metadataValue";
371 371
                 }
372 372
             }
373 373
 
374
-            if ($metadataInfo != null) {
374
+            if ($metadataInfo!=null) {
375 375
                 $this->woocommerceOrder->add_order_note($metadataInfo);
376 376
             }
377 377
 
@@ -440,13 +440,13 @@  discard block
 block discarded – undo
440 440
     {
441 441
         global $wpdb;
442 442
         $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME;
443
-        if ($orderId == null) {
443
+        if ($orderId==null) {
444 444
             $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT." SECOND)";
445 445
         } else {
446 446
             $query = "DELETE FROM $tableName WHERE order_id = $orderId";
447 447
         }
448 448
         $resultDelete = $wpdb->query($query);
449
-        if ($resultDelete === false) {
449
+        if ($resultDelete===false) {
450 450
             throw new ConcurrencyException();
451 451
         }
452 452
     }
@@ -461,8 +461,8 @@  discard block
 block discarded – undo
461 461
         global $wpdb;
462 462
         $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME;
463 463
         $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId));
464
-        if ($insertResult === false) {
465
-            if ($this->getOrigin() == 'Notify') {
464
+        if ($insertResult===false) {
465
+            if ($this->getOrigin()=='Notify') {
466 466
                 throw new ConcurrencyException();
467 467
             } else {
468 468
                 $query = sprintf(
@@ -473,8 +473,8 @@  discard block
 block discarded – undo
473 473
                 );
474 474
                 $resultSeconds = $wpdb->get_row($query);
475 475
                 $restSeconds = isset($resultSeconds) ? ($resultSeconds->rest) : 0;
476
-                $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;
477
-                sleep($secondsToExpire+1);
476
+                $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;
477
+                sleep($secondsToExpire + 1);
478 478
 
479 479
                 $logMessage = sprintf(
480 480
                     "User waiting %s seconds, default seconds %s, bd time to expire %s seconds",
@@ -498,10 +498,10 @@  discard block
 block discarded – undo
498 498
     {
499 499
         $this->unblockConcurrency($this->woocommerceOrderId);
500 500
         $this->setToken($_GET['token']);
501
-        pagantisLogger::log( " token " . $_GET['token'] .  "on " . __LINE__ . " in " . __FILE__);
502
-        pagantisLogger::log( " token " . $this->token .  "on " . __LINE__ . " in " . __FILE__);
501
+        pagantisLogger::log(" token ".$_GET['token']."on ".__LINE__." in ".__FILE__);
502
+        pagantisLogger::log(" token ".$this->token."on ".__LINE__." in ".__FILE__);
503 503
 
504
-        if ($exception == null) {
504
+        if ($exception==null) {
505 505
             $jsonResponse = new JsonSuccessResponse();
506 506
         } else {
507 507
             $jsonResponse = new JsonExceptionResponse();
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
         $jsonResponse->setMerchantOrderId($this->woocommerceOrderId);
511 511
         $jsonResponse->setPagantisOrderId($this->pagantisOrderId);
512 512
 
513
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
513
+        if ($_SERVER['REQUEST_METHOD']=='POST') {
514 514
             $jsonResponse->printResponse();
515 515
         } else {
516 516
             return $jsonResponse;
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
      */
543 543
     private function isProduct4x()
544 544
     {
545
-        return ($this->product === Ucfirst(WcPagantis4xGateway::METHOD_ID));
545
+        return ($this->product===Ucfirst(WcPagantis4xGateway::METHOD_ID));
546 546
     }
547 547
 
548 548
     /**
Please login to merge, or discard this patch.
controllers/paymentController.php 1 patch
Spacing   +49 added lines, -52 removed lines patch added patch discarded remove patch
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
         $this->method_title = ucfirst($this->id);
59 59
 
60 60
         //Useful vars
61
-        $this->template_path = plugin_dir_path(__FILE__) . '../templates/';
61
+        $this->template_path = plugin_dir_path(__FILE__).'../templates/';
62 62
         $this->allowed_currencies = getAllowedCurrencies();
63
-        $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Pagantis.php';
63
+        $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)).'/WC_Pagantis.php';
64 64
         $this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false);
65 65
         $this->language = strstr(get_locale(), '_', true);
66 66
         if ($this->language=='') {
@@ -69,25 +69,25 @@  discard block
 block discarded – undo
69 69
         $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg';
70 70
 
71 71
         //Panel form fields
72
-        $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options
72
+        $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options
73 73
         $this->init_settings();
74 74
 
75 75
         $this->extraConfig = getExtraConfig();
76 76
         $this->title = __($this->extraConfig['PAGANTIS_TITLE'], 'pagantis');
77 77
         $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis.";
78 78
 
79
-        $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl();
80
-        $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl();
79
+        $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl();
80
+        $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl();
81 81
         foreach ($this->settings as $setting_key => $setting_value) {
82 82
             $this->$setting_key = $setting_value;
83 83
         }
84 84
 
85 85
         //Hooks
86
-        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options
87
-        add_action('admin_notices', array($this, 'pagantisCheckFields'));                          //Check config fields
88
-        add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage'));          //Pagantis form
89
-        add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification'));      //Json Notification
90
-        add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3);
86
+        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options
87
+        add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields
88
+        add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form
89
+        add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification
90
+        add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3);
91 91
         add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2);
92 92
     }
93 93
 
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function loadPagantisTranslation($mofile, $domain)
101 101
     {
102
-        if ('pagantis' === $domain) {
103
-            $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo';
102
+        if ('pagantis'===$domain) {
103
+            $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo';
104 104
         }
105 105
         return $mofile;
106 106
     }
@@ -134,24 +134,24 @@  discard block
 block discarded – undo
134 134
     public function pagantisCheckFields()
135 135
     {
136 136
         $error_string = '';
137
-        if ($this->settings['enabled'] !== 'yes') {
137
+        if ($this->settings['enabled']!=='yes') {
138 138
             return;
139 139
         } elseif (!version_compare(phpversion(), '5.3.0', '>=')) {
140
-            $error_string =  __(' is not compatible with your php and/or curl version', 'pagantis');
140
+            $error_string = __(' is not compatible with your php and/or curl version', 'pagantis');
141 141
             $this->settings['enabled'] = 'no';
142
-        } elseif (($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="")  && (empty($this->settings['pagantis_public_key_4x']) || empty($this->settings['pagantis_private_key_4x']))) {
142
+        } elseif (($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="") && (empty($this->settings['pagantis_public_key_4x']) || empty($this->settings['pagantis_private_key_4x']))) {
143 143
             $error_string = __(' is not configured correctly, the fields Public Key and Secret Key are mandatory for use this plugin', 'pagantis');
144 144
             $this->settings['enabled'] = 'no';
145 145
         } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) {
146
-            $error_string =  __(' only can be used in Euros', 'pagantis');
146
+            $error_string = __(' only can be used in Euros', 'pagantis');
147 147
             $this->settings['enabled'] = 'no';
148
-        } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']<'2'
149
-                  || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']>'12') {
148
+        } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] < '2'
149
+                  || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] > '12') {
150 150
             $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis');
151
-        } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']<'2'
152
-                  || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']>'12') {
151
+        } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] < '2'
152
+                  || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] > '12') {
153 153
             $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis');
154
-        } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']<0) {
154
+        } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] < 0) {
155 155
             $error_string = __(' can not have a minimum amount less than 0', 'pagantis');
156 156
         }
157 157
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 
185 185
             $shippingAddress = $order->get_address('shipping');
186 186
             $billingAddress = $order->get_address('billing');
187
-            if ($shippingAddress['address_1'] == '') {
187
+            if ($shippingAddress['address_1']=='') {
188 188
                 $shippingAddress = $billingAddress;
189 189
             }
190 190
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                 ->setNationalId($national_id)
212 212
                 ->setTaxId($tax_id)
213 213
             ;
214
-            $orderBillingAddress =  new Address();
214
+            $orderBillingAddress = new Address();
215 215
             $orderBillingAddress
216 216
                 ->setZipCode($billingAddress['postcode'])
217 217
                 ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name'])
@@ -284,12 +284,12 @@  discard block
 block discarded – undo
284 284
                 $details->addProduct($product);
285 285
 
286 286
                 $promotedProduct = isProductPromoted($item->get_product_id());
287
-                if ($promotedProduct == 'true') {
288
-                    $promotedAmount+=$product->getAmount();
289
-                    $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() .
290
-                                       ' - Price: ' . $item->get_total() .
291
-                                       ' - Qty: ' . $product->getQuantity() .
292
-                                       ' - Item ID: ' . $item['id_product'];
287
+                if ($promotedProduct=='true') {
288
+                    $promotedAmount += $product->getAmount();
289
+                    $promotedMessage = 'Promoted Item: '.$wcProduct->get_name().
290
+                                       ' - Price: '.$item->get_total().
291
+                                       ' - Qty: '.$product->getQuantity().
292
+                                       ' - Item ID: '.$item['id_product'];
293 293
                     $promotedMessage = substr($promotedMessage, 0, 999);
294 294
                     $metadataOrder->addMetadata('promotedProduct', $promotedMessage);
295 295
                 }
@@ -337,9 +337,7 @@  discard block
 block discarded – undo
337 337
 
338 338
             $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']);
339 339
             $purchaseCountry =
340
-                in_array(strtolower($this->language), $allowedCountries) ? $this->language :
341
-                in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] :
342
-                in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null;
340
+                in_array(strtolower($this->language), $allowedCountries) ? $this->language : in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null;
343 341
 
344 342
             $orderConfiguration = new Configuration();
345 343
             $orderConfiguration
@@ -363,7 +361,7 @@  discard block
 block discarded – undo
363 361
             $pagantisOrder = $orderClient->createOrder($orderApiClient);
364 362
             if ($pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) {
365 363
                 $url = $pagantisOrder->getActionUrls()->getForm();
366
-                addOrderToCartProcessingQueue(WC()->cart->get_cart_hash(),  $pagantisOrder->getId(),$order->get_id() , null , $urlToken);
364
+                addOrderToCartProcessingQueue(WC()->cart->get_cart_hash(), $pagantisOrder->getId(), $order->get_id(), null, $urlToken);
367 365
 
368 366
             } else {
369 367
                 throw new OrderNotFoundException();
@@ -382,7 +380,7 @@  discard block
 block discarded – undo
382 380
                 wc_get_template('iframe.php', $template_fields, '', $this->template_path);
383 381
             }
384 382
         } catch (\Exception $exception) {
385
-            wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error');
383
+            wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error');
386 384
             insertLogEntry($exception);
387 385
             pagantisLogger::log($exception);
388 386
             pagantisLogger::log(pagantisLogger::pg_debug_backtrace());
@@ -400,7 +398,7 @@  discard block
 block discarded – undo
400 398
     public function pagantisNotification()
401 399
     {
402 400
         try {
403
-            $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order';
401
+            $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order';
404 402
 
405 403
             include_once('notifyController.php');
406 404
             $notify = new WcPagantisNotify();
@@ -439,10 +437,10 @@  discard block
 block discarded – undo
439 437
      */
440 438
     public function pagantisCompleteStatus($status, $order_id, $order)
441 439
     {
442
-        if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) {
443
-            if ($order->get_status() == 'failed') {
440
+        if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) {
441
+            if ($order->get_status()=='failed') {
444 442
                 $status = 'processing';
445
-            } elseif ($order->get_status() == 'pending' && $status=='completed') {
443
+            } elseif ($order->get_status()=='pending' && $status=='completed') {
446 444
                 $status = 'processing';
447 445
             }
448 446
         }
@@ -468,8 +466,8 @@  discard block
 block discarded – undo
468 466
         $allowedCountry = (in_array(strtolower($locale), $allowedCountries));
469 467
         $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'];
470 468
         $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT'];
471
-        $totalPrice = (int)$this->get_order_total();
472
-        $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0'));
469
+        $totalPrice = (int) $this->get_order_total();
470
+        $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0'));
473 471
         if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' &&
474 472
             $validAmount && $allowedCountry) {
475 473
             return true;
@@ -502,7 +500,7 @@  discard block
 block discarded – undo
502 500
 
503 501
             $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function
504 502
             if (strpos($redirectUrl, 'order-pay=')===false) {
505
-                $redirectUrl.="&order-pay=".$order_id;
503
+                $redirectUrl .= "&order-pay=".$order_id;
506 504
             }
507 505
 
508 506
             return array(
@@ -510,7 +508,7 @@  discard block
 block discarded – undo
510 508
                 'redirect' => $redirectUrl
511 509
             );
512 510
         } catch (Exception $e) {
513
-            wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error');
511
+            wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error');
514 512
             return array();
515 513
         }
516 514
     }
@@ -579,7 +577,7 @@  discard block
 block discarded – undo
579 577
     private function generateUrl($url)
580 578
     {
581 579
         $parsed_url = parse_url($url);
582
-        if ($parsed_url !== false) {
580
+        if ($parsed_url!==false) {
583 581
             $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query'];
584 582
             parse_str($parsed_url['query'], $arrayParams);
585 583
             foreach ($arrayParams as $keyParam => $valueParam) {
@@ -627,11 +625,10 @@  discard block
 block discarded – undo
627 625
     private function getKeysUrl($order, $url)
628 626
     {
629 627
         $defaultFields = (get_class($order)=='WC_Order') ?
630
-            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) :
631
-            array();
628
+            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array();
632 629
 
633 630
         $parsedUrl = parse_url($url);
634
-        if ($parsedUrl !== false) {
631
+        if ($parsedUrl!==false) {
635 632
             //Replace parameters from url
636 633
             $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields);
637 634
 
@@ -676,7 +673,7 @@  discard block
 block discarded – undo
676 673
         foreach ($arrayParams as $keyParam => $valueParam) {
677 674
             preg_match('#\{{.*?}\}#', $valueParam, $match);
678 675
             if (count($match)) {
679
-                $key = str_replace(array('{{','}}'), array('',''), $match[0]);
676
+                $key = str_replace(array('{{', '}}'), array('', ''), $match[0]);
680 677
                 $arrayParams[$keyParam] = $defaultFields[$key];
681 678
             }
682 679
         }
@@ -691,13 +688,13 @@  discard block
 block discarded – undo
691 688
      */
692 689
     private function unparseUrl($parsed_url)
693 690
     {
694
-        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
691
+        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : '';
695 692
         $host     = isset($parsed_url['host']) ? $parsed_url['host'] : '';
696
-        $port     = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
697
-        $query    = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
698
-        $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
693
+        $port     = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : '';
694
+        $query    = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : '';
695
+        $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : '';
699 696
         $path     = $parsed_url['path'];
700
-        return $scheme . $host . $port . $path . $query . $fragment;
697
+        return $scheme.$host.$port.$path.$query.$fragment;
701 698
     }
702 699
 
703 700
 }
Please login to merge, or discard this patch.
WC_Pagantis.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 }
18 18
 
19 19
 
20
-require_once(__DIR__ . '/includes/pg-functions.php');
20
+require_once(__DIR__.'/includes/pg-functions.php');
21 21
 
22 22
 /**
23 23
  * Required minimums and constants
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
     public function __construct()
80 80
     {
81 81
         require_once(plugin_dir_path(__FILE__).'/vendor/autoload.php');
82
-        require_once(PG_ABSPATH . '/includes/pg-functions.php');
83
-        require_once(PG_ABSPATH . '/includes/logger.php');
82
+        require_once(PG_ABSPATH.'/includes/pg-functions.php');
83
+        require_once(PG_ABSPATH.'/includes/logger.php');
84 84
         $this->template_path = plugin_dir_path(__FILE__).'/templates/';
85 85
 
86 86
         $this->pagantisActivation();
@@ -97,15 +97,15 @@  discard block
 block discarded – undo
97 97
         add_action('init', array($this, 'checkWcPriceSettings'), 10);
98 98
         add_action('woocommerce_after_template_part', array($this, 'pagantisAddSimulatorHtmlDiv'), 10);
99 99
         add_action('woocommerce_single_product_summary', array($this, 'pagantisInitProductSimulator'), 20);
100
-        add_action('woocommerce_single_variation', array($this,'pagantisAddProductSnippetForVariations'), 30);
100
+        add_action('woocommerce_single_variation', array($this, 'pagantisAddProductSnippetForVariations'), 30);
101 101
         add_action('wp_enqueue_scripts', 'add_pagantis_widget_js');
102 102
         add_action('rest_api_init', array($this, 'pagantisRegisterEndpoint')); //Endpoint
103 103
         add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2);
104 104
         register_activation_hook(__FILE__, array($this, 'pagantisActivation'));
105 105
         add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl'));
106 106
         add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave'));
107
-        add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate'));
108
-        add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave'));
107
+        add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate'));
108
+        add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave'));
109 109
     }
110 110
 
111 111
     /**
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     {
132 132
         $post_id = $product->get_id();
133 133
         $pagantis_promoted_value = $_REQUEST['pagantis_promoted'];
134
-        if ($pagantis_promoted_value === 'on') {
134
+        if ($pagantis_promoted_value==='on') {
135 135
             $pagantis_promoted_value = 'yes';
136 136
         } else {
137 137
             $pagantis_promoted_value = 'no';
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
     public function pagantisPromotedVarSave($post_id)
166 166
     {
167 167
         $pagantis_promoted_value = $_POST['pagantis_promoted'];
168
-        if ($pagantis_promoted_value !== 'yes') {
168
+        if ($pagantis_promoted_value!=='yes') {
169 169
             $pagantis_promoted_value = 'no';
170 170
         }
171 171
 
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
      */
180 180
     public function loadPagantisTranslation($mofile, $domain)
181 181
     {
182
-        if ('pagantis' === $domain) {
183
-            $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo';
182
+        if ('pagantis'===$domain) {
183
+            $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo';
184 184
         }
185 185
         return $mofile;
186 186
     }
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
         global $wpdb;
203 203
 
204 204
         $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME;
205
-        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
205
+        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
206 206
             $charset_collate = $wpdb->get_charset_collate();
207 207
             $sql = "CREATE TABLE $tableName ( order_id int NOT NULL,  
208 208
                     createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate";
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
214 214
 
215 215
         //Check if table exists
216
-        $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName;
216
+        $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName;
217 217
         if ($tableExists) {
218 218
             $charset_collate = $wpdb->get_charset_collate();
219 219
             $sql = "CREATE TABLE IF NOT EXISTS $tableName (
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
             //Updated value field to adapt to new length < v8.0.1
229 229
             $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'";
230 230
             $results = $wpdb->get_results($query, ARRAY_A);
231
-            if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') {
231
+            if ($results['0']['COLUMN_TYPE']=='varchar(100)') {
232 232
                 $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)";
233 233
                 $wpdb->query($sql);
234 234
             }
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
                                or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'";
239 239
             $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A);
240 240
             foreach ($dbCurrentConfig as $item) {
241
-                if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') {
241
+                if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') {
242 242
                     $css_price_selector = $this->preparePriceSelector($item['value']);
243
-                    if ($item['value'] != $css_price_selector) {
243
+                    if ($item['value']!=$css_price_selector) {
244 244
                         $wpdb->update(
245 245
                             $tableName,
246 246
                             array('value' => stripslashes($css_price_selector)),
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
                             array('%s')
250 250
                         );
251 251
                     }
252
-                } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') {
252
+                } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') {
253 253
                     $css_quantity_selector = $this->prepareQuantitySelector($item['value']);
254
-                    if ($item['value'] != $css_quantity_selector) {
254
+                    if ($item['value']!=$css_quantity_selector) {
255 255
                         $wpdb->update(
256 256
                             $tableName,
257 257
                             array('value' => stripslashes($css_quantity_selector)),
@@ -265,18 +265,18 @@  discard block
 block discarded – undo
265 265
         }
266 266
 
267 267
         // Creating new cart processing table < 8.6.13
268
-        if (isPgTableCreated(PG_CART_PROCESS_TABLE)){
269
-            pagantisLogger::log(PG_CART_PROCESS_TABLE . " ALTERED " .  "on " . __LINE__ . " in " . __FILE__);
268
+        if (isPgTableCreated(PG_CART_PROCESS_TABLE)) {
269
+            pagantisLogger::log(PG_CART_PROCESS_TABLE." ALTERED "."on ".__LINE__." in ".__FILE__);
270 270
             pagantisLogger::log(pagantisLogger::pg_debug_backtrace());
271 271
             alterCartProcessingTable();
272
-        } else{
273
-            pagantisLogger::log(PG_CART_PROCESS_TABLE . " CREATED " .  "on " . __LINE__ . " in " . __FILE__);
272
+        } else {
273
+            pagantisLogger::log(PG_CART_PROCESS_TABLE." CREATED "."on ".__LINE__." in ".__FILE__);
274 274
             pagantisLogger::log(pagantisLogger::pg_debug_backtrace());
275 275
             createCartProcessingTable();
276 276
         }
277 277
 
278 278
         // Making sure DB tables are created < v8.6.9
279
-        if (!isPgTableCreated(PG_LOGS_TABLE_NAME)){
279
+        if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) {
280 280
             createLogsTable();
281 281
         }
282 282
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
285 285
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'";
286 286
         $results = $wpdb->get_results($query, ARRAY_A);
287
-        if (count($results) == 0) {
287
+        if (count($results)==0) {
288 288
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value'  => '.'), array('%s', '%s'));
289 289
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value'  => ','), array('%s', '%s'));
290 290
         }
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
294 294
         $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'";
295 295
         $results = $wpdb->get_results($query, ARRAY_A);
296
-        if (count($results) == 0) {
296
+        if (count($results)==0) {
297 297
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value'  => '0'), array('%s', '%s'));
298 298
         }
299 299
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
302 302
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'";
303 303
         $results = $wpdb->get_results($query, ARRAY_A);
304
-        if (count($results) == 0) {
304
+        if (count($results)==0) {
305 305
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value'  => 'default'), array('%s', '%s'));
306 306
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value'  => 'default'), array('%s', '%s'));
307 307
         }
@@ -311,17 +311,17 @@  discard block
 block discarded – undo
311 311
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
312 312
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'";
313 313
         $results = $wpdb->get_results($query, ARRAY_A);
314
-        if (count($results) == 0) {
314
+        if (count($results)==0) {
315 315
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', 'value'  => 'sdk.simulator.types.CHECKOUT_PAGE'), array('%s', '%s'));
316 316
             $wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), array('%s'), array('%s'));
317 317
         }
318 318
 
319 319
         //Adapting to variable selector < v8.3.6
320
-        $variableSelector="div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price";
320
+        $variableSelector = "div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price";
321 321
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
322 322
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'";
323 323
         $results = $wpdb->get_results($query, ARRAY_A);
324
-        if (count($results) == 0) {
324
+        if (count($results)==0) {
325 325
             $wpdb->update($tableName, array('value' => $variableSelector), array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION'), array('%s'), array('%s'));
326 326
         }
327 327
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
330 330
         $query = "select * from $tableName where config='PAGANTIS_TITLE_4x'";
331 331
         $results = $wpdb->get_results($query, ARRAY_A);
332
-        if (count($results) == 0) {
332
+        if (count($results)==0) {
333 333
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_TITLE_4x', 'value'  => 'Until 4 installments, without fees'), array('%s', '%s'));
334 334
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MIN_AMOUNT_4x', 'value'  => 1), array('%s', '%s'));
335 335
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT_4x', 'value'  => 800), array('%s', '%s'));
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
343 343
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X'";
344 344
         $results = $wpdb->get_results($query, ARRAY_A);
345
-        if (count($results) == 0) {
345
+        if (count($results)==0) {
346 346
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X', 'value'  => 'default'), array('%s', '%s'));
347 347
         }
348 348
 
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
359 359
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'";
360 360
         $results = $wpdb->get_results($query, ARRAY_A);
361
-        if (count($results) == 0) {
361
+        if (count($results)==0) {
362 362
             $wpdb->update($tableName, array('value' => 'a:4:{i:0;s:52:"div.summary *:not(del)>.woocommerce-Price-amount bdi";i:1;s:48:"div.summary *:not(del)>.woocommerce-Price-amount";i:2;s:54:"div.entry-summary *:not(del)>.woocommerce-Price-amount";i:3;s:36:"*:not(del)>.woocommerce-Price-amount";}'), array('config' => 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'), array('%s'), array('%s'));
363 363
         }
364 364
 
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
         $isAtcTplPresent = isTemplatePresent(
452 452
             $template_name,
453 453
             array('single-product/add-to-cart/variation-add-to-cart-button.php',
454
-                'single-product/add-to-cart/variation.php','single-product/add-to-cart/simple.php')
454
+                'single-product/add-to-cart/variation.php', 'single-product/add-to-cart/simple.php')
455 455
         );
456 456
 
457 457
         $html = apply_filters('pagantis_simulator_selector_html', '<div class="mainPagantisSimulator"></div><div class="pagantisSimulator"></div>');
@@ -463,10 +463,10 @@  discard block
 block discarded – undo
463 463
         }
464 464
 
465 465
         $pagantisSimulator4x = 'enabled';
466
-        if (!isPluginEnabled4x() || !areMerchantKeysSet4x()  || !isCountryShopContextValid() || !isProductAmountValid4x()) {
466
+        if (!isPluginEnabled4x() || !areMerchantKeysSet4x() || !isCountryShopContextValid() || !isProductAmountValid4x()) {
467 467
             $pagantisSimulator4x = 'disabled';
468 468
         }
469
-        if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') {
469
+        if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') {
470 470
             return;
471 471
         }
472 472
 
@@ -522,12 +522,12 @@  discard block
 block discarded – undo
522 522
             $pagantisSimulator4x = 'disabled';
523 523
         }
524 524
 
525
-        if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') {
525
+        if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') {
526 526
             return;
527 527
         }
528 528
 
529 529
         $totalPrice = $product->get_price();
530
-        $formattedInstallments = number_format($totalPrice/4, 2);
530
+        $formattedInstallments = number_format($totalPrice / 4, 2);
531 531
         $simulatorMessage = sprintf(__('or 4 installments of %s€, without fees, with ', 'pagantis'), $formattedInstallments);
532 532
         $post_id = $product->get_id();
533 533
         $logo = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg';
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
      */
571 571
     public function addPagantisGateway($methods)
572 572
     {
573
-        if (! class_exists('WC_Payment_Gateway')) {
573
+        if (!class_exists('WC_Payment_Gateway')) {
574 574
             return $methods;
575 575
         }
576 576
 
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
      */
636 636
     public function pagantisRowMeta($links, $file)
637 637
     {
638
-        if ($file == plugin_basename(__FILE__)) {
638
+        if ($file==plugin_basename(__FILE__)) {
639 639
             $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>';
640 640
             $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'.
641 641
                        __('API documentation', 'pagantis').'</a>';
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
         $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME;
665 665
         $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc";
666 666
         $results = $wpdb->get_results($query);
667
-        if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) {
667
+        if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) {
668 668
             foreach ($results as $key => $result) {
669 669
                 $response[$key]['timestamp'] = $result->createdAt;
670 670
                 $response[$key]['log']       = json_decode($result->log);
@@ -691,13 +691,13 @@  discard block
 block discarded – undo
691 691
 
692 692
         $filters   = ($data->get_params());
693 693
         $secretKey = $filters['secret'];
694
-        $cfg  = get_option('woocommerce_pagantis_settings');
694
+        $cfg = get_option('woocommerce_pagantis_settings');
695 695
         $privateKey   = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null;
696 696
         $privateKey4x = isset($cfg['pagantis_private_key_4x']) ? $cfg['pagantis_private_key_4x'] : null;
697
-        if ($privateKey != $secretKey && $privateKey4x != $secretKey) {
697
+        if ($privateKey!=$secretKey && $privateKey4x!=$secretKey) {
698 698
             $response['status'] = 401;
699 699
             $response['result'] = 'Unauthorized';
700
-        } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
700
+        } elseif ($_SERVER['REQUEST_METHOD']=='POST') {
701 701
             if (count($_POST)) {
702 702
                 foreach ($_POST as $config => $value) {
703 703
                     if (isset($this->defaultConfigs[$config]) && $response['status']==null) {
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
                   and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc";
759 759
         $results = $wpdb->get_results($query);
760 760
 
761
-        if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) {
761
+        if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) {
762 762
             foreach ($results as $result) {
763 763
                 $key = $result->ID;
764 764
                 $response['message'][$key]['timestamp'] = $result->post_date;
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
      */
832 832
     private function prepareQuantitySelector($css_quantity_selector)
833 833
     {
834
-        if ($css_quantity_selector == 'default' || $css_quantity_selector == '') {
834
+        if ($css_quantity_selector=='default' || $css_quantity_selector=='') {
835 835
             $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'];
836 836
         } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it
837 837
             $css_quantity_selector = serialize(array($css_quantity_selector));
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
      */
848 848
     private function preparePriceSelector($css_price_selector)
849 849
     {
850
-        if ($css_price_selector == 'default' || $css_price_selector == '') {
850
+        if ($css_price_selector=='default' || $css_price_selector=='') {
851 851
             $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'];
852 852
         } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it
853 853
             $css_price_selector = serialize(array($css_price_selector));
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
     {
866 866
         $metaProduct = get_post_meta($product_id);
867 867
         return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) &&
868
-                $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false';
868
+                $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false';
869 869
     }
870 870
 
871 871
     /**
Please login to merge, or discard this patch.