Passed
Pull Request — master (#82)
by
unknown
02:32
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.
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.
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->urlToken4x
280
+                                    'key'=>$order->get_order_key(),
281
+                                    'order-received'=>$order->get_id(),
282
+                                    'origin' => '',
283
+                                    'token' => $this->urlToken4x
284 284
             );
285 285
 
286 286
             $callback_arg_user = $callback_arg;
Please login to merge, or discard this patch.
Spacing   +39 added lines, -42 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
@@ -336,7 +334,7 @@  discard block
 block discarded – undo
336 334
             if ($pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) {
337 335
                 $url = $pagantisOrder->getActionUrls()->getForm();
338 336
                 addOrderToProcessingQueue($pagantisOrder->getId(), $order->get_id(), $this->urlToken4x);
339
-                $logEntry = "Cart Added to Processing Queue" .
337
+                $logEntry = "Cart Added to Processing Queue".
340 338
                     " cart hash: ".WC()->cart->get_cart_hash().
341 339
                     " Merchant order id: ".$order->get_id().
342 340
                     " Pagantis order id: ".$pagantisOrder->getId().
@@ -360,7 +358,7 @@  discard block
 block discarded – undo
360 358
                 wc_get_template('iframe.php', $template_fields, '', $this->template_path);
361 359
             }
362 360
         } catch (\Exception $exception) {
363
-            wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error');
361
+            wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error');
364 362
             insertLogEntry($exception);
365 363
             $checkout_url = get_permalink(wc_get_page_id('checkout'));
366 364
             wp_redirect($checkout_url);
@@ -376,7 +374,7 @@  discard block
 block discarded – undo
376 374
     public function pagantisNotification()
377 375
     {
378 376
         try {
379
-            $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order';
377
+            $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order';
380 378
 
381 379
             include_once('notifyController.php');
382 380
             $notify = new WcPagantisNotify();
@@ -415,10 +413,10 @@  discard block
 block discarded – undo
415 413
      */
416 414
     public function pagantisCompleteStatus($status, $order_id, $order)
417 415
     {
418
-        if ($order->get_payment_method() == WcPagantis4xGateway::METHOD_ID) {
419
-            if ($order->get_status() == 'failed') {
416
+        if ($order->get_payment_method()==WcPagantis4xGateway::METHOD_ID) {
417
+            if ($order->get_status()=='failed') {
420 418
                 $status = 'processing';
421
-            } elseif ($order->get_status() == 'pending' && $status=='completed') {
419
+            } elseif ($order->get_status()=='pending' && $status=='completed') {
422 420
                 $status = 'processing';
423 421
             }
424 422
         }
@@ -447,8 +445,8 @@  discard block
 block discarded – undo
447 445
         $allowedCountry = (in_array(strtolower($locale), $allowedCountries));
448 446
         $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT_4x'];
449 447
         $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT_4x'];
450
-        $totalPrice = (int)$this->get_order_total();
451
-        $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0'));
448
+        $totalPrice = (int) $this->get_order_total();
449
+        $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0'));
452 450
         if ($cfg['enabled_4x']==='yes' && $cfg['pagantis_public_key_4x']!='' && $cfg['pagantis_private_key_4x']!='' &&
453 451
             $validAmount && $allowedCountry) {
454 452
             return true;
@@ -483,8 +481,8 @@  discard block
 block discarded – undo
483 481
 
484 482
             $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function
485 483
             if (strpos($redirectUrl, 'order-pay=')===false) {
486
-                $redirectUrl.="&order-pay=".$order_id;
487
-                $redirectUrl.="&token=".$this->urlToken4x;
484
+                $redirectUrl .= "&order-pay=".$order_id;
485
+                $redirectUrl .= "&token=".$this->urlToken4x;
488 486
             }
489 487
 
490 488
             return array(
@@ -492,7 +490,7 @@  discard block
 block discarded – undo
492 490
                 'redirect' => $redirectUrl
493 491
             );
494 492
         } catch (Exception $e) {
495
-            wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error');
493
+            wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error');
496 494
             return array();
497 495
         }
498 496
     }
@@ -563,7 +561,7 @@  discard block
 block discarded – undo
563 561
     private function generateUrl($url)
564 562
     {
565 563
         $parsed_url = parse_url($url);
566
-        if ($parsed_url !== false) {
564
+        if ($parsed_url!==false) {
567 565
             $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query'];
568 566
             parse_str($parsed_url['query'], $arrayParams);
569 567
             foreach ($arrayParams as $keyParam => $valueParam) {
@@ -611,11 +609,10 @@  discard block
 block discarded – undo
611 609
     private function getKeysUrl($order, $url)
612 610
     {
613 611
         $defaultFields = (get_class($order)=='WC_Order') ?
614
-            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key(), 'token' => $this->urlToken4x) :
615
-            array();
612
+            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key(), 'token' => $this->urlToken4x) : array();
616 613
 
617 614
         $parsedUrl = parse_url($url);
618
-        if ($parsedUrl !== false) {
615
+        if ($parsedUrl!==false) {
619 616
             //Replace parameters from url
620 617
             $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields);
621 618
 
@@ -660,7 +657,7 @@  discard block
 block discarded – undo
660 657
         foreach ($arrayParams as $keyParam => $valueParam) {
661 658
             preg_match('#\{{.*?}\}#', $valueParam, $match);
662 659
             if (count($match)) {
663
-                $key = str_replace(array('{{','}}'), array('',''), $match[0]);
660
+                $key = str_replace(array('{{', '}}'), array('', ''), $match[0]);
664 661
                 $arrayParams[$keyParam] = $defaultFields[$key];
665 662
             }
666 663
         }
@@ -675,12 +672,12 @@  discard block
 block discarded – undo
675 672
      */
676 673
     private function unparseUrl($parsed_url)
677 674
     {
678
-        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
675
+        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : '';
679 676
         $host     = isset($parsed_url['host']) ? $parsed_url['host'] : '';
680
-        $port     = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
681
-        $query    = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
682
-        $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
677
+        $port     = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : '';
678
+        $query    = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : '';
679
+        $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : '';
683 680
         $path     = $parsed_url['path'];
684
-        return $scheme . $host . $port . $path . $query . $fragment;
681
+        return $scheme.$host.$port.$path.$query.$fragment;
685 682
     }
686 683
 }
Please login to merge, or discard this patch.
controllers/notifyController.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -250,10 +250,10 @@
 block discarded – undo
250 250
 
251 251
         if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM
252 252
             $logMessage = "WARNING checkMerchantOrderStatus." .
253
-                          " Merchant order id:".$this->woocommerceOrder->get_id().
254
-                          " Merchant order status:".$this->woocommerceOrder->get_status().
255
-                          " Pagantis order id:".$this->pagantisOrder->getStatus().
256
-                          " Pagantis order status:".$this->pagantisOrder->getId();
253
+                            " Merchant order id:".$this->woocommerceOrder->get_id().
254
+                            " Merchant order status:".$this->woocommerceOrder->get_status().
255
+                            " Pagantis order id:".$this->pagantisOrder->getStatus().
256
+                            " Pagantis order status:".$this->pagantisOrder->getId();
257 257
             $this->insertLog(null, $logMessage);
258 258
             $this->woocommerceOrder->add_order_note($logMessage);
259 259
             $this->woocommerceOrder->save();
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
     public function processInformation()
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
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     private function getProductType()
128 128
     {
129
-        if ($_GET['product'] == '') {
129
+        if ($_GET['product']=='') {
130 130
             $this->setProduct(WcPagantisGateway::METHOD_ID);
131 131
         } else {
132 132
             $this->setProduct($_GET['product']);
@@ -153,24 +153,24 @@  discard block
 block discarded – undo
153 153
     {
154 154
         global $wpdb;
155 155
         $this->checkDbTable();
156
-        $tableName =$wpdb->prefix.PG_CART_PROCESS_TABLE;
156
+        $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
157 157
         $tokenQuery = $wpdb->prepare(
158 158
             "SELECT COUNT(wc_order_id) 
159 159
                  FROM $tableName 
160 160
                  WHERE token=%s AND order_id=%s",
161
-            array($this->getUrlToken(),$this->pagantisOrderId)
161
+            array($this->getUrlToken(), $this->pagantisOrderId)
162 162
         );
163
-        $tokenCount=$wpdb->get_var($tokenQuery);
163
+        $tokenCount = $wpdb->get_var($tokenQuery);
164 164
 
165 165
         $orderIDQuery = $wpdb->prepare(
166 166
             "SELECT COUNT(token) 
167 167
                       FROM $tableName 
168 168
                       WHERE wc_order_id=%s AND order_id=%s",
169
-            array($this->woocommerceOrderId,$this->pagantisOrderId)
169
+            array($this->woocommerceOrderId, $this->pagantisOrderId)
170 170
         );
171 171
         $orderIDCount = $wpdb->get_var($orderIDQuery);
172 172
 
173
-        if (!($tokenCount == 1 && $orderIDCount == 1)) {
173
+        if (!($tokenCount==1 && $orderIDCount==1)) {
174 174
             throw new MerchantOrderNotFoundException();
175 175
         }
176 176
     }
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
                 $status = '-';
231 231
             }
232 232
 
233
-            if ($status === Order::STATUS_CONFIRMED) {
233
+            if ($status===Order::STATUS_CONFIRMED) {
234 234
                 return true;
235 235
             }
236 236
             throw new WrongStatusException($status);
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     private function checkMerchantOrderStatus()
244 244
     {
245 245
         //Order status reference => https://docs.woocommerce.com/document/managing-orders/
246
-        $validStatus=array('on-hold', 'pending', 'failed', 'processing', 'completed');
246
+        $validStatus = array('on-hold', 'pending', 'failed', 'processing', 'completed');
247 247
         $isValidStatus = apply_filters(
248 248
             'woocommerce_valid_order_statuses_for_payment_complete',
249 249
             $validStatus,
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         );
252 252
 
253 253
         if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM
254
-            $logMessage = "WARNING checkMerchantOrderStatus." .
254
+            $logMessage = "WARNING checkMerchantOrderStatus.".
255 255
                           " Merchant order id:".$this->woocommerceOrder->get_id().
256 256
                           " Merchant order status:".$this->woocommerceOrder->get_status().
257 257
                           " Pagantis order id:".$this->pagantisOrder->getStatus().
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
     {
273 273
         $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount();
274 274
         $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total()));
275
-        if ($pagantisAmount != $wcAmount) {
275
+        if ($pagantisAmount!=$wcAmount) {
276 276
             throw new AmountMismatchException($pagantisAmount, $wcAmount);
277 277
         }
278 278
     }
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
             $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId);
297 297
         } catch (\Exception $e) {
298 298
             $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId);
299
-            if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) {
299
+            if ($this->pagantisOrder->getStatus()!==Order::STATUS_CONFIRMED) {
300 300
                 throw new UnknownException($e->getMessage());
301 301
             } else {
302 302
                 $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process';
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 
327 327
         $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
328 328
 
329
-        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
329
+        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
330 330
             createOrderProcessingTable();
331 331
         }
332 332
     }
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
         global $wpdb;
340 340
         $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME;
341 341
 
342
-        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
342
+        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
343 343
             $charset_collate = $wpdb->get_charset_collate();
344 344
             $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, 
345 345
                     createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate";
@@ -396,12 +396,12 @@  discard block
 block discarded – undo
396 396
             $metadataOrder = $this->pagantisOrder->getMetadata();
397 397
             $metadataInfo = null;
398 398
             foreach ($metadataOrder as $metadataKey => $metadataValue) {
399
-                if ($metadataKey == 'promotedProduct') {
400
-                    $metadataInfo.= "/Producto promocionado = $metadataValue";
399
+                if ($metadataKey=='promotedProduct') {
400
+                    $metadataInfo .= "/Producto promocionado = $metadataValue";
401 401
                 }
402 402
             }
403 403
 
404
-            if ($metadataInfo != null) {
404
+            if ($metadataInfo!=null) {
405 405
                 $this->woocommerceOrder->add_order_note($metadataInfo);
406 406
             }
407 407
 
@@ -469,13 +469,13 @@  discard block
 block discarded – undo
469 469
     {
470 470
         global $wpdb;
471 471
         $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME;
472
-        if ($orderId == null) {
472
+        if ($orderId==null) {
473 473
             $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT." SECOND)";
474 474
         } else {
475 475
             $query = "DELETE FROM $tableName WHERE order_id = $orderId";
476 476
         }
477 477
         $resultDelete = $wpdb->query($query);
478
-        if ($resultDelete === false) {
478
+        if ($resultDelete===false) {
479 479
             throw new ConcurrencyException();
480 480
         }
481 481
     }
@@ -490,19 +490,19 @@  discard block
 block discarded – undo
490 490
         global $wpdb;
491 491
         $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME;
492 492
         $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId));
493
-        if ($insertResult === false) {
494
-            if ($this->getOrigin() == 'Notify') {
493
+        if ($insertResult===false) {
494
+            if ($this->getOrigin()=='Notify') {
495 495
                 throw new ConcurrencyException();
496 496
             } else {
497
-                $query           =
497
+                $query =
498 498
                     sprintf(
499 499
                         "SELECT TIMESTAMPDIFF(SECOND,NOW()-INTERVAL %s SECOND, createdAt) as rest FROM %s WHERE %s",
500 500
                         self::CONCURRENCY_TIMEOUT,
501 501
                         $tableName,
502 502
                         "order_id=$orderId"
503 503
                     );
504
-                $resultSeconds=$wpdb->get_row($query);
505
-                $restSeconds  =isset($resultSeconds) ? ($resultSeconds->rest) : 0;
504
+                $resultSeconds = $wpdb->get_row($query);
505
+                $restSeconds  = isset($resultSeconds) ? ($resultSeconds->rest) : 0;
506 506
                 $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;
507 507
                 sleep($secondsToExpire + 1);
508 508
 
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
     {
530 530
         $this->unblockConcurrency($this->woocommerceOrderId);
531 531
 
532
-        if ($exception == null) {
532
+        if ($exception==null) {
533 533
             $jsonResponse = new JsonSuccessResponse();
534 534
         } else {
535 535
             $jsonResponse = new JsonExceptionResponse();
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
         $jsonResponse->setMerchantOrderId($this->woocommerceOrderId);
539 539
         $jsonResponse->setPagantisOrderId($this->pagantisOrderId);
540 540
 
541
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
541
+        if ($_SERVER['REQUEST_METHOD']=='POST') {
542 542
             $jsonResponse->printResponse();
543 543
         } else {
544 544
             return $jsonResponse;
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
      */
571 571
     private function isProduct4x()
572 572
     {
573
-        return ($this->product === Ucfirst(WcPagantis4xGateway::METHOD_ID));
573
+        return ($this->product===Ucfirst(WcPagantis4xGateway::METHOD_ID));
574 574
     }
575 575
 
576 576
     /**
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
     public function setWoocommerceOrderId()
604 604
     {
605 605
         $this->woocommerceOrderId = $_GET['order-received'];
606
-        if ($this->woocommerceOrderId == '') {
606
+        if ($this->woocommerceOrderId=='') {
607 607
             throw new QuoteNotFoundException();
608 608
         }
609 609
     }
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->urlToken = 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
@@ -369,7 +367,7 @@  discard block
 block discarded – undo
369 367
                 $url = $pagantisOrder->getActionUrls()->getForm();
370 368
                 addOrderToProcessingQueue($pagantisOrder->getId(), $order->get_id(), $this->urlToken);
371 369
 
372
-                $logEntry = "Cart Added to Processing Queue" .
370
+                $logEntry = "Cart Added to Processing Queue".
373 371
                             " cart hash: ".WC()->cart->get_cart_hash().
374 372
                             " Merchant order id: ".$order->get_id().
375 373
                             " Pagantis order id: ".$pagantisOrder->getId().
@@ -393,7 +391,7 @@  discard block
 block discarded – undo
393 391
                 wc_get_template('iframe.php', $template_fields, '', $this->template_path);
394 392
             }
395 393
         } catch (\Exception $exception) {
396
-            wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error');
394
+            wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error');
397 395
             insertLogEntry($exception);
398 396
             $checkout_url = get_permalink(wc_get_page_id('checkout'));
399 397
             wp_redirect($checkout_url);
@@ -408,7 +406,7 @@  discard block
 block discarded – undo
408 406
     public function pagantisNotification()
409 407
     {
410 408
         try {
411
-            $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order';
409
+            $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order';
412 410
 
413 411
             include_once('notifyController.php');
414 412
             $notify = new WcPagantisNotify();
@@ -447,10 +445,10 @@  discard block
 block discarded – undo
447 445
      */
448 446
     public function pagantisCompleteStatus($status, $order_id, $order)
449 447
     {
450
-        if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) {
451
-            if ($order->get_status() == 'failed') {
448
+        if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) {
449
+            if ($order->get_status()=='failed') {
452 450
                 $status = 'processing';
453
-            } elseif ($order->get_status() == 'pending' && $status=='completed') {
451
+            } elseif ($order->get_status()=='pending' && $status=='completed') {
454 452
                 $status = 'processing';
455 453
             }
456 454
         }
@@ -476,8 +474,8 @@  discard block
 block discarded – undo
476 474
         $allowedCountry = (in_array(strtolower($locale), $allowedCountries));
477 475
         $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'];
478 476
         $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT'];
479
-        $totalPrice = (int)$this->get_order_total();
480
-        $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0'));
477
+        $totalPrice = (int) $this->get_order_total();
478
+        $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0'));
481 479
         if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' &&
482 480
             $validAmount && $allowedCountry) {
483 481
             return true;
@@ -510,8 +508,8 @@  discard block
 block discarded – undo
510 508
 
511 509
             $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function
512 510
             if (strpos($redirectUrl, 'order-pay=')===false) {
513
-                $redirectUrl.="&order-pay=".$order_id;
514
-                $redirectUrl.="&token=".$this->urlToken;
511
+                $redirectUrl .= "&order-pay=".$order_id;
512
+                $redirectUrl .= "&token=".$this->urlToken;
515 513
             }
516 514
 
517 515
             return array(
@@ -519,7 +517,7 @@  discard block
 block discarded – undo
519 517
                 'redirect' => $redirectUrl
520 518
             );
521 519
         } catch (Exception $e) {
522
-            wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error');
520
+            wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error');
523 521
             return array();
524 522
         }
525 523
     }
@@ -588,7 +586,7 @@  discard block
 block discarded – undo
588 586
     private function generateUrl($url)
589 587
     {
590 588
         $parsed_url = parse_url($url);
591
-        if ($parsed_url !== false) {
589
+        if ($parsed_url!==false) {
592 590
             $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query'];
593 591
             parse_str($parsed_url['query'], $arrayParams);
594 592
             foreach ($arrayParams as $keyParam => $valueParam) {
@@ -636,11 +634,10 @@  discard block
 block discarded – undo
636 634
     private function getKeysUrl($order, $url)
637 635
     {
638 636
         $defaultFields = (get_class($order)=='WC_Order') ?
639
-            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) :
640
-            array();
637
+            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array();
641 638
 
642 639
         $parsedUrl = parse_url($url);
643
-        if ($parsedUrl !== false) {
640
+        if ($parsedUrl!==false) {
644 641
             //Replace parameters from url
645 642
             $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields);
646 643
 
@@ -685,7 +682,7 @@  discard block
 block discarded – undo
685 682
         foreach ($arrayParams as $keyParam => $valueParam) {
686 683
             preg_match('#\{{.*?}\}#', $valueParam, $match);
687 684
             if (count($match)) {
688
-                $key = str_replace(array('{{','}}'), array('',''), $match[0]);
685
+                $key = str_replace(array('{{', '}}'), array('', ''), $match[0]);
689 686
                 $arrayParams[$keyParam] = $defaultFields[$key];
690 687
             }
691 688
         }
@@ -700,12 +697,12 @@  discard block
 block discarded – undo
700 697
      */
701 698
     private function unparseUrl($parsed_url)
702 699
     {
703
-        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
700
+        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : '';
704 701
         $host     = isset($parsed_url['host']) ? $parsed_url['host'] : '';
705
-        $port     = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
706
-        $query    = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
707
-        $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
702
+        $port     = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : '';
703
+        $query    = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : '';
704
+        $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : '';
708 705
         $path     = $parsed_url['path'];
709
-        return $scheme . $host . $port . $path . $query . $fragment;
706
+        return $scheme.$host.$port.$path.$query.$fragment;
710 707
     }
711 708
 }
Please login to merge, or discard this patch.
includes/pg-functions.php 1 patch
Spacing   +41 added lines, -41 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
     }
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 function addOrderToProcessingQueue($pagantisOrderId, $wcOrderID, $paymentProcessingToken)
403 403
 {
404 404
     global $wpdb;
405
-    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
405
+    $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
406 406
     $wpdb->insert($tableName, array(
407 407
         'order_id' => $pagantisOrderId,
408 408
         'wc_order_id' => $wcOrderID,
@@ -413,8 +413,8 @@  discard block
 block discarded – undo
413 413
 function alterCartProcessingTable()
414 414
 {
415 415
     global $wpdb;
416
-    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
417
-    if (! $wpdb->get_var("SHOW COLUMNS FROM `{$tableName}` LIKE 'token'")) {
416
+    $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
417
+    if (!$wpdb->get_var("SHOW COLUMNS FROM `{$tableName}` LIKE 'token'")) {
418 418
         $wpdb->query("ALTER TABLE $tableName ADD COLUMN `token` VARCHAR(32) AFTER `wc_order_id`");
419 419
         $wpdb->query("ALTER TABLE $tableName DROP PRIMARY KEY, ADD PRIMARY KEY(order_id)");
420 420
     }
@@ -427,9 +427,9 @@  discard block
 block discarded – undo
427 427
 function createOrderProcessingTable()
428 428
 {
429 429
     global $wpdb;
430
-    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
430
+    $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
431 431
 
432
-    if (! isPgTableCreated(PG_CART_PROCESS_TABLE)) {
432
+    if (!isPgTableCreated(PG_CART_PROCESS_TABLE)) {
433 433
         $charset_collate = $wpdb->get_charset_collate();
434 434
         $sql             = "CREATE TABLE IF NOT EXISTS $tableName  
435 435
             (order_id VARCHAR(60), 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
             token VARCHAR(32), 
438 438
             PRIMARY KEY(order_id))$charset_collate";
439 439
 
440
-        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
440
+        require_once(ABSPATH.'wp-admin/includes/upgrade.php');
441 441
         dbDelta($sql);
442 442
     }
443 443
 }
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
             'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
481 481
         ));
482 482
         foreach ($customer_orders as $customer_order) {
483
-            if (trim($sign_up) == '' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) {
483
+            if (trim($sign_up)=='' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) {
484 484
                 $sign_up = substr($customer_order->post_date, 0, 10);
485 485
             }
486 486
         }
Please login to merge, or discard this patch.