Completed
Push — master ( 72ec0a...f6d0fe )
by
unknown
15s queued 11s
created
WC_Pagantis.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 }
20 20
 
21 21
 
22
-require_once(__DIR__ . '/includes/pg-functions.php');
22
+require_once(__DIR__.'/includes/pg-functions.php');
23 23
 
24 24
 /**
25 25
  * Required minimums and constants
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     public function __construct()
82 82
     {
83 83
         require_once(plugin_dir_path(__FILE__).'/vendor/autoload.php');
84
-        require_once(PG_ABSPATH . '/includes/pg-functions.php');
84
+        require_once(PG_ABSPATH.'/includes/pg-functions.php');
85 85
         $this->template_path = plugin_dir_path(__FILE__).'/templates/';
86 86
 
87 87
         $this->pagantisActivation();
@@ -97,15 +97,15 @@  discard block
 block discarded – undo
97 97
         add_action('init', array($this, 'checkWcPriceSettings'), 10);
98 98
         add_action('woocommerce_after_template_part', array($this, 'pagantisAddSimulatorHtmlDiv'), 10);
99 99
         add_action('woocommerce_single_product_summary', array($this, 'pagantisInitProductSimulator'), 20);
100
-        add_action('woocommerce_single_variation', array($this,'pagantisAddProductSnippetForVariations'), 30);
100
+        add_action('woocommerce_single_variation', array($this, 'pagantisAddProductSnippetForVariations'), 30);
101 101
         add_action('wp_enqueue_scripts', 'add_pagantis_widget_js');
102 102
         add_action('rest_api_init', array($this, 'pagantisRegisterEndpoint')); //Endpoint
103 103
         add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2);
104 104
         register_activation_hook(__FILE__, array($this, 'pagantisActivation'));
105 105
         add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl'));
106 106
         add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave'));
107
-        add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate'));
108
-        add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave'));
107
+        add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate'));
108
+        add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave'));
109 109
     }
110 110
 
111 111
     /**
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     {
132 132
         $post_id = $product->get_id();
133 133
         $pagantis_promoted_value = $_REQUEST['pagantis_promoted'];
134
-        if ($pagantis_promoted_value === 'on') {
134
+        if ($pagantis_promoted_value==='on') {
135 135
             $pagantis_promoted_value = 'yes';
136 136
         } else {
137 137
             $pagantis_promoted_value = 'no';
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
     public function pagantisPromotedVarSave($post_id)
166 166
     {
167 167
         $pagantis_promoted_value = $_POST['pagantis_promoted'];
168
-        if ($pagantis_promoted_value !== 'yes') {
168
+        if ($pagantis_promoted_value!=='yes') {
169 169
             $pagantis_promoted_value = 'no';
170 170
         }
171 171
 
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
      */
180 180
     public function loadPagantisTranslation($mofile, $domain)
181 181
     {
182
-        if ('pagantis' === $domain) {
183
-            $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo';
182
+        if ('pagantis'===$domain) {
183
+            $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo';
184 184
         }
185 185
         return $mofile;
186 186
     }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         global $wpdb;
194 194
 
195 195
         $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME;
196
-        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
196
+        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
197 197
             $charset_collate = $wpdb->get_charset_collate();
198 198
             $sql = "CREATE TABLE $tableName ( order_id int NOT NULL,  
199 199
                     createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate";
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
205 205
 
206 206
         //Check if table exists
207
-        $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName;
207
+        $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName;
208 208
         if ($tableExists) {
209 209
             $charset_collate = $wpdb->get_charset_collate();
210 210
             $sql = "CREATE TABLE IF NOT EXISTS $tableName (
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
             //Updated value field to adapt to new length < v8.0.1
220 220
             $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'";
221 221
             $results = $wpdb->get_results($query, ARRAY_A);
222
-            if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') {
222
+            if ($results['0']['COLUMN_TYPE']=='varchar(100)') {
223 223
                 $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)";
224 224
                 $wpdb->query($sql);
225 225
             }
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
                                or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'";
230 230
             $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A);
231 231
             foreach ($dbCurrentConfig as $item) {
232
-                if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') {
232
+                if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') {
233 233
                     $css_price_selector = $this->preparePriceSelector($item['value']);
234
-                    if ($item['value'] != $css_price_selector) {
234
+                    if ($item['value']!=$css_price_selector) {
235 235
                         $wpdb->update(
236 236
                             $tableName,
237 237
                             array('value' => stripslashes($css_price_selector)),
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
                             array('%s')
241 241
                         );
242 242
                     }
243
-                } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') {
243
+                } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') {
244 244
                     $css_quantity_selector = $this->prepareQuantitySelector($item['value']);
245
-                    if ($item['value'] != $css_quantity_selector) {
245
+                    if ($item['value']!=$css_quantity_selector) {
246 246
                         $wpdb->update(
247 247
                             $tableName,
248 248
                             array('value' => stripslashes($css_quantity_selector)),
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
         }
257 257
 
258 258
         // Making sure DB tables are created < v8.6.9
259
-        if (!isPgTableCreated(PG_LOGS_TABLE_NAME)){
259
+        if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) {
260 260
             createLogsTable();
261 261
         }
262
-        if (isPgTableCreated(PG_CART_PROCESS_TABLE)){
262
+        if (isPgTableCreated(PG_CART_PROCESS_TABLE)) {
263 263
             alterCartProcessTable();
264 264
         }
265 265
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
272 272
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'";
273 273
         $results = $wpdb->get_results($query, ARRAY_A);
274
-        if (count($results) == 0) {
274
+        if (count($results)==0) {
275 275
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value'  => '.'), array('%s', '%s'));
276 276
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value'  => ','), array('%s', '%s'));
277 277
         }
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
281 281
         $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'";
282 282
         $results = $wpdb->get_results($query, ARRAY_A);
283
-        if (count($results) == 0) {
283
+        if (count($results)==0) {
284 284
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value'  => '0'), array('%s', '%s'));
285 285
         }
286 286
 
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
289 289
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'";
290 290
         $results = $wpdb->get_results($query, ARRAY_A);
291
-        if (count($results) == 0) {
291
+        if (count($results)==0) {
292 292
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value'  => 'default'), array('%s', '%s'));
293 293
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value'  => 'default'), array('%s', '%s'));
294 294
         }
@@ -298,17 +298,17 @@  discard block
 block discarded – undo
298 298
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
299 299
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'";
300 300
         $results = $wpdb->get_results($query, ARRAY_A);
301
-        if (count($results) == 0) {
301
+        if (count($results)==0) {
302 302
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', 'value'  => 'sdk.simulator.types.CHECKOUT_PAGE'), array('%s', '%s'));
303 303
             $wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), array('%s'), array('%s'));
304 304
         }
305 305
 
306 306
         //Adapting to variable selector < v8.3.6
307
-        $variableSelector="div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price";
307
+        $variableSelector = "div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price";
308 308
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
309 309
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'";
310 310
         $results = $wpdb->get_results($query, ARRAY_A);
311
-        if (count($results) == 0) {
311
+        if (count($results)==0) {
312 312
             $wpdb->update($tableName, array('value' => $variableSelector), array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION'), array('%s'), array('%s'));
313 313
         }
314 314
 
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
317 317
         $query = "select * from $tableName where config='PAGANTIS_TITLE_4x'";
318 318
         $results = $wpdb->get_results($query, ARRAY_A);
319
-        if (count($results) == 0) {
319
+        if (count($results)==0) {
320 320
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_TITLE_4x', 'value'  => 'Until 4 installments, without fees'), array('%s', '%s'));
321 321
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MIN_AMOUNT_4x', 'value'  => 1), array('%s', '%s'));
322 322
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT_4x', 'value'  => 800), array('%s', '%s'));
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
330 330
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X'";
331 331
         $results = $wpdb->get_results($query, ARRAY_A);
332
-        if (count($results) == 0) {
332
+        if (count($results)==0) {
333 333
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X', 'value'  => 'default'), array('%s', '%s'));
334 334
         }
335 335
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
         $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
346 346
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'";
347 347
         $results = $wpdb->get_results($query, ARRAY_A);
348
-        if (count($results) == 0) {
348
+        if (count($results)==0) {
349 349
             $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'));
350 350
         }
351 351
 
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
      */
385 385
     public function checkWcPriceSettings()
386 386
     {
387
-        if (class_exists( 'WooCommerce' ) ){
387
+        if (class_exists('WooCommerce')) {
388 388
             $this->checkWcDecimalSeparatorSettings();
389 389
             $this->checkWcThousandsSeparatorSettings();
390 390
         }
@@ -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
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
                 if ($promotedProduct == 'true') {
258 258
                     $promotedAmount+=$product->getAmount();
259 259
                     $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() .
260
-                                       ' - Price: ' . $item->get_total() .
261
-                                       ' - Qty: ' . $product->getQuantity() .
262
-                                       ' - Item ID: ' . $item['id_product'];
260
+                                        ' - Price: ' . $item->get_total() .
261
+                                        ' - Qty: ' . $product->getQuantity() .
262
+                                        ' - Item ID: ' . $item['id_product'];
263 263
                     $promotedMessage = substr($promotedMessage, 0, 999);
264 264
                     $metadataOrder->addMetadata('promotedProduct', $promotedMessage);
265 265
                 }
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
             $orderConfigurationUrls = new Urls();
276 276
             $cancelUrl = $this->getKoUrl($order);
277 277
             $callback_arg = array('wc-api'=>'wcpagantisgateway',
278
-                                  'key'=>$order->get_order_key(),
279
-                                  'order-received'=>$order->get_id(),
280
-                                  'origin' => '',
281
-                                  'token' => $this->urlToken4x
278
+                                    'key'=>$order->get_order_key(),
279
+                                    'order-received'=>$order->get_id(),
280
+                                    'origin' => '',
281
+                                    'token' => $this->urlToken4x
282 282
 
283 283
             );
284 284
 
Please login to merge, or discard this patch.
Spacing   +38 added lines, -41 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $this->urlToken4x = strtoupper(md5(uniqid(rand(), true)));
67 67
 
68 68
         //Useful vars
69
-        $this->template_path = plugin_dir_path(__FILE__) . '../templates/';
69
+        $this->template_path = plugin_dir_path(__FILE__).'../templates/';
70 70
         $this->allowed_currencies = getAllowedCurrencies();
71 71
         $this->language = strstr(get_locale(), '_', true);
72 72
         if ($this->language=='') {
@@ -75,24 +75,24 @@  discard block
 block discarded – undo
75 75
         $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg';
76 76
 
77 77
         //Panel form fields
78
-        $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options
78
+        $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options
79 79
         $this->init_settings();
80 80
 
81 81
         $this->extraConfig = getExtraConfig();
82 82
         $this->title = __($this->extraConfig['PAGANTIS_TITLE_4x'], 'pagantis');
83 83
         $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis.";
84 84
 
85
-        $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl();
86
-        $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl();
85
+        $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl();
86
+        $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl();
87 87
         foreach ($this->settings as $setting_key => $setting_value) {
88 88
             $this->$setting_key = $setting_value;
89 89
         }
90 90
 
91 91
         //Hooks
92
-        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options
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);
92
+        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options
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
     }
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
             $shippingAddress = $order->get_address('shipping');
156 156
             $billingAddress = $order->get_address('billing');
157
-            if ($shippingAddress['address_1'] == '') {
157
+            if ($shippingAddress['address_1']=='') {
158 158
                 $shippingAddress = $billingAddress;
159 159
             }
160 160
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
                 ->setNationalId($national_id)
182 182
                 ->setTaxId($tax_id)
183 183
             ;
184
-            $orderBillingAddress =  new Address();
184
+            $orderBillingAddress = new Address();
185 185
             $orderBillingAddress
186 186
                 ->setZipCode($billingAddress['postcode'])
187 187
                 ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name'])
@@ -254,12 +254,12 @@  discard block
 block discarded – undo
254 254
                 $details->addProduct($product);
255 255
 
256 256
                 $promotedProduct = isProductPromoted($item->get_product_id());
257
-                if ($promotedProduct == 'true') {
258
-                    $promotedAmount+=$product->getAmount();
259
-                    $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() .
260
-                                       ' - Price: ' . $item->get_total() .
261
-                                       ' - Qty: ' . $product->getQuantity() .
262
-                                       ' - Item ID: ' . $item['id_product'];
257
+                if ($promotedProduct=='true') {
258
+                    $promotedAmount += $product->getAmount();
259
+                    $promotedMessage = 'Promoted Item: '.$wcProduct->get_name().
260
+                                       ' - Price: '.$item->get_total().
261
+                                       ' - Qty: '.$product->getQuantity().
262
+                                       ' - Item ID: '.$item['id_product'];
263 263
                     $promotedMessage = substr($promotedMessage, 0, 999);
264 264
                     $metadataOrder->addMetadata('promotedProduct', $promotedMessage);
265 265
                 }
@@ -307,9 +307,7 @@  discard block
 block discarded – undo
307 307
 
308 308
             $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']);
309 309
             $purchaseCountry =
310
-                in_array(strtolower($this->language), $allowedCountries) ? $this->language :
311
-                    in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] :
312
-                        in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null;
310
+                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;
313 311
 
314 312
             $orderConfiguration = new Configuration();
315 313
             $orderConfiguration
@@ -334,7 +332,7 @@  discard block
 block discarded – undo
334 332
             $pagantisOrder = $orderClient->createOrder($orderApiClient);
335 333
             if ($pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) {
336 334
                 $url = $pagantisOrder->getActionUrls()->getForm();
337
-                addOrderToProcessingQueue($pagantisOrder->getId(), $order->get_id(), $this->urlToken4x,self::METHOD_ID);
335
+                addOrderToProcessingQueue($pagantisOrder->getId(), $order->get_id(), $this->urlToken4x, self::METHOD_ID);
338 336
             } else {
339 337
                 throw new OrderNotFoundException();
340 338
             }
@@ -353,7 +351,7 @@  discard block
 block discarded – undo
353 351
                 wc_get_template('iframe.php', $template_fields, '', $this->template_path);
354 352
             }
355 353
         } catch (\Exception $exception) {
356
-            wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error');
354
+            wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error');
357 355
             insertLogEntry($exception);
358 356
             $checkout_url = get_permalink(wc_get_page_id('checkout'));
359 357
             wp_redirect($checkout_url);
@@ -369,7 +367,7 @@  discard block
 block discarded – undo
369 367
     public function pagantisNotification()
370 368
     {
371 369
         try {
372
-            $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order';
370
+            $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order';
373 371
 
374 372
             include_once('notifyController.php');
375 373
             $notify = new WcPagantisNotify();
@@ -408,10 +406,10 @@  discard block
 block discarded – undo
408 406
      */
409 407
     public function pagantisCompleteStatus($status, $order_id, $order)
410 408
     {
411
-        if ($order->get_payment_method() == WcPagantis4xGateway::METHOD_ID) {
412
-            if ($order->get_status() == 'failed') {
409
+        if ($order->get_payment_method()==WcPagantis4xGateway::METHOD_ID) {
410
+            if ($order->get_status()=='failed') {
413 411
                 $status = 'processing';
414
-            } elseif ($order->get_status() == 'pending' && $status=='completed') {
412
+            } elseif ($order->get_status()=='pending' && $status=='completed') {
415 413
                 $status = 'processing';
416 414
             }
417 415
         }
@@ -440,8 +438,8 @@  discard block
 block discarded – undo
440 438
         $allowedCountry = (in_array(strtolower($locale), $allowedCountries));
441 439
         $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT_4x'];
442 440
         $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT_4x'];
443
-        $totalPrice = (int)$this->get_order_total();
444
-        $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0'));
441
+        $totalPrice = (int) $this->get_order_total();
442
+        $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0'));
445 443
         if ($cfg['enabled_4x']==='yes' && $cfg['pagantis_public_key_4x']!='' && $cfg['pagantis_private_key_4x']!='' &&
446 444
             $validAmount && $allowedCountry) {
447 445
             return true;
@@ -476,7 +474,7 @@  discard block
 block discarded – undo
476 474
 
477 475
             $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function
478 476
             if (strpos($redirectUrl, 'order-pay=')===false) {
479
-                $redirectUrl.="&order-pay=".$order_id;
477
+                $redirectUrl .= "&order-pay=".$order_id;
480 478
             }
481 479
 
482 480
             return array(
@@ -484,7 +482,7 @@  discard block
 block discarded – undo
484 482
                 'redirect' => $redirectUrl
485 483
             );
486 484
         } catch (Exception $e) {
487
-            wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error');
485
+            wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error');
488 486
             return array();
489 487
         }
490 488
     }
@@ -555,7 +553,7 @@  discard block
 block discarded – undo
555 553
     private function generateUrl($url)
556 554
     {
557 555
         $parsed_url = parse_url($url);
558
-        if ($parsed_url !== false) {
556
+        if ($parsed_url!==false) {
559 557
             $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query'];
560 558
             parse_str($parsed_url['query'], $arrayParams);
561 559
             foreach ($arrayParams as $keyParam => $valueParam) {
@@ -603,11 +601,10 @@  discard block
 block discarded – undo
603 601
     private function getKeysUrl($order, $url)
604 602
     {
605 603
         $defaultFields = (get_class($order)=='WC_Order') ?
606
-            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) :
607
-            array();
604
+            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array();
608 605
 
609 606
         $parsedUrl = parse_url($url);
610
-        if ($parsedUrl !== false) {
607
+        if ($parsedUrl!==false) {
611 608
             //Replace parameters from url
612 609
             $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields);
613 610
 
@@ -652,7 +649,7 @@  discard block
 block discarded – undo
652 649
         foreach ($arrayParams as $keyParam => $valueParam) {
653 650
             preg_match('#\{{.*?}\}#', $valueParam, $match);
654 651
             if (count($match)) {
655
-                $key = str_replace(array('{{','}}'), array('',''), $match[0]);
652
+                $key = str_replace(array('{{', '}}'), array('', ''), $match[0]);
656 653
                 $arrayParams[$keyParam] = $defaultFields[$key];
657 654
             }
658 655
         }
@@ -667,12 +664,12 @@  discard block
 block discarded – undo
667 664
      */
668 665
     private function unparseUrl($parsed_url)
669 666
     {
670
-        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
667
+        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : '';
671 668
         $host     = isset($parsed_url['host']) ? $parsed_url['host'] : '';
672
-        $port     = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
673
-        $query    = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
674
-        $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
669
+        $port     = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : '';
670
+        $query    = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : '';
671
+        $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : '';
675 672
         $path     = $parsed_url['path'];
676
-        return $scheme . $host . $port . $path . $query . $fragment;
673
+        return $scheme.$host.$port.$path.$query.$fragment;
677 674
     }
678 675
 }
Please login to merge, or discard this patch.
controllers/notifyController.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         try {
69 69
             require_once(__ROOT__.'/vendor/autoload.php');
70 70
             try {
71
-                if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_GET['origin'] == 'notification') {
71
+                if ($_SERVER['REQUEST_METHOD']=='GET' && $_GET['origin']=='notification') {
72 72
                     return $this->buildResponse();
73 73
                 }
74 74
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     private function checkConcurrency()
120 120
     {
121 121
         $this->woocommerceOrderId = $_GET['order-received'];
122
-        if ($this->woocommerceOrderId == '') {
122
+        if ($this->woocommerceOrderId=='') {
123 123
             throw new QuoteNotFoundException();
124 124
         }
125 125
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      */
133 133
     private function getProductType()
134 134
     {
135
-        if ($_GET['product'] == '') {
135
+        if ($_GET['product']=='') {
136 136
             $this->setProduct(WcPagantisGateway::METHOD_ID);
137 137
         } else {
138 138
             $this->setProduct($_GET['product']);
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         $order_id = $wpdb->get_var("SELECT order_id FROM $tableName WHERE token='{$this->getUrlToken()}' ");
168 168
         $this->pagantisOrderId = $order_id;
169 169
 
170
-        if ($this->pagantisOrderId == '') {
170
+        if ($this->pagantisOrderId=='') {
171 171
             throw new NoIdentificationException();
172 172
         }
173 173
     }
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
                 $status = '-';
211 211
             }
212 212
 
213
-            if ($status === Order::STATUS_CONFIRMED) {
213
+            if ($status===Order::STATUS_CONFIRMED) {
214 214
                 return true;
215 215
             }
216 216
             throw new WrongStatusException($status);
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
         );
232 232
 
233 233
         if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM
234
-            $logMessage = "WARNING checkMerchantOrderStatus." .
234
+            $logMessage = "WARNING checkMerchantOrderStatus.".
235 235
                           " Merchant order id:".$this->woocommerceOrder->get_id().
236 236
                           " Merchant order status:".$this->woocommerceOrder->get_status().
237 237
                           " Pagantis order id:".$this->pagantisOrder->getStatus().
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
     {
254 254
         $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount();
255 255
         $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total()));
256
-        if ($pagantisAmount != $wcAmount) {
256
+        if ($pagantisAmount!=$wcAmount) {
257 257
             throw new AmountMismatchException($pagantisAmount, $wcAmount);
258 258
         }
259 259
     }
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
             $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId);
278 278
         } catch (\Exception $e) {
279 279
             $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId);
280
-            if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) {
280
+            if ($this->pagantisOrder->getStatus()!==Order::STATUS_CONFIRMED) {
281 281
                 throw new UnknownException($e->getMessage());
282 282
             } else {
283 283
                 $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process';
@@ -301,9 +301,9 @@  discard block
 block discarded – undo
301 301
         global $wpdb;
302 302
         $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
303 303
 
304
-        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
304
+        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
305 305
             $charset_collate = $wpdb->get_charset_collate();
306
-            $sql= "CREATE TABLE IF NOT EXISTS $tableName
306
+            $sql = "CREATE TABLE IF NOT EXISTS $tableName
307 307
                 (id INT, 
308 308
                 order_id varchar(60),
309 309
                 wc_order_id varchar(60),
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
         global $wpdb;
325 325
         $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME;
326 326
 
327
-        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
327
+        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
328 328
             $charset_collate = $wpdb->get_charset_collate();
329 329
             $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, 
330 330
                     createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate";
@@ -381,12 +381,12 @@  discard block
 block discarded – undo
381 381
             $metadataOrder = $this->pagantisOrder->getMetadata();
382 382
             $metadataInfo = null;
383 383
             foreach ($metadataOrder as $metadataKey => $metadataValue) {
384
-                if ($metadataKey == 'promotedProduct') {
385
-                    $metadataInfo.= "/Producto promocionado = $metadataValue";
384
+                if ($metadataKey=='promotedProduct') {
385
+                    $metadataInfo .= "/Producto promocionado = $metadataValue";
386 386
                 }
387 387
             }
388 388
 
389
-            if ($metadataInfo != null) {
389
+            if ($metadataInfo!=null) {
390 390
                 $this->woocommerceOrder->add_order_note($metadataInfo);
391 391
             }
392 392
 
@@ -414,9 +414,9 @@  discard block
 block discarded – undo
414 414
         $wpdb->update(
415 415
             $tableName,
416 416
             array('wc_order_id'=>$this->woocommerceOrderId),
417
-            array('token' => $this->getUrlToken(),'order_id' => $this->pagantisOrderId),
418
-            array( '%s'),
419
-            array( '%s', '%s' )
417
+            array('token' => $this->getUrlToken(), 'order_id' => $this->pagantisOrderId),
418
+            array('%s'),
419
+            array('%s', '%s')
420 420
         );
421 421
     }
422 422
 
@@ -454,13 +454,13 @@  discard block
 block discarded – undo
454 454
     {
455 455
         global $wpdb;
456 456
         $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME;
457
-        if ($orderId == null) {
457
+        if ($orderId==null) {
458 458
             $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT." SECOND)";
459 459
         } else {
460 460
             $query = "DELETE FROM $tableName WHERE order_id = $orderId";
461 461
         }
462 462
         $resultDelete = $wpdb->query($query);
463
-        if ($resultDelete === false) {
463
+        if ($resultDelete===false) {
464 464
             throw new ConcurrencyException();
465 465
         }
466 466
     }
@@ -475,8 +475,8 @@  discard block
 block discarded – undo
475 475
         global $wpdb;
476 476
         $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME;
477 477
         $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId));
478
-        if ($insertResult === false) {
479
-            if ($this->getOrigin() == 'Notify') {
478
+        if ($insertResult===false) {
479
+            if ($this->getOrigin()=='Notify') {
480 480
                 throw new ConcurrencyException();
481 481
             } else {
482 482
                 $query = sprintf(
@@ -487,8 +487,8 @@  discard block
 block discarded – undo
487 487
                 );
488 488
                 $resultSeconds = $wpdb->get_row($query);
489 489
                 $restSeconds = isset($resultSeconds) ? ($resultSeconds->rest) : 0;
490
-                $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;
491
-                sleep($secondsToExpire+1);
490
+                $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;
491
+                sleep($secondsToExpire + 1);
492 492
 
493 493
                 $logMessage = sprintf(
494 494
                     "User waiting %s seconds, default seconds %s, bd time to expire %s seconds",
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
     {
513 513
         $this->unblockConcurrency($this->woocommerceOrderId);
514 514
 
515
-        if ($exception == null) {
515
+        if ($exception==null) {
516 516
             $jsonResponse = new JsonSuccessResponse();
517 517
         } else {
518 518
             $jsonResponse = new JsonExceptionResponse();
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
         $jsonResponse->setMerchantOrderId($this->woocommerceOrderId);
523 523
         $jsonResponse->setPagantisOrderId($this->pagantisOrderId);
524 524
 
525
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
525
+        if ($_SERVER['REQUEST_METHOD']=='POST') {
526 526
             $jsonResponse->printResponse();
527 527
         } else {
528 528
             return $jsonResponse;
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
      */
555 555
     private function isProduct4x()
556 556
     {
557
-        return ($this->product === Ucfirst(WcPagantis4xGateway::METHOD_ID));
557
+        return ($this->product===Ucfirst(WcPagantis4xGateway::METHOD_ID));
558 558
     }
559 559
 
560 560
     /**
@@ -594,13 +594,13 @@  discard block
 block discarded – undo
594 594
      */
595 595
     private function setUrlToken()
596 596
     {
597
-        if (!isset($_GET['token'])){
598
-            $logEntry = '$_GET[\'token\'] is empty' .
597
+        if (!isset($_GET['token'])) {
598
+            $logEntry = '$_GET[\'token\'] is empty'.
599 599
                 " cart hash: ".WC()->cart->get_cart_hash().
600 600
                 " Merchant order id: ".$this->woocommerceOrderId.
601 601
                 " Pagantis order id: ".$this->pagantisOrderId.
602 602
                 " Pagantis urlToken: ".$this->getUrlToken().
603
-                " Function: " . __FUNCTION__;
603
+                " Function: ".__FUNCTION__;
604 604
             insertLogEntry(null, $logEntry);
605 605
         }
606 606
 
Please login to merge, or discard this patch.
controllers/paymentController.php 1 patch
Spacing   +48 added lines, -51 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
@@ -385,7 +383,7 @@  discard block
 block discarded – undo
385 383
                 wc_get_template('iframe.php', $template_fields, '', $this->template_path);
386 384
             }
387 385
         } catch (\Exception $exception) {
388
-            wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error');
386
+            wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error');
389 387
             insertLogEntry($exception);
390 388
             $checkout_url = get_permalink(wc_get_page_id('checkout'));
391 389
             wp_redirect($checkout_url);
@@ -400,7 +398,7 @@  discard block
 block discarded – undo
400 398
     public function pagantisNotification()
401 399
     {
402 400
         try {
403
-            $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order';
401
+            $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order';
404 402
 
405 403
             include_once('notifyController.php');
406 404
             $notify = new WcPagantisNotify();
@@ -439,10 +437,10 @@  discard block
 block discarded – undo
439 437
      */
440 438
     public function pagantisCompleteStatus($status, $order_id, $order)
441 439
     {
442
-        if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) {
443
-            if ($order->get_status() == 'failed') {
440
+        if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) {
441
+            if ($order->get_status()=='failed') {
444 442
                 $status = 'processing';
445
-            } elseif ($order->get_status() == 'pending' && $status=='completed') {
443
+            } elseif ($order->get_status()=='pending' && $status=='completed') {
446 444
                 $status = 'processing';
447 445
             }
448 446
         }
@@ -468,8 +466,8 @@  discard block
 block discarded – undo
468 466
         $allowedCountry = (in_array(strtolower($locale), $allowedCountries));
469 467
         $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'];
470 468
         $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT'];
471
-        $totalPrice = (int)$this->get_order_total();
472
-        $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0'));
469
+        $totalPrice = (int) $this->get_order_total();
470
+        $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0'));
473 471
         if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' &&
474 472
             $validAmount && $allowedCountry) {
475 473
             return true;
@@ -502,7 +500,7 @@  discard block
 block discarded – undo
502 500
 
503 501
             $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function
504 502
             if (strpos($redirectUrl, 'order-pay=')===false) {
505
-                $redirectUrl.="&order-pay=".$order_id;
503
+                $redirectUrl .= "&order-pay=".$order_id;
506 504
             }
507 505
 
508 506
             return array(
@@ -510,7 +508,7 @@  discard block
 block discarded – undo
510 508
                 'redirect' => $redirectUrl
511 509
             );
512 510
         } catch (Exception $e) {
513
-            wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error');
511
+            wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error');
514 512
             return array();
515 513
         }
516 514
     }
@@ -579,7 +577,7 @@  discard block
 block discarded – undo
579 577
     private function generateUrl($url)
580 578
     {
581 579
         $parsed_url = parse_url($url);
582
-        if ($parsed_url !== false) {
580
+        if ($parsed_url!==false) {
583 581
             $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query'];
584 582
             parse_str($parsed_url['query'], $arrayParams);
585 583
             foreach ($arrayParams as $keyParam => $valueParam) {
@@ -627,11 +625,10 @@  discard block
 block discarded – undo
627 625
     private function getKeysUrl($order, $url)
628 626
     {
629 627
         $defaultFields = (get_class($order)=='WC_Order') ?
630
-            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) :
631
-            array();
628
+            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array();
632 629
 
633 630
         $parsedUrl = parse_url($url);
634
-        if ($parsedUrl !== false) {
631
+        if ($parsedUrl!==false) {
635 632
             //Replace parameters from url
636 633
             $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields);
637 634
 
@@ -676,7 +673,7 @@  discard block
 block discarded – undo
676 673
         foreach ($arrayParams as $keyParam => $valueParam) {
677 674
             preg_match('#\{{.*?}\}#', $valueParam, $match);
678 675
             if (count($match)) {
679
-                $key = str_replace(array('{{','}}'), array('',''), $match[0]);
676
+                $key = str_replace(array('{{', '}}'), array('', ''), $match[0]);
680 677
                 $arrayParams[$keyParam] = $defaultFields[$key];
681 678
             }
682 679
         }
@@ -691,13 +688,13 @@  discard block
 block discarded – undo
691 688
      */
692 689
     private function unparseUrl($parsed_url)
693 690
     {
694
-        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
691
+        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : '';
695 692
         $host     = isset($parsed_url['host']) ? $parsed_url['host'] : '';
696
-        $port     = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
697
-        $query    = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
698
-        $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
693
+        $port     = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : '';
694
+        $query    = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : '';
695
+        $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : '';
699 696
         $path     = $parsed_url['path'];
700
-        return $scheme . $host . $port . $path . $query . $fragment;
697
+        return $scheme.$host.$port.$path.$query.$fragment;
701 698
     }
702 699
 
703 700
 }
Please login to merge, or discard this patch.
includes/pg-functions.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 function requireWPPluginFunctions()
4 4
 {
5
-    if (! function_exists('is_plugin_active')) {
6
-        require_once(ABSPATH . 'wp-admin/includes/plugin.php');
5
+    if (!function_exists('is_plugin_active')) {
6
+        require_once(ABSPATH.'wp-admin/includes/plugin.php');
7 7
     }
8 8
 }
9 9
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 function getConfigValue($configKey)
22 22
 {
23 23
     global $wpdb;
24
-    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
24
+    $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
25 25
     $value     = $wpdb->get_var($wpdb->prepare("SELECT value FROM $tableName WHERE config= %s ", $configKey));
26 26
 
27 27
     return $value;
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 function isPgTableCreated($tableToCheck)
39 39
 {
40 40
     global $wpdb;
41
-    $tableName = $wpdb->prefix . $tableToCheck;
42
-    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) {
41
+    $tableName = $wpdb->prefix.$tableToCheck;
42
+    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")==$tableName) {
43 43
         return true;
44 44
     }
45 45
 
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 function createPgCartTable()
53 53
 {
54 54
     global $wpdb;
55
-    $tableName       = $wpdb->prefix . PG_CART_PROCESS_TABLE;
55
+    $tableName       = $wpdb->prefix.PG_CART_PROCESS_TABLE;
56 56
     $charset_collate = $wpdb->get_charset_collate();
57 57
     $sql             = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50),  
58 58
                   UNIQUE KEY id (id)) $charset_collate";
59 59
 
60
-    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
60
+    require_once(ABSPATH.'wp-admin/includes/upgrade.php');
61 61
     dbDelta($sql);
62 62
 }
63 63
 
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 {
66 66
     global $wpdb;
67 67
     $charset_collate = $wpdb->get_charset_collate();
68
-    $LogsTableName   = $wpdb->prefix . PG_LOGS_TABLE_NAME;
68
+    $LogsTableName   = $wpdb->prefix.PG_LOGS_TABLE_NAME;
69 69
     $sqlQuery        = "CREATE TABLE $LogsTableName ( 
70 70
     id int NOT NULL AUTO_INCREMENT,
71 71
     log text NOT NULL, 
72 72
     createdAt timestamp DEFAULT CURRENT_TIMESTAMP,
73 73
     UNIQUE KEY id (id)) 
74 74
     $charset_collate";
75
-    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
75
+    require_once(ABSPATH.'wp-admin/includes/upgrade.php');
76 76
     dbDelta($sqlQuery);
77 77
 }
78 78
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 function insertLogEntry($exception = null, $message = null)
84 84
 {
85 85
     global $wpdb;
86
-    if (! isPgTableCreated(PG_LOGS_TABLE_NAME)) {
86
+    if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) {
87 87
         createLogsTable();
88 88
     }
89 89
     $logEntry = new Pagantis\ModuleUtils\Model\Log\LogEntry();
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     } else {
93 93
         $logEntry = $logEntry->info($message);
94 94
     }
95
-    $tableName = $wpdb->prefix . PG_LOGS_TABLE_NAME;
95
+    $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME;
96 96
     $wpdb->insert($tableName, array('log' => $logEntry->toJson()));
97 97
 }
98 98
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 {
104 104
     $pgDecimalSeparator = getPgSimulatorDecimalSeparatorConfig();
105 105
     $wc_decimal_sep     = get_option('woocommerce_price_decimal_sep');
106
-    if (stripslashes($wc_decimal_sep) == stripslashes($pgDecimalSeparator)) {
106
+    if (stripslashes($wc_decimal_sep)==stripslashes($pgDecimalSeparator)) {
107 107
         return true;
108 108
     } else {
109 109
         return false;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 {
119 119
     $pgThousandSeparator = getPgSimulatorThousandsSeparator();
120 120
     $wc_price_thousand   = get_option('woocommerce_price_thousand_sep');
121
-    if (stripslashes($wc_price_thousand) == stripslashes($pgThousandSeparator)) {
121
+    if (stripslashes($wc_price_thousand)==stripslashes($pgThousandSeparator)) {
122 122
         return true;
123 123
     } else {
124 124
         return false;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 function getPgSimulatorThousandsSeparator()
132 132
 {
133 133
     global $wpdb;
134
-    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
134
+    $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
135 135
     $query     = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'";
136 136
     $result    = $wpdb->get_row($query, ARRAY_A);
137 137
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 function getPgSimulatorDecimalSeparatorConfig()
145 145
 {
146 146
     global $wpdb;
147
-    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
147
+    $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
148 148
     $query     = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'";
149 149
     $result    = $wpdb->get_row($query, ARRAY_A);
150 150
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     if (areThousandsSeparatorEqual()) {
158 158
         return;
159 159
     }
160
-    $tableName         = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
160
+    $tableName         = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
161 161
     $thousandSeparator = get_option('woocommerce_price_thousand_sep');
162 162
     $wpdb->update(
163 163
         $tableName,
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
     if (areDecimalSeparatorEqual()) {
175 175
         return;
176 176
     }
177
-    $tableName        = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
177
+    $tableName        = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
178 178
     $decimalSeparator = get_option('woocommerce_price_decimal_sep');
179 179
     $wpdb->update(
180 180
         $tableName,
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
  */
195 195
 function isSimulatorTypeValid($simulatorType, $validSimulatorTypes)
196 196
 {
197
-    if (! in_array($simulatorType, $validSimulatorTypes)) {
197
+    if (!in_array($simulatorType, $validSimulatorTypes)) {
198 198
         return false;
199 199
     }
200 200
 
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 function areMerchantKeysSet()
222 222
 {
223 223
     $settings   = get_option('woocommerce_pagantis_settings');
224
-    $publicKey  = ! empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : '';
225
-    $privateKey = ! empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : '';
224
+    $publicKey  = !empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : '';
225
+    $privateKey = !empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : '';
226 226
     if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) {
227 227
         return false;
228 228
     }
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 function areMerchantKeysSet4x()
234 234
 {
235 235
     $settings   = get_option('woocommerce_pagantis_settings');
236
-    $publicKey  = ! empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : '';
237
-    $privateKey = ! empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : '';
236
+    $publicKey  = !empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : '';
237
+    $privateKey = !empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : '';
238 238
     if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) {
239 239
         return false;
240 240
     }
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 function isSimulatorEnabled()
246 246
 {
247 247
     $settings = get_option('woocommerce_pagantis_settings');
248
-    if ((! empty($settings['simulator']) && 'yes' === $settings['simulator']) ? true : false) {
248
+    if ((!empty($settings['simulator']) && 'yes'===$settings['simulator']) ? true : false) {
249 249
         return true;
250 250
     }
251 251
 
@@ -256,13 +256,13 @@  discard block
 block discarded – undo
256 256
 {
257 257
     $settings = get_option('woocommerce_pagantis_settings');
258 258
 
259
-    return (! empty($settings['enabled']) && 'yes' === $settings['enabled']);
259
+    return (!empty($settings['enabled']) && 'yes'===$settings['enabled']);
260 260
 }
261 261
 
262 262
 function isPluginEnabled4x()
263 263
 {
264 264
     $settings = get_option('woocommerce_pagantis_settings');
265
-    return (! empty($settings['enabled_4x']) && 'yes' === $settings['enabled_4x']);
265
+    return (!empty($settings['enabled_4x']) && 'yes'===$settings['enabled_4x']);
266 266
 }
267 267
 
268 268
 
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 {
271 271
     $locale           = strtolower(strstr(get_locale(), '_', true));
272 272
     $allowedCountries = maybe_unserialize(getConfigValue('PAGANTIS_ALLOWED_COUNTRIES'));
273
-    if (! in_array(strtolower($locale), $allowedCountries)) {
273
+    if (!in_array(strtolower($locale), $allowedCountries)) {
274 274
         return false;
275 275
     }
276 276
 
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
     global $product;
288 288
     if (method_exists($product, 'get_price')) {
289 289
         $productPrice = $product->get_price();
290
-        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0'));
290
+        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0'));
291 291
         if ($validAmount) {
292 292
             return true;
293 293
         }
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
     global $product;
307 307
     if (method_exists($product, 'get_price')) {
308 308
         $productPrice = $product->get_price();
309
-        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0'));
309
+        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0'));
310 310
         if ($validAmount) {
311 311
             return true;
312 312
         }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 function getExtraConfig()
326 326
 {
327 327
     global $wpdb;
328
-    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
328
+    $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
329 329
     $response  = array();
330 330
     $dbResult  = $wpdb->get_results("select config, value from $tableName", ARRAY_A);
331 331
     foreach ($dbResult as $value) {
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 function getModuleVersion()
339 339
 {
340 340
 
341
-    $mainFile = plugin_dir_path(PG_WC_MAIN_FILE). '/WC_Pagantis.php';
341
+    $mainFile = plugin_dir_path(PG_WC_MAIN_FILE).'/WC_Pagantis.php';
342 342
     $version = get_file_data($mainFile, array('Version' => 'Version'), false);
343 343
     return $version['Version'];
344 344
 }
@@ -350,9 +350,9 @@  discard block
 block discarded – undo
350 350
  */
351 351
 function getNationalId($order)
352 352
 {
353
-    foreach ((array)$order->get_meta_data() as $mdObject) {
353
+    foreach ((array) $order->get_meta_data() as $mdObject) {
354 354
         $data = $mdObject->get_data();
355
-        if ($data['key'] == 'vat_number') {
355
+        if ($data['key']=='vat_number') {
356 356
             return $data['value'];
357 357
         }
358 358
     }
@@ -367,9 +367,9 @@  discard block
 block discarded – undo
367 367
  */
368 368
 function getTaxId($order)
369 369
 {
370
-    foreach ((array)$order->get_meta_data() as $mdObject) {
370
+    foreach ((array) $order->get_meta_data() as $mdObject) {
371 371
         $data = $mdObject->get_data();
372
-        if ($data['key'] == 'billing_cfpiva') {
372
+        if ($data['key']=='billing_cfpiva') {
373 373
             return $data['value'];
374 374
         }
375 375
     }
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
     $metaProduct = get_post_meta($product_id);
387 387
 
388 388
     return (array_key_exists('custom_product_pagantis_promoted', $metaProduct)
389
-            && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false';
389
+            && $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false';
390 390
 }
391 391
 
392 392
 /**
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
     $promotedAmount = 0;
398 398
     foreach (WC()->cart->get_cart() as $key => $item) {
399 399
         $promotedProduct = isProductPromoted($item['product_id']);
400
-        if ($promotedProduct == 'true') {
400
+        if ($promotedProduct=='true') {
401 401
             $promotedAmount += $item['line_total'] + $item['line_tax'];
402 402
         }
403 403
     }
@@ -411,24 +411,24 @@  discard block
 block discarded – undo
411 411
  * @param $urlToken
412 412
  * @param $methodID
413 413
  */
414
-function addOrderToProcessingQueue($pagantisOrderId, $wcOrderID, $urlToken ,$methodID)
414
+function addOrderToProcessingQueue($pagantisOrderId, $wcOrderID, $urlToken, $methodID)
415 415
 {
416 416
     global $wpdb;
417 417
     checkCartProcessTable();
418
-    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
418
+    $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
419 419
 
420 420
     //Check if id exists
421 421
     $resultsSelect = $wpdb->get_results("SELECT * FROM $tableName WHERE id='$pagantisOrderId'");
422 422
     $countResults  = count($resultsSelect);
423 423
 
424
-    if ($countResults == 0) {
424
+    if ($countResults==0) {
425 425
         $wpdb->insert($tableName, array(
426 426
             'order_id' => $pagantisOrderId,
427 427
             'wc_order_id' => $wcOrderID,
428 428
             'token'       => $urlToken
429 429
         ), array('%s', '%s', '%s'));
430 430
 
431
-        $logEntry = "Cart Added to Processing Queue" .
431
+        $logEntry = "Cart Added to Processing Queue".
432 432
             " cart hash: ".WC()->cart->get_cart_hash().
433 433
             " Merchant order id: ".$wcOrderID.
434 434
             " Pagantis order id: ".$pagantisOrderId.
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
         insertLogEntry(null, $logEntry);
438 438
     } else {
439 439
         $wpdb->update($tableName,
440
-            array('order_id' => $pagantisOrderId,'token' => $urlToken),
440
+            array('order_id' => $pagantisOrderId, 'token' => $urlToken),
441 441
             array('wc_order_id' => $wcOrderID),
442 442
             array('%s,%s'),
443 443
             array('%s'));
@@ -448,8 +448,8 @@  discard block
 block discarded – undo
448 448
 function alterCartProcessTable()
449 449
 {
450 450
     global $wpdb;
451
-    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
452
-    if (! $wpdb->get_var( "SHOW COLUMNS FROM `{$tableName}` LIKE 'token';" ) ) {
451
+    $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
452
+    if (!$wpdb->get_var("SHOW COLUMNS FROM `{$tableName}` LIKE 'token';")) {
453 453
         $wpdb->query("ALTER TABLE $tableName ADD COLUMN `token` VARCHAR(32) NOT NULL AFTER `order_id`");
454 454
         $wpdb->query("ALTER TABLE $tableName DROP PRIMARY KEY, ADD PRIMARY KEY(order_id)");
455 455
         // OLDER VERSIONS OF MODULE USE UNIQUE KEY ON `id` MEANING THIS VALUE WAS NULLABLE
@@ -463,9 +463,9 @@  discard block
 block discarded – undo
463 463
 function checkCartProcessTable()
464 464
 {
465 465
     global $wpdb;
466
-    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
466
+    $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
467 467
 
468
-    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
468
+    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
469 469
 
470 470
         $charset_collate = $wpdb->get_charset_collate();
471 471
         $sql = "CREATE TABLE IF NOT EXISTS $tableName(
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
              PRIMARY KEY (`id`, `order_id`)
477 477
             )$charset_collate";
478 478
 
479
-        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
479
+        require_once(ABSPATH.'wp-admin/includes/upgrade.php');
480 480
         dbDelta($sql);
481 481
     }
482 482
 }
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
             'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
520 520
         ));
521 521
         foreach ($customer_orders as $customer_order) {
522
-            if (trim($sign_up) == '' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) {
522
+            if (trim($sign_up)=='' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) {
523 523
                 $sign_up = substr($customer_order->post_date, 0, 10);
524 524
             }
525 525
         }
Please login to merge, or discard this patch.