Passed
Pull Request — master (#83)
by
unknown
02:56
created
includes/pg-functions.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 function requireWPPluginFunctions()
4 4
 {
5
-    if (! function_exists('is_plugin_active')) {
6
-        require_once(ABSPATH . 'wp-admin/includes/plugin.php');
5
+    if (!function_exists('is_plugin_active')) {
6
+        require_once(ABSPATH.'wp-admin/includes/plugin.php');
7 7
     }
8 8
 }
9 9
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 function getConfigValue($configKey)
22 22
 {
23 23
     global $wpdb;
24
-    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
24
+    $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
25 25
     $value     = $wpdb->get_var($wpdb->prepare("SELECT value FROM $tableName WHERE config= %s ", $configKey));
26 26
 
27 27
     return $value;
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 function isPgTableCreated($tableToCheck)
39 39
 {
40 40
     global $wpdb;
41
-    $tableName = $wpdb->prefix . $tableToCheck;
42
-    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) {
41
+    $tableName = $wpdb->prefix.$tableToCheck;
42
+    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")==$tableName) {
43 43
         return true;
44 44
     }
45 45
 
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 function createPgCartTable()
53 53
 {
54 54
     global $wpdb;
55
-    $tableName       = $wpdb->prefix . PG_CART_PROCESS_TABLE;
55
+    $tableName       = $wpdb->prefix.PG_CART_PROCESS_TABLE;
56 56
     $charset_collate = $wpdb->get_charset_collate();
57 57
     $sql             = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50),  
58 58
                   UNIQUE KEY id (id)) $charset_collate";
59 59
 
60
-    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
60
+    require_once(ABSPATH.'wp-admin/includes/upgrade.php');
61 61
     dbDelta($sql);
62 62
 }
63 63
 
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 {
66 66
     global $wpdb;
67 67
     $charset_collate = $wpdb->get_charset_collate();
68
-    $LogsTableName   = $wpdb->prefix . PG_LOGS_TABLE_NAME;
68
+    $LogsTableName   = $wpdb->prefix.PG_LOGS_TABLE_NAME;
69 69
     $sqlQuery        = "CREATE TABLE $LogsTableName ( 
70 70
     id int NOT NULL AUTO_INCREMENT,
71 71
     log text NOT NULL, 
72 72
     createdAt timestamp DEFAULT CURRENT_TIMESTAMP,
73 73
     UNIQUE KEY id (id)) 
74 74
     $charset_collate";
75
-    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
75
+    require_once(ABSPATH.'wp-admin/includes/upgrade.php');
76 76
     dbDelta($sqlQuery);
77 77
 }
78 78
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 function insertLogEntry($exception = null, $message = null)
84 84
 {
85 85
     global $wpdb;
86
-    if (! isPgTableCreated(PG_LOGS_TABLE_NAME)) {
86
+    if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) {
87 87
         createLogsTable();
88 88
     }
89 89
     $logEntry = new Pagantis\ModuleUtils\Model\Log\LogEntry();
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     } else {
93 93
         $logEntry = $logEntry->info($message);
94 94
     }
95
-    $tableName = $wpdb->prefix . PG_LOGS_TABLE_NAME;
95
+    $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME;
96 96
     $wpdb->insert($tableName, array('log' => $logEntry->toJson()));
97 97
 }
98 98
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 {
104 104
     $pgDecimalSeparator = getPgSimulatorDecimalSeparatorConfig();
105 105
     $wc_decimal_sep     = get_option('woocommerce_price_decimal_sep');
106
-    if (stripslashes($wc_decimal_sep) == stripslashes($pgDecimalSeparator)) {
106
+    if (stripslashes($wc_decimal_sep)==stripslashes($pgDecimalSeparator)) {
107 107
         return true;
108 108
     } else {
109 109
         return false;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 {
119 119
     $pgThousandSeparator = getPgSimulatorThousandsSeparator();
120 120
     $wc_price_thousand   = get_option('woocommerce_price_thousand_sep');
121
-    if (stripslashes($wc_price_thousand) == stripslashes($pgThousandSeparator)) {
121
+    if (stripslashes($wc_price_thousand)==stripslashes($pgThousandSeparator)) {
122 122
         return true;
123 123
     } else {
124 124
         return false;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 function getPgSimulatorThousandsSeparator()
132 132
 {
133 133
     global $wpdb;
134
-    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
134
+    $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
135 135
     $query     = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'";
136 136
     $result    = $wpdb->get_row($query, ARRAY_A);
137 137
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 function getPgSimulatorDecimalSeparatorConfig()
145 145
 {
146 146
     global $wpdb;
147
-    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
147
+    $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
148 148
     $query     = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'";
149 149
     $result    = $wpdb->get_row($query, ARRAY_A);
150 150
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     if (areThousandsSeparatorEqual()) {
158 158
         return;
159 159
     }
160
-    $tableName         = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
160
+    $tableName         = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
161 161
     $thousandSeparator = get_option('woocommerce_price_thousand_sep');
162 162
     $wpdb->update(
163 163
         $tableName,
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
     if (areDecimalSeparatorEqual()) {
175 175
         return;
176 176
     }
177
-    $tableName        = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
177
+    $tableName        = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
178 178
     $decimalSeparator = get_option('woocommerce_price_decimal_sep');
179 179
     $wpdb->update(
180 180
         $tableName,
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
  */
195 195
 function isSimulatorTypeValid($simulatorType, $validSimulatorTypes)
196 196
 {
197
-    if (! in_array($simulatorType, $validSimulatorTypes)) {
197
+    if (!in_array($simulatorType, $validSimulatorTypes)) {
198 198
         return false;
199 199
     }
200 200
 
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 function areMerchantKeysSet()
222 222
 {
223 223
     $settings   = get_option('woocommerce_pagantis_settings');
224
-    $publicKey  = ! empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : '';
225
-    $privateKey = ! empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : '';
224
+    $publicKey  = !empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : '';
225
+    $privateKey = !empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : '';
226 226
     if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) {
227 227
         return false;
228 228
     }
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 function areMerchantKeysSet4x()
234 234
 {
235 235
     $settings   = get_option('woocommerce_pagantis_settings');
236
-    $publicKey  = ! empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : '';
237
-    $privateKey = ! empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : '';
236
+    $publicKey  = !empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : '';
237
+    $privateKey = !empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : '';
238 238
     if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) {
239 239
         return false;
240 240
     }
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 function isSimulatorEnabled()
246 246
 {
247 247
     $settings = get_option('woocommerce_pagantis_settings');
248
-    if ((! empty($settings['simulator']) && 'yes' === $settings['simulator']) ? true : false) {
248
+    if ((!empty($settings['simulator']) && 'yes'===$settings['simulator']) ? true : false) {
249 249
         return true;
250 250
     }
251 251
 
@@ -256,13 +256,13 @@  discard block
 block discarded – undo
256 256
 {
257 257
     $settings = get_option('woocommerce_pagantis_settings');
258 258
 
259
-    return (! empty($settings['enabled']) && 'yes' === $settings['enabled']);
259
+    return (!empty($settings['enabled']) && 'yes'===$settings['enabled']);
260 260
 }
261 261
 
262 262
 function isPluginEnabled4x()
263 263
 {
264 264
     $settings = get_option('woocommerce_pagantis_settings');
265
-    return (! empty($settings['enabled_4x']) && 'yes' === $settings['enabled_4x']);
265
+    return (!empty($settings['enabled_4x']) && 'yes'===$settings['enabled_4x']);
266 266
 }
267 267
 
268 268
 
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 {
271 271
     $locale           = strtolower(strstr(get_locale(), '_', true));
272 272
     $allowedCountries = maybe_unserialize(getConfigValue('PAGANTIS_ALLOWED_COUNTRIES'));
273
-    if (! in_array(strtolower($locale), $allowedCountries)) {
273
+    if (!in_array(strtolower($locale), $allowedCountries)) {
274 274
         return false;
275 275
     }
276 276
 
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
     global $product;
288 288
     if (method_exists($product, 'get_price')) {
289 289
         $productPrice = $product->get_price();
290
-        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0'));
290
+        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0'));
291 291
         if ($validAmount) {
292 292
             return true;
293 293
         }
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
     global $product;
307 307
     if (method_exists($product, 'get_price')) {
308 308
         $productPrice = $product->get_price();
309
-        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0'));
309
+        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0'));
310 310
         if ($validAmount) {
311 311
             return true;
312 312
         }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 function getExtraConfig()
326 326
 {
327 327
     global $wpdb;
328
-    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
328
+    $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
329 329
     $response  = array();
330 330
     $dbResult  = $wpdb->get_results("select config, value from $tableName", ARRAY_A);
331 331
     foreach ($dbResult as $value) {
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 function getModuleVersion()
339 339
 {
340 340
 
341
-    $mainFile = plugin_dir_path(PG_WC_MAIN_FILE). '/WC_Pagantis.php';
341
+    $mainFile = plugin_dir_path(PG_WC_MAIN_FILE).'/WC_Pagantis.php';
342 342
     $version = get_file_data($mainFile, array('Version' => 'Version'), false);
343 343
     return $version['Version'];
344 344
 }
@@ -350,9 +350,9 @@  discard block
 block discarded – undo
350 350
  */
351 351
 function getNationalId($order)
352 352
 {
353
-    foreach ((array)$order->get_meta_data() as $mdObject) {
353
+    foreach ((array) $order->get_meta_data() as $mdObject) {
354 354
         $data = $mdObject->get_data();
355
-        if ($data['key'] == 'vat_number') {
355
+        if ($data['key']=='vat_number') {
356 356
             return $data['value'];
357 357
         }
358 358
     }
@@ -367,9 +367,9 @@  discard block
 block discarded – undo
367 367
  */
368 368
 function getTaxId($order)
369 369
 {
370
-    foreach ((array)$order->get_meta_data() as $mdObject) {
370
+    foreach ((array) $order->get_meta_data() as $mdObject) {
371 371
         $data = $mdObject->get_data();
372
-        if ($data['key'] == 'billing_cfpiva') {
372
+        if ($data['key']=='billing_cfpiva') {
373 373
             return $data['value'];
374 374
         }
375 375
     }
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
     $metaProduct = get_post_meta($product_id);
387 387
 
388 388
     return (array_key_exists('custom_product_pagantis_promoted', $metaProduct)
389
-            && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false';
389
+            && $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false';
390 390
 }
391 391
 
392 392
 /**
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
     $promotedAmount = 0;
398 398
     foreach (WC()->cart->get_cart() as $key => $item) {
399 399
         $promotedProduct = isProductPromoted($item['product_id']);
400
-        if ($promotedProduct == 'true') {
400
+        if ($promotedProduct=='true') {
401 401
             $promotedAmount += $item['line_total'] + $item['line_tax'];
402 402
         }
403 403
     }
@@ -416,12 +416,12 @@  discard block
 block discarded – undo
416 416
 {
417 417
     global $wpdb;
418 418
     checkCartProcessTable();
419
-    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
419
+    $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
420 420
 
421 421
     //Check if id exists
422 422
     $resultsSelect = $wpdb->get_results("SELECT * FROM $tableName WHERE id='$orderId'");
423 423
     $countResults  = count($resultsSelect);
424
-    if ($countResults == 0) {
424
+    if ($countResults==0) {
425 425
         $wpdb->insert($tableName, array('id' => $orderId, 'order_id' => $pagantisOrderId), array('%d', '%s'));
426 426
     } else {
427 427
         $wpdb->update($tableName, array('order_id' => $pagantisOrderId), array('id' => $orderId), array('%s'), array('%d'));
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 function alterCartProcessTable()
432 432
 {
433 433
     global $wpdb;
434
-    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
435
-        if (!$wpdb->get_var( "SELECT token FROM `{$tableName}` LIMIT 1"  ) ) {
434
+    $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
435
+        if (!$wpdb->get_var("SELECT token FROM `{$tableName}` LIMIT 1")) {
436 436
         $wpdb->query("ALTER TABLE $tableName ADD COLUMN `token` VARCHAR(32) NOT NULL AFTER `wc_order_id`");
437 437
         // OLDER VERSIONS OF MODULE USE UNIQUE KEY ON `id` MEANING THIS VALUE WAS NULLABLE
438 438
         $wpdb->query("ALTER TABLE $tableName DROP PRIMARY KEY,ADD PRIMARY KEY(`id`,`order_id`)");
@@ -446,9 +446,9 @@  discard block
 block discarded – undo
446 446
 function checkCartProcessTable()
447 447
 {
448 448
     global $wpdb;
449
-    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
449
+    $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
450 450
 
451
-    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
451
+    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
452 452
 
453 453
         $charset_collate = $wpdb->get_charset_collate();
454 454
         $sql = "CREATE TABLE IF NOT EXISTS $tableName(
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
              PRIMARY KEY (`id`, `order_id`)
460 460
             )$charset_collate";
461 461
 
462
-        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
462
+        require_once(ABSPATH.'wp-admin/includes/upgrade.php');
463 463
         dbDelta($sql);
464 464
     }
465 465
 }
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
             'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
503 503
         ));
504 504
         foreach ($customer_orders as $customer_order) {
505
-            if (trim($sign_up) == '' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) {
505
+            if (trim($sign_up)=='' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) {
506 506
                 $sign_up = substr($customer_order->post_date, 0, 10);
507 507
             }
508 508
         }
Please login to merge, or discard this patch.
controllers/notifyController.php 1 patch
Spacing   +24 added lines, -24 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
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     private function checkConcurrency()
120 120
     {
121 121
         $this->woocommerceOrderId = $_GET['order-received'];
122
-        if ($this->woocommerceOrderId == '') {
122
+        if ($this->woocommerceOrderId=='') {
123 123
             throw new QuoteNotFoundException();
124 124
         }
125 125
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      */
133 133
     private function getProductType()
134 134
     {
135
-        if ($_GET['product'] == '') {
135
+        if ($_GET['product']=='') {
136 136
             $this->setProduct(WcPagantisGateway::METHOD_ID);
137 137
         } else {
138 138
             $this->setProduct($_GET['product']);
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
         $order_id = $wpdb->get_var("SELECT order_id FROM $tableName WHERE token='{$this->getUrlToken()}' ");
167 167
         $this->pagantisOrderId = $order_id;
168 168
 
169
-        $this->insertLog(null, '$order_id '. json_encode($order_id, JSON_PRETTY_PRINT) . " LINE:".__LINE__);
169
+        $this->insertLog(null, '$order_id '.json_encode($order_id, JSON_PRETTY_PRINT)." LINE:".__LINE__);
170 170
 
171
-        if ($this->pagantisOrderId == '') {
171
+        if ($this->pagantisOrderId=='') {
172 172
             throw new NoIdentificationException();
173 173
         }
174 174
     }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                 $status = '-';
212 212
             }
213 213
 
214
-            if ($status === Order::STATUS_CONFIRMED) {
214
+            if ($status===Order::STATUS_CONFIRMED) {
215 215
                 return true;
216 216
             }
217 217
             throw new WrongStatusException($status);
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
         );
233 233
 
234 234
         if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM
235
-            $logMessage = "WARNING checkMerchantOrderStatus." .
235
+            $logMessage = "WARNING checkMerchantOrderStatus.".
236 236
                           " Merchant order id:".$this->woocommerceOrder->get_id().
237 237
                           " Merchant order status:".$this->woocommerceOrder->get_status().
238 238
                           " Pagantis order id:".$this->pagantisOrder->getStatus().
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
     {
255 255
         $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount();
256 256
         $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total()));
257
-        if ($pagantisAmount != $wcAmount) {
257
+        if ($pagantisAmount!=$wcAmount) {
258 258
             throw new AmountMismatchException($pagantisAmount, $wcAmount);
259 259
         }
260 260
     }
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
             $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId);
279 279
         } catch (\Exception $e) {
280 280
             $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId);
281
-            if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) {
281
+            if ($this->pagantisOrder->getStatus()!==Order::STATUS_CONFIRMED) {
282 282
                 throw new UnknownException($e->getMessage());
283 283
             } else {
284 284
                 $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process';
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
         global $wpdb;
303 303
         $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
304 304
 
305
-        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
305
+        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
306 306
             $charset_collate = $wpdb->get_charset_collate();
307
-            $sql= "CREATE TABLE IF NOT EXISTS $tableName
307
+            $sql = "CREATE TABLE IF NOT EXISTS $tableName
308 308
                 (id INT, 
309 309
                 order_id varchar(60),
310 310
                 wc_order_id varchar(60),
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
         global $wpdb;
326 326
         $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME;
327 327
 
328
-        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
328
+        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
329 329
             $charset_collate = $wpdb->get_charset_collate();
330 330
             $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, 
331 331
                     createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate";
@@ -382,12 +382,12 @@  discard block
 block discarded – undo
382 382
             $metadataOrder = $this->pagantisOrder->getMetadata();
383 383
             $metadataInfo = null;
384 384
             foreach ($metadataOrder as $metadataKey => $metadataValue) {
385
-                if ($metadataKey == 'promotedProduct') {
386
-                    $metadataInfo.= "/Producto promocionado = $metadataValue";
385
+                if ($metadataKey=='promotedProduct') {
386
+                    $metadataInfo .= "/Producto promocionado = $metadataValue";
387 387
                 }
388 388
             }
389 389
 
390
-            if ($metadataInfo != null) {
390
+            if ($metadataInfo!=null) {
391 391
                 $this->woocommerceOrder->add_order_note($metadataInfo);
392 392
             }
393 393
 
@@ -456,13 +456,13 @@  discard block
 block discarded – undo
456 456
     {
457 457
         global $wpdb;
458 458
         $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME;
459
-        if ($orderId == null) {
459
+        if ($orderId==null) {
460 460
             $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT." SECOND)";
461 461
         } else {
462 462
             $query = "DELETE FROM $tableName WHERE order_id = $orderId";
463 463
         }
464 464
         $resultDelete = $wpdb->query($query);
465
-        if ($resultDelete === false) {
465
+        if ($resultDelete===false) {
466 466
             throw new ConcurrencyException();
467 467
         }
468 468
     }
@@ -477,8 +477,8 @@  discard block
 block discarded – undo
477 477
         global $wpdb;
478 478
         $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME;
479 479
         $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId));
480
-        if ($insertResult === false) {
481
-            if ($this->getOrigin() == 'Notify') {
480
+        if ($insertResult===false) {
481
+            if ($this->getOrigin()=='Notify') {
482 482
                 throw new ConcurrencyException();
483 483
             } else {
484 484
                 $query = sprintf(
@@ -489,8 +489,8 @@  discard block
 block discarded – undo
489 489
                 );
490 490
                 $resultSeconds = $wpdb->get_row($query);
491 491
                 $restSeconds = isset($resultSeconds) ? ($resultSeconds->rest) : 0;
492
-                $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;
493
-                sleep($secondsToExpire+1);
492
+                $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;
493
+                sleep($secondsToExpire + 1);
494 494
 
495 495
                 $logMessage = sprintf(
496 496
                     "User waiting %s seconds, default seconds %s, bd time to expire %s seconds",
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
     {
515 515
         $this->unblockConcurrency($this->woocommerceOrderId);
516 516
 
517
-        if ($exception == null) {
517
+        if ($exception==null) {
518 518
             $jsonResponse = new JsonSuccessResponse();
519 519
         } else {
520 520
             $jsonResponse = new JsonExceptionResponse();
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
         $jsonResponse->setMerchantOrderId($this->woocommerceOrderId);
525 525
         $jsonResponse->setPagantisOrderId($this->pagantisOrderId);
526 526
 
527
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
527
+        if ($_SERVER['REQUEST_METHOD']=='POST') {
528 528
             $jsonResponse->printResponse();
529 529
         } else {
530 530
             return $jsonResponse;
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
      */
557 557
     private function isProduct4x()
558 558
     {
559
-        return ($this->product === Ucfirst(WcPagantis4xGateway::METHOD_ID));
559
+        return ($this->product===Ucfirst(WcPagantis4xGateway::METHOD_ID));
560 560
     }
561 561
 
562 562
     /**
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
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
         $this->method_title = ucfirst($this->id);
58 58
 
59 59
         //Useful vars
60
-        $this->template_path = plugin_dir_path(__FILE__) . '../templates/';
60
+        $this->template_path = plugin_dir_path(__FILE__).'../templates/';
61 61
         $this->allowed_currencies = getAllowedCurrencies();
62
-        $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Pagantis.php';
62
+        $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)).'/WC_Pagantis.php';
63 63
         $this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false);
64 64
         $this->language = strstr(get_locale(), '_', true);
65 65
         if ($this->language=='') {
@@ -68,25 +68,25 @@  discard block
 block discarded – undo
68 68
         $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg';
69 69
 
70 70
         //Panel form fields
71
-        $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options
71
+        $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options
72 72
         $this->init_settings();
73 73
 
74 74
         $this->extraConfig = getExtraConfig();
75 75
         $this->title = __($this->extraConfig['PAGANTIS_TITLE'], 'pagantis');
76 76
         $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis.";
77 77
 
78
-        $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl();
79
-        $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl();
78
+        $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl();
79
+        $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl();
80 80
         foreach ($this->settings as $setting_key => $setting_value) {
81 81
             $this->$setting_key = $setting_value;
82 82
         }
83 83
 
84 84
         //Hooks
85
-        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options
86
-        add_action('admin_notices', array($this, 'pagantisCheckFields'));                          //Check config fields
87
-        add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage'));          //Pagantis form
88
-        add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification'));      //Json Notification
89
-        add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3);
85
+        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options
86
+        add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields
87
+        add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form
88
+        add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification
89
+        add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3);
90 90
         add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2);
91 91
     }
92 92
 
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function loadPagantisTranslation($mofile, $domain)
100 100
     {
101
-        if ('pagantis' === $domain) {
102
-            $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo';
101
+        if ('pagantis'===$domain) {
102
+            $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo';
103 103
         }
104 104
         return $mofile;
105 105
     }
@@ -133,24 +133,24 @@  discard block
 block discarded – undo
133 133
     public function pagantisCheckFields()
134 134
     {
135 135
         $error_string = '';
136
-        if ($this->settings['enabled'] !== 'yes') {
136
+        if ($this->settings['enabled']!=='yes') {
137 137
             return;
138 138
         } elseif (!version_compare(phpversion(), '5.3.0', '>=')) {
139
-            $error_string =  __(' is not compatible with your php and/or curl version', 'pagantis');
139
+            $error_string = __(' is not compatible with your php and/or curl version', 'pagantis');
140 140
             $this->settings['enabled'] = 'no';
141
-        } 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']))) {
141
+        } 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 142
             $error_string = __(' is not configured correctly, the fields Public Key and Secret Key are mandatory for use this plugin', 'pagantis');
143 143
             $this->settings['enabled'] = 'no';
144 144
         } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) {
145
-            $error_string =  __(' only can be used in Euros', 'pagantis');
145
+            $error_string = __(' only can be used in Euros', 'pagantis');
146 146
             $this->settings['enabled'] = 'no';
147
-        } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']<'2'
148
-                  || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']>'12') {
147
+        } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] < '2'
148
+                  || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] > '12') {
149 149
             $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis');
150
-        } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']<'2'
151
-                  || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']>'12') {
150
+        } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] < '2'
151
+                  || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] > '12') {
152 152
             $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis');
153
-        } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']<0) {
153
+        } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] < 0) {
154 154
             $error_string = __(' can not have a minimum amount less than 0', 'pagantis');
155 155
         }
156 156
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
             $shippingAddress = $order->get_address('shipping');
185 185
             $billingAddress = $order->get_address('billing');
186
-            if ($shippingAddress['address_1'] == '') {
186
+            if ($shippingAddress['address_1']=='') {
187 187
                 $shippingAddress = $billingAddress;
188 188
             }
189 189
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
                 ->setNationalId($national_id)
211 211
                 ->setTaxId($tax_id)
212 212
             ;
213
-            $orderBillingAddress =  new Address();
213
+            $orderBillingAddress = new Address();
214 214
             $orderBillingAddress
215 215
                 ->setZipCode($billingAddress['postcode'])
216 216
                 ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name'])
@@ -283,12 +283,12 @@  discard block
 block discarded – undo
283 283
                 $details->addProduct($product);
284 284
 
285 285
                 $promotedProduct = isProductPromoted($item->get_product_id());
286
-                if ($promotedProduct == 'true') {
287
-                    $promotedAmount+=$product->getAmount();
288
-                    $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() .
289
-                                       ' - Price: ' . $item->get_total() .
290
-                                       ' - Qty: ' . $product->getQuantity() .
291
-                                       ' - Item ID: ' . $item['id_product'];
286
+                if ($promotedProduct=='true') {
287
+                    $promotedAmount += $product->getAmount();
288
+                    $promotedMessage = 'Promoted Item: '.$wcProduct->get_name().
289
+                                       ' - Price: '.$item->get_total().
290
+                                       ' - Qty: '.$product->getQuantity().
291
+                                       ' - Item ID: '.$item['id_product'];
292 292
                     $promotedMessage = substr($promotedMessage, 0, 999);
293 293
                     $metadataOrder->addMetadata('promotedProduct', $promotedMessage);
294 294
                 }
@@ -334,9 +334,7 @@  discard block
 block discarded – undo
334 334
 
335 335
             $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']);
336 336
             $purchaseCountry =
337
-                in_array(strtolower($this->language), $allowedCountries) ? $this->language :
338
-                in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] :
339
-                in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null;
337
+                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;
340 338
 
341 339
             $orderConfiguration = new Configuration();
342 340
             $orderConfiguration
@@ -362,7 +360,7 @@  discard block
 block discarded – undo
362 360
                 $url = $pagantisOrder->getActionUrls()->getForm();
363 361
                 addOrderToProcessingQueue($pagantisOrder->getId(), $order->get_id(), $this->urlToken);
364 362
 
365
-                $logEntry = "Cart Added to Processing Queue" .
363
+                $logEntry = "Cart Added to Processing Queue".
366 364
                             " cart hash: ".WC()->cart->get_cart_hash().
367 365
                             " Merchant order id: ".$order->get_id().
368 366
                             " Pagantis order id: ".$pagantisOrder->getId().
@@ -386,7 +384,7 @@  discard block
 block discarded – undo
386 384
                 wc_get_template('iframe.php', $template_fields, '', $this->template_path);
387 385
             }
388 386
         } catch (\Exception $exception) {
389
-            wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error');
387
+            wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error');
390 388
             insertLogEntry($exception);
391 389
             $checkout_url = get_permalink(wc_get_page_id('checkout'));
392 390
             wp_redirect($checkout_url);
@@ -401,7 +399,7 @@  discard block
 block discarded – undo
401 399
     public function pagantisNotification()
402 400
     {
403 401
         try {
404
-            $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order';
402
+            $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order';
405 403
 
406 404
             include_once('notifyController.php');
407 405
             $notify = new WcPagantisNotify();
@@ -440,10 +438,10 @@  discard block
 block discarded – undo
440 438
      */
441 439
     public function pagantisCompleteStatus($status, $order_id, $order)
442 440
     {
443
-        if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) {
444
-            if ($order->get_status() == 'failed') {
441
+        if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) {
442
+            if ($order->get_status()=='failed') {
445 443
                 $status = 'processing';
446
-            } elseif ($order->get_status() == 'pending' && $status=='completed') {
444
+            } elseif ($order->get_status()=='pending' && $status=='completed') {
447 445
                 $status = 'processing';
448 446
             }
449 447
         }
@@ -469,8 +467,8 @@  discard block
 block discarded – undo
469 467
         $allowedCountry = (in_array(strtolower($locale), $allowedCountries));
470 468
         $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'];
471 469
         $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT'];
472
-        $totalPrice = (int)$this->get_order_total();
473
-        $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0'));
470
+        $totalPrice = (int) $this->get_order_total();
471
+        $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0'));
474 472
         if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' &&
475 473
             $validAmount && $allowedCountry) {
476 474
             return true;
@@ -503,7 +501,7 @@  discard block
 block discarded – undo
503 501
 
504 502
             $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function
505 503
             if (strpos($redirectUrl, 'order-pay=')===false) {
506
-                $redirectUrl.="&order-pay=".$order_id;
504
+                $redirectUrl .= "&order-pay=".$order_id;
507 505
             }
508 506
 
509 507
             return array(
@@ -511,7 +509,7 @@  discard block
 block discarded – undo
511 509
                 'redirect' => $redirectUrl
512 510
             );
513 511
         } catch (Exception $e) {
514
-            wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error');
512
+            wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error');
515 513
             return array();
516 514
         }
517 515
     }
@@ -580,7 +578,7 @@  discard block
 block discarded – undo
580 578
     private function generateUrl($url)
581 579
     {
582 580
         $parsed_url = parse_url($url);
583
-        if ($parsed_url !== false) {
581
+        if ($parsed_url!==false) {
584 582
             $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query'];
585 583
             parse_str($parsed_url['query'], $arrayParams);
586 584
             foreach ($arrayParams as $keyParam => $valueParam) {
@@ -628,11 +626,10 @@  discard block
 block discarded – undo
628 626
     private function getKeysUrl($order, $url)
629 627
     {
630 628
         $defaultFields = (get_class($order)=='WC_Order') ?
631
-            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) :
632
-            array();
629
+            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array();
633 630
 
634 631
         $parsedUrl = parse_url($url);
635
-        if ($parsedUrl !== false) {
632
+        if ($parsedUrl!==false) {
636 633
             //Replace parameters from url
637 634
             $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields);
638 635
 
@@ -677,7 +674,7 @@  discard block
 block discarded – undo
677 674
         foreach ($arrayParams as $keyParam => $valueParam) {
678 675
             preg_match('#\{{.*?}\}#', $valueParam, $match);
679 676
             if (count($match)) {
680
-                $key = str_replace(array('{{','}}'), array('',''), $match[0]);
677
+                $key = str_replace(array('{{', '}}'), array('', ''), $match[0]);
681 678
                 $arrayParams[$keyParam] = $defaultFields[$key];
682 679
             }
683 680
         }
@@ -692,13 +689,13 @@  discard block
 block discarded – undo
692 689
      */
693 690
     private function unparseUrl($parsed_url)
694 691
     {
695
-        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
692
+        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : '';
696 693
         $host     = isset($parsed_url['host']) ? $parsed_url['host'] : '';
697
-        $port     = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
698
-        $query    = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
699
-        $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
694
+        $port     = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : '';
695
+        $query    = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : '';
696
+        $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : '';
700 697
         $path     = $parsed_url['path'];
701
-        return $scheme . $host . $port . $path . $query . $fragment;
698
+        return $scheme.$host.$port.$path.$query.$fragment;
702 699
     }
703 700
 
704 701
 }
Please login to merge, or discard this patch.
controllers/paymentController4x.php 1 patch
Spacing   +38 added lines, -41 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         $this->method_title = ucfirst($this->id);
66 66
 
67 67
         //Useful vars
68
-        $this->template_path = plugin_dir_path(__FILE__) . '../templates/';
68
+        $this->template_path = plugin_dir_path(__FILE__).'../templates/';
69 69
         $this->allowed_currencies = getAllowedCurrencies();
70 70
         $this->language = strstr(get_locale(), '_', true);
71 71
         if ($this->language=='') {
@@ -74,24 +74,24 @@  discard block
 block discarded – undo
74 74
         $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg';
75 75
 
76 76
         //Panel form fields
77
-        $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options
77
+        $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options
78 78
         $this->init_settings();
79 79
 
80 80
         $this->extraConfig = getExtraConfig();
81 81
         $this->title = __($this->extraConfig['PAGANTIS_TITLE_4x'], 'pagantis');
82 82
         $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis.";
83 83
 
84
-        $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl();
85
-        $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl();
84
+        $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl();
85
+        $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl();
86 86
         foreach ($this->settings as $setting_key => $setting_value) {
87 87
             $this->$setting_key = $setting_value;
88 88
         }
89 89
 
90 90
         //Hooks
91
-        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options
92
-        add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage'));          //Pagantis form
93
-        add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification'));      //Json Notification
94
-        add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3);
91
+        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options
92
+        add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form
93
+        add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification
94
+        add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3);
95 95
         add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2);
96 96
     }
97 97
 
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function loadPagantisTranslation($mofile, $domain)
105 105
     {
106
-        if ('pagantis' === $domain) {
107
-            $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo';
106
+        if ('pagantis'===$domain) {
107
+            $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo';
108 108
         }
109 109
         return $mofile;
110 110
     }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 
154 154
             $shippingAddress = $order->get_address('shipping');
155 155
             $billingAddress = $order->get_address('billing');
156
-            if ($shippingAddress['address_1'] == '') {
156
+            if ($shippingAddress['address_1']=='') {
157 157
                 $shippingAddress = $billingAddress;
158 158
             }
159 159
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
                 ->setNationalId($national_id)
181 181
                 ->setTaxId($tax_id)
182 182
             ;
183
-            $orderBillingAddress =  new Address();
183
+            $orderBillingAddress = new Address();
184 184
             $orderBillingAddress
185 185
                 ->setZipCode($billingAddress['postcode'])
186 186
                 ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name'])
@@ -253,12 +253,12 @@  discard block
 block discarded – undo
253 253
                 $details->addProduct($product);
254 254
 
255 255
                 $promotedProduct = isProductPromoted($item->get_product_id());
256
-                if ($promotedProduct == 'true') {
257
-                    $promotedAmount+=$product->getAmount();
258
-                    $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() .
259
-                                       ' - Price: ' . $item->get_total() .
260
-                                       ' - Qty: ' . $product->getQuantity() .
261
-                                       ' - Item ID: ' . $item['id_product'];
256
+                if ($promotedProduct=='true') {
257
+                    $promotedAmount += $product->getAmount();
258
+                    $promotedMessage = 'Promoted Item: '.$wcProduct->get_name().
259
+                                       ' - Price: '.$item->get_total().
260
+                                       ' - Qty: '.$product->getQuantity().
261
+                                       ' - Item ID: '.$item['id_product'];
262 262
                     $promotedMessage = substr($promotedMessage, 0, 999);
263 263
                     $metadataOrder->addMetadata('promotedProduct', $promotedMessage);
264 264
                 }
@@ -304,9 +304,7 @@  discard block
 block discarded – undo
304 304
 
305 305
             $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']);
306 306
             $purchaseCountry =
307
-                in_array(strtolower($this->language), $allowedCountries) ? $this->language :
308
-                    in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] :
309
-                        in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null;
307
+                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;
310 308
 
311 309
             $orderConfiguration = new Configuration();
312 310
             $orderConfiguration
@@ -332,7 +330,7 @@  discard block
 block discarded – undo
332 330
             if ($pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) {
333 331
                 $url = $pagantisOrder->getActionUrls()->getForm();
334 332
                 addOrderToProcessingQueue($pagantisOrder->getId(), $order->get_id(), $this->urlToken4x);
335
-                $logEntry = "Cart Added to Processing Queue" .
333
+                $logEntry = "Cart Added to Processing Queue".
336 334
                     " cart hash: ".WC()->cart->get_cart_hash().
337 335
                     " Merchant order id: ".$order->get_id().
338 336
                     " Pagantis order id: ".$pagantisOrder->getId().
@@ -356,7 +354,7 @@  discard block
 block discarded – undo
356 354
                 wc_get_template('iframe.php', $template_fields, '', $this->template_path);
357 355
             }
358 356
         } catch (\Exception $exception) {
359
-            wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error');
357
+            wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error');
360 358
             insertLogEntry($exception);
361 359
             $checkout_url = get_permalink(wc_get_page_id('checkout'));
362 360
             wp_redirect($checkout_url);
@@ -372,7 +370,7 @@  discard block
 block discarded – undo
372 370
     public function pagantisNotification()
373 371
     {
374 372
         try {
375
-            $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order';
373
+            $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order';
376 374
 
377 375
             include_once('notifyController.php');
378 376
             $notify = new WcPagantisNotify();
@@ -411,10 +409,10 @@  discard block
 block discarded – undo
411 409
      */
412 410
     public function pagantisCompleteStatus($status, $order_id, $order)
413 411
     {
414
-        if ($order->get_payment_method() == WcPagantis4xGateway::METHOD_ID) {
415
-            if ($order->get_status() == 'failed') {
412
+        if ($order->get_payment_method()==WcPagantis4xGateway::METHOD_ID) {
413
+            if ($order->get_status()=='failed') {
416 414
                 $status = 'processing';
417
-            } elseif ($order->get_status() == 'pending' && $status=='completed') {
415
+            } elseif ($order->get_status()=='pending' && $status=='completed') {
418 416
                 $status = 'processing';
419 417
             }
420 418
         }
@@ -443,8 +441,8 @@  discard block
 block discarded – undo
443 441
         $allowedCountry = (in_array(strtolower($locale), $allowedCountries));
444 442
         $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT_4x'];
445 443
         $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT_4x'];
446
-        $totalPrice = (int)$this->get_order_total();
447
-        $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0'));
444
+        $totalPrice = (int) $this->get_order_total();
445
+        $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0'));
448 446
         if ($cfg['enabled_4x']==='yes' && $cfg['pagantis_public_key_4x']!='' && $cfg['pagantis_private_key_4x']!='' &&
449 447
             $validAmount && $allowedCountry) {
450 448
             return true;
@@ -479,7 +477,7 @@  discard block
 block discarded – undo
479 477
 
480 478
             $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function
481 479
             if (strpos($redirectUrl, 'order-pay=')===false) {
482
-                $redirectUrl.="&order-pay=".$order_id;
480
+                $redirectUrl .= "&order-pay=".$order_id;
483 481
             }
484 482
 
485 483
             return array(
@@ -487,7 +485,7 @@  discard block
 block discarded – undo
487 485
                 'redirect' => $redirectUrl
488 486
             );
489 487
         } catch (Exception $e) {
490
-            wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error');
488
+            wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error');
491 489
             return array();
492 490
         }
493 491
     }
@@ -558,7 +556,7 @@  discard block
 block discarded – undo
558 556
     private function generateUrl($url)
559 557
     {
560 558
         $parsed_url = parse_url($url);
561
-        if ($parsed_url !== false) {
559
+        if ($parsed_url!==false) {
562 560
             $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query'];
563 561
             parse_str($parsed_url['query'], $arrayParams);
564 562
             foreach ($arrayParams as $keyParam => $valueParam) {
@@ -606,11 +604,10 @@  discard block
 block discarded – undo
606 604
     private function getKeysUrl($order, $url)
607 605
     {
608 606
         $defaultFields = (get_class($order)=='WC_Order') ?
609
-            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) :
610
-            array();
607
+            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array();
611 608
 
612 609
         $parsedUrl = parse_url($url);
613
-        if ($parsedUrl !== false) {
610
+        if ($parsedUrl!==false) {
614 611
             //Replace parameters from url
615 612
             $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields);
616 613
 
@@ -655,7 +652,7 @@  discard block
 block discarded – undo
655 652
         foreach ($arrayParams as $keyParam => $valueParam) {
656 653
             preg_match('#\{{.*?}\}#', $valueParam, $match);
657 654
             if (count($match)) {
658
-                $key = str_replace(array('{{','}}'), array('',''), $match[0]);
655
+                $key = str_replace(array('{{', '}}'), array('', ''), $match[0]);
659 656
                 $arrayParams[$keyParam] = $defaultFields[$key];
660 657
             }
661 658
         }
@@ -670,12 +667,12 @@  discard block
 block discarded – undo
670 667
      */
671 668
     private function unparseUrl($parsed_url)
672 669
     {
673
-        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
670
+        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : '';
674 671
         $host     = isset($parsed_url['host']) ? $parsed_url['host'] : '';
675
-        $port     = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
676
-        $query    = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
677
-        $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
672
+        $port     = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : '';
673
+        $query    = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : '';
674
+        $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : '';
678 675
         $path     = $parsed_url['path'];
679
-        return $scheme . $host . $port . $path . $query . $fragment;
676
+        return $scheme.$host.$port.$path.$query.$fragment;
680 677
     }
681 678
 }
Please login to merge, or discard this patch.
WC_Pagantis.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 }
20 20
 
21 21
 
22
-require_once(__DIR__ . '/includes/pg-functions.php');
22
+require_once(__DIR__.'/includes/pg-functions.php');
23 23
 
24 24
 /**
25 25
  * Required minimums and constants
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     public function __construct()
82 82
     {
83 83
         require_once(plugin_dir_path(__FILE__).'/vendor/autoload.php');
84
-        require_once(PG_ABSPATH . '/includes/pg-functions.php');
84
+        require_once(PG_ABSPATH.'/includes/pg-functions.php');
85 85
         $this->template_path = plugin_dir_path(__FILE__).'/templates/';
86 86
 
87 87
         $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
     }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         global $wpdb;
194 194
 
195 195
         $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME;
196
-        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
196
+        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
197 197
             $charset_collate = $wpdb->get_charset_collate();
198 198
             $sql = "CREATE TABLE $tableName ( order_id int NOT NULL,  
199 199
                     createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate";
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
205 205
 
206 206
         //Check if table exists
207
-        $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName;
207
+        $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName;
208 208
         if ($tableExists) {
209 209
             $charset_collate = $wpdb->get_charset_collate();
210 210
             $sql = "CREATE TABLE IF NOT EXISTS $tableName (
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
             //Updated value field to adapt to new length < v8.0.1
220 220
             $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'";
221 221
             $results = $wpdb->get_results($query, ARRAY_A);
222
-            if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') {
222
+            if ($results['0']['COLUMN_TYPE']=='varchar(100)') {
223 223
                 $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)";
224 224
                 $wpdb->query($sql);
225 225
             }
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
                                or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'";
230 230
             $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A);
231 231
             foreach ($dbCurrentConfig as $item) {
232
-                if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') {
232
+                if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') {
233 233
                     $css_price_selector = $this->preparePriceSelector($item['value']);
234
-                    if ($item['value'] != $css_price_selector) {
234
+                    if ($item['value']!=$css_price_selector) {
235 235
                         $wpdb->update(
236 236
                             $tableName,
237 237
                             array('value' => stripslashes($css_price_selector)),
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
                             array('%s')
241 241
                         );
242 242
                     }
243
-                } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') {
243
+                } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') {
244 244
                     $css_quantity_selector = $this->prepareQuantitySelector($item['value']);
245
-                    if ($item['value'] != $css_quantity_selector) {
245
+                    if ($item['value']!=$css_quantity_selector) {
246 246
                         $wpdb->update(
247 247
                             $tableName,
248 248
                             array('value' => stripslashes($css_quantity_selector)),
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
         }
257 257
 
258 258
         // Making sure DB tables are created < v8.6.9
259
-        if (!isPgTableCreated(PG_LOGS_TABLE_NAME)){
259
+        if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) {
260 260
             createLogsTable();
261 261
         }
262
-        if (isPgTableCreated(PG_CART_PROCESS_TABLE)){
262
+        if (isPgTableCreated(PG_CART_PROCESS_TABLE)) {
263 263
             alterCartProcessTable();
264 264
         }
265 265
         checkCartProcessTable();
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
269 269
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'";
270 270
         $results = $wpdb->get_results($query, ARRAY_A);
271
-        if (count($results) == 0) {
271
+        if (count($results)==0) {
272 272
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value'  => '.'), array('%s', '%s'));
273 273
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value'  => ','), array('%s', '%s'));
274 274
         }
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
278 278
         $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'";
279 279
         $results = $wpdb->get_results($query, ARRAY_A);
280
-        if (count($results) == 0) {
280
+        if (count($results)==0) {
281 281
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value'  => '0'), array('%s', '%s'));
282 282
         }
283 283
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
286 286
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'";
287 287
         $results = $wpdb->get_results($query, ARRAY_A);
288
-        if (count($results) == 0) {
288
+        if (count($results)==0) {
289 289
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value'  => 'default'), array('%s', '%s'));
290 290
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value'  => 'default'), array('%s', '%s'));
291 291
         }
@@ -295,17 +295,17 @@  discard block
 block discarded – undo
295 295
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
296 296
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'";
297 297
         $results = $wpdb->get_results($query, ARRAY_A);
298
-        if (count($results) == 0) {
298
+        if (count($results)==0) {
299 299
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', 'value'  => 'sdk.simulator.types.CHECKOUT_PAGE'), array('%s', '%s'));
300 300
             $wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), array('%s'), array('%s'));
301 301
         }
302 302
 
303 303
         //Adapting to variable selector < v8.3.6
304
-        $variableSelector="div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price";
304
+        $variableSelector = "div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price";
305 305
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
306 306
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'";
307 307
         $results = $wpdb->get_results($query, ARRAY_A);
308
-        if (count($results) == 0) {
308
+        if (count($results)==0) {
309 309
             $wpdb->update($tableName, array('value' => $variableSelector), array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION'), array('%s'), array('%s'));
310 310
         }
311 311
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
314 314
         $query = "select * from $tableName where config='PAGANTIS_TITLE_4x'";
315 315
         $results = $wpdb->get_results($query, ARRAY_A);
316
-        if (count($results) == 0) {
316
+        if (count($results)==0) {
317 317
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_TITLE_4x', 'value'  => 'Until 4 installments, without fees'), array('%s', '%s'));
318 318
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MIN_AMOUNT_4x', 'value'  => 1), array('%s', '%s'));
319 319
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT_4x', 'value'  => 800), array('%s', '%s'));
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
327 327
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X'";
328 328
         $results = $wpdb->get_results($query, ARRAY_A);
329
-        if (count($results) == 0) {
329
+        if (count($results)==0) {
330 330
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X', 'value'  => 'default'), array('%s', '%s'));
331 331
         }
332 332
 
@@ -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_PRICE_SELECTOR'";
344 344
         $results = $wpdb->get_results($query, ARRAY_A);
345
-        if (count($results) == 0) {
345
+        if (count($results)==0) {
346 346
             $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'));
347 347
         }
348 348
 
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
         $isAtcTplPresent = isTemplatePresent(
436 436
             $template_name,
437 437
             array('single-product/add-to-cart/variation-add-to-cart-button.php',
438
-                'single-product/add-to-cart/variation.php','single-product/add-to-cart/simple.php')
438
+                'single-product/add-to-cart/variation.php', 'single-product/add-to-cart/simple.php')
439 439
         );
440 440
 
441 441
         $html = apply_filters('pagantis_simulator_selector_html', '<div class="mainPagantisSimulator"></div><div class="pagantisSimulator"></div>');
@@ -447,10 +447,10 @@  discard block
 block discarded – undo
447 447
         }
448 448
 
449 449
         $pagantisSimulator4x = 'enabled';
450
-        if (!isPluginEnabled4x() || !areMerchantKeysSet4x()  || !isCountryShopContextValid() || !isProductAmountValid4x()) {
450
+        if (!isPluginEnabled4x() || !areMerchantKeysSet4x() || !isCountryShopContextValid() || !isProductAmountValid4x()) {
451 451
             $pagantisSimulator4x = 'disabled';
452 452
         }
453
-        if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') {
453
+        if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') {
454 454
             return;
455 455
         }
456 456
 
@@ -506,12 +506,12 @@  discard block
 block discarded – undo
506 506
             $pagantisSimulator4x = 'disabled';
507 507
         }
508 508
 
509
-        if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') {
509
+        if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') {
510 510
             return;
511 511
         }
512 512
 
513 513
         $totalPrice = $product->get_price();
514
-        $formattedInstallments = number_format($totalPrice/4, 2);
514
+        $formattedInstallments = number_format($totalPrice / 4, 2);
515 515
         $simulatorMessage = sprintf(__('or 4 installments of %s€, without fees, with ', 'pagantis'), $formattedInstallments);
516 516
         $post_id = $product->get_id();
517 517
         $logo = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg';
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
      */
555 555
     public function addPagantisGateway($methods)
556 556
     {
557
-        if (! class_exists('WC_Payment_Gateway')) {
557
+        if (!class_exists('WC_Payment_Gateway')) {
558 558
             return $methods;
559 559
         }
560 560
 
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
      */
620 620
     public function pagantisRowMeta($links, $file)
621 621
     {
622
-        if ($file == plugin_basename(__FILE__)) {
622
+        if ($file==plugin_basename(__FILE__)) {
623 623
             $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>';
624 624
             $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'.
625 625
                        __('API documentation', 'pagantis').'</a>';
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
         $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME;
649 649
         $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc";
650 650
         $results = $wpdb->get_results($query);
651
-        if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) {
651
+        if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) {
652 652
             foreach ($results as $key => $result) {
653 653
                 $response[$key]['timestamp'] = $result->createdAt;
654 654
                 $response[$key]['log']       = json_decode($result->log);
@@ -675,13 +675,13 @@  discard block
 block discarded – undo
675 675
 
676 676
         $filters   = ($data->get_params());
677 677
         $secretKey = $filters['secret'];
678
-        $cfg  = get_option('woocommerce_pagantis_settings');
678
+        $cfg = get_option('woocommerce_pagantis_settings');
679 679
         $privateKey   = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null;
680 680
         $privateKey4x = isset($cfg['pagantis_private_key_4x']) ? $cfg['pagantis_private_key_4x'] : null;
681
-        if ($privateKey != $secretKey && $privateKey4x != $secretKey) {
681
+        if ($privateKey!=$secretKey && $privateKey4x!=$secretKey) {
682 682
             $response['status'] = 401;
683 683
             $response['result'] = 'Unauthorized';
684
-        } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
684
+        } elseif ($_SERVER['REQUEST_METHOD']=='POST') {
685 685
             if (count($_POST)) {
686 686
                 foreach ($_POST as $config => $value) {
687 687
                     if (isset($this->defaultConfigs[$config]) && $response['status']==null) {
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
                   and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc";
743 743
         $results = $wpdb->get_results($query);
744 744
 
745
-        if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) {
745
+        if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) {
746 746
             foreach ($results as $result) {
747 747
                 $key = $result->ID;
748 748
                 $response['message'][$key]['timestamp'] = $result->post_date;
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
      */
816 816
     private function prepareQuantitySelector($css_quantity_selector)
817 817
     {
818
-        if ($css_quantity_selector == 'default' || $css_quantity_selector == '') {
818
+        if ($css_quantity_selector=='default' || $css_quantity_selector=='') {
819 819
             $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'];
820 820
         } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it
821 821
             $css_quantity_selector = serialize(array($css_quantity_selector));
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
      */
832 832
     private function preparePriceSelector($css_price_selector)
833 833
     {
834
-        if ($css_price_selector == 'default' || $css_price_selector == '') {
834
+        if ($css_price_selector=='default' || $css_price_selector=='') {
835 835
             $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'];
836 836
         } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it
837 837
             $css_price_selector = serialize(array($css_price_selector));
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
     {
850 850
         $metaProduct = get_post_meta($product_id);
851 851
         return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) &&
852
-                $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false';
852
+                $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false';
853 853
     }
854 854
 
855 855
     /**
Please login to merge, or discard this patch.