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