Passed
Pull Request — master (#48)
by
unknown
02:20
created
controllers/paymentController.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -299,9 +299,9 @@
 block discarded – undo
299 299
                 if ($promotedProduct == 'true') {
300 300
                     $promotedAmount+=$product->getAmount();
301 301
                     $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() .
302
-                                       ' - Price: ' . $item->get_total() .
303
-                                       ' - Qty: ' . $product->getQuantity() .
304
-                                       ' - Item ID: ' . $item['id_product'];
302
+                                        ' - Price: ' . $item->get_total() .
303
+                                        ' - Qty: ' . $product->getQuantity() .
304
+                                        ' - Item ID: ' . $item['id_product'];
305 305
                     $promotedMessage = substr($promotedMessage, 0, 999);
306 306
                     $metadataOrder->addMetadata('promotedProduct', $promotedMessage);
307 307
                 }
Please login to merge, or discard this patch.
Spacing   +63 added lines, -66 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         require_once dirname(__FILE__).'/../includes/class-wc-pagantis-extraconfig.php';
46 46
         require_once dirname(__FILE__).'/../includes/class-wc-pagantis-logger.php';
47 47
         //Useful vars
48
-        $this->template_path = plugin_dir_path(__FILE__) . '../templates/';
48
+        $this->template_path = plugin_dir_path(__FILE__).'../templates/';
49 49
         $this->allowed_currencies = array("EUR");
50 50
         $this->language = strstr(get_locale(), '_', true);
51 51
         if ($this->language=='') {
@@ -54,31 +54,31 @@  discard block
 block discarded – undo
54 54
         $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg';
55 55
 
56 56
         //Panel form fields
57
-        $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options
57
+        $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options
58 58
         $this->init_settings();
59 59
 
60 60
         $this->extraConfig = WcPagantisExtraConfig::getExtraConfig();
61 61
         $this->title = __($this->extraConfig['PAGANTIS_TITLE'], 'pagantis');
62 62
         $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis.";
63 63
 
64
-        $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl();
65
-        $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl();
64
+        $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl();
65
+        $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl();
66 66
         foreach ($this->settings as $setting_key => $setting_value) {
67 67
             $this->$setting_key = $setting_value;
68 68
         }
69 69
 
70 70
         //Hooks
71
-        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options
72
-        add_action('admin_notices', array($this, 'pagantisCheckFields'));                          //Check config fields
73
-        add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage'));          //Pagantis form
74
-        add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification'));      //Json Notification
75
-        add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3);
71
+        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options
72
+        add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields
73
+        add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form
74
+        add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification
75
+        add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3);
76 76
         add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2);
77 77
     }
78 78
 
79 79
     public function enqueue_scripts()
80 80
     {
81
-        if ($this->enabled !== 'yes' || ! is_checkout() || is_order_received_page() || is_wc_endpoint_url('order-pay')) {
81
+        if ($this->enabled!=='yes' || !is_checkout() || is_order_received_page() || is_wc_endpoint_url('order-pay')) {
82 82
             return;
83 83
         }
84 84
 
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function loadPagantisTranslation($mofile, $domain)
111 111
     {
112
-        if ('pagantis' === $domain) {
113
-            $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo';
112
+        if ('pagantis'===$domain) {
113
+            $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo';
114 114
         }
115 115
         return $mofile;
116 116
     }
@@ -142,24 +142,24 @@  discard block
 block discarded – undo
142 142
     public function pagantisCheckFields()
143 143
     {
144 144
         $error_string = '';
145
-        if ($this->settings['enabled'] !== 'yes') {
145
+        if ($this->settings['enabled']!=='yes') {
146 146
             return;
147 147
         } elseif (!version_compare(phpversion(), '5.3.0', '>=')) {
148
-            $error_string =  __(' is not compatible with your php and/or curl version', 'pagantis');
148
+            $error_string = __(' is not compatible with your php and/or curl version', 'pagantis');
149 149
             $this->settings['enabled'] = 'no';
150 150
         } elseif ($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="") {
151 151
             $error_string = __(' is not configured correctly, the fields Public Key and Secret Key are mandatory for use this plugin', 'pagantis');
152 152
             $this->settings['enabled'] = 'no';
153 153
         } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) {
154
-            $error_string =  __(' only can be used in Euros', 'pagantis');
154
+            $error_string = __(' only can be used in Euros', 'pagantis');
155 155
             $this->settings['enabled'] = 'no';
156
-        } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']<'2'
157
-                  || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']>'12') {
156
+        } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] < '2'
157
+                  || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] > '12') {
158 158
             $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis');
159
-        } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']<'2'
160
-                  || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']>'12') {
159
+        } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] < '2'
160
+                  || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] > '12') {
161 161
             $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis');
162
-        } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']<0) {
162
+        } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] < 0) {
163 163
             $error_string = __(' can not have a minimum amount less than 0', 'pagantis');
164 164
         }
165 165
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 
194 194
             $shippingAddress = $order->get_address('shipping');
195 195
             $billingAddress = $order->get_address('billing');
196
-            if ($shippingAddress['address_1'] == '') {
196
+            if ($shippingAddress['address_1']=='') {
197 197
                 $shippingAddress = $billingAddress;
198 198
             }
199 199
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
                 ->setNationalId($national_id)
221 221
                 ->setTaxId($tax_id)
222 222
             ;
223
-            $orderBillingAddress =  new Address();
223
+            $orderBillingAddress = new Address();
224 224
             $orderBillingAddress
225 225
                 ->setZipCode($billingAddress['postcode'])
226 226
                 ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name'])
@@ -293,12 +293,12 @@  discard block
 block discarded – undo
293 293
                 $details->addProduct($product);
294 294
 
295 295
                 $promotedProduct = $this->isPromoted($item->get_product_id());
296
-                if ($promotedProduct == 'true') {
297
-                    $promotedAmount+=$product->getAmount();
298
-                    $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() .
299
-                                       ' - Price: ' . $item->get_total() .
300
-                                       ' - Qty: ' . $product->getQuantity() .
301
-                                       ' - Item ID: ' . $item['id_product'];
296
+                if ($promotedProduct=='true') {
297
+                    $promotedAmount += $product->getAmount();
298
+                    $promotedMessage = 'Promoted Item: '.$wcProduct->get_name().
299
+                                       ' - Price: '.$item->get_total().
300
+                                       ' - Qty: '.$product->getQuantity().
301
+                                       ' - Item ID: '.$item['id_product'];
302 302
                     $promotedMessage = substr($promotedMessage, 0, 999);
303 303
                     $metadataOrder->addMetadata('promotedProduct', $promotedMessage);
304 304
                 }
@@ -342,9 +342,7 @@  discard block
 block discarded – undo
342 342
 
343 343
             $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']);
344 344
             $purchaseCountry =
345
-                in_array(strtolower($this->language), $allowedCountries) ? $this->language :
346
-                in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] :
347
-                in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null;
345
+                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;
348 346
 
349 347
             $orderConfiguration = new Configuration();
350 348
             $orderConfiguration
@@ -386,7 +384,7 @@  discard block
 block discarded – undo
386 384
                 wc_get_template('iframe.php', $template_fields, '', $this->template_path);
387 385
             }
388 386
         } catch (\Exception $exception) {
389
-            wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error');
387
+            wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error');
390 388
             $this->insertLog($exception);
391 389
             $checkout_url = get_permalink(wc_get_page_id('checkout'));
392 390
             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() == self::METHOD_ID) {
443
-            if ($order->get_status() == 'failed') {
440
+        if ($order->get_payment_method()==self::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
         }
@@ -467,8 +465,8 @@  discard block
 block discarded – undo
467 465
         $allowedCountry = (in_array(strtolower($locale), $allowedCountries));
468 466
         $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'];
469 467
         $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT'];
470
-        $totalPrice = (int)$this->get_order_total();
471
-        $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0'));
468
+        $totalPrice = (int) $this->get_order_total();
469
+        $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0'));
472 470
         if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' &&
473 471
             $validAmount && $allowedCountry) {
474 472
             return true;
@@ -498,7 +496,7 @@  discard block
 block discarded – undo
498 496
 
499 497
             $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function
500 498
             if (strpos($redirectUrl, 'order-pay=')===false) {
501
-                $redirectUrl.="&order-pay=".$order_id;
499
+                $redirectUrl .= "&order-pay=".$order_id;
502 500
             }
503 501
 
504 502
             return array(
@@ -506,7 +504,7 @@  discard block
 block discarded – undo
506 504
                 'redirect' => $redirectUrl
507 505
             );
508 506
         } catch (Exception $e) {
509
-            wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error');
507
+            wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error');
510 508
             return array();
511 509
         }
512 510
     }
@@ -577,7 +575,7 @@  discard block
 block discarded – undo
577 575
     private function generateUrl($url)
578 576
     {
579 577
         $parsed_url = parse_url($url);
580
-        if ($parsed_url !== false) {
578
+        if ($parsed_url!==false) {
581 579
             $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query'];
582 580
             parse_str($parsed_url['query'], $arrayParams);
583 581
             foreach ($arrayParams as $keyParam => $valueParam) {
@@ -625,11 +623,10 @@  discard block
 block discarded – undo
625 623
     private function getKeysUrl($order, $url)
626 624
     {
627 625
         $defaultFields = (get_class($order)=='WC_Order') ?
628
-            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) :
629
-            array();
626
+            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array();
630 627
 
631 628
         $parsedUrl = parse_url($url);
632
-        if ($parsedUrl !== false) {
629
+        if ($parsedUrl!==false) {
633 630
             //Replace parameters from url
634 631
             $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields);
635 632
 
@@ -674,7 +671,7 @@  discard block
 block discarded – undo
674 671
         foreach ($arrayParams as $keyParam => $valueParam) {
675 672
             preg_match('#\{{.*?}\}#', $valueParam, $match);
676 673
             if (count($match)) {
677
-                $key = str_replace(array('{{','}}'), array('',''), $match[0]);
674
+                $key = str_replace(array('{{', '}}'), array('', ''), $match[0]);
678 675
                 $arrayParams[$keyParam] = $defaultFields[$key];
679 676
             }
680 677
         }
@@ -689,13 +686,13 @@  discard block
 block discarded – undo
689 686
      */
690 687
     private function unparseUrl($parsed_url)
691 688
     {
692
-        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
689
+        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : '';
693 690
         $host     = isset($parsed_url['host']) ? $parsed_url['host'] : '';
694
-        $port     = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
695
-        $query    = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
696
-        $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
691
+        $port     = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : '';
692
+        $query    = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : '';
693
+        $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : '';
697 694
         $path     = $parsed_url['path'];
698
-        return $scheme . $host . $port . $path . $query . $fragment;
695
+        return $scheme.$host.$port.$path.$query.$fragment;
699 696
     }
700 697
 
701 698
     /**
@@ -717,20 +714,20 @@  discard block
 block discarded – undo
717 714
             $is_guest = "false";
718 715
             $sign_up = substr($current_user->user_registered, 0, 10);
719 716
             $customer_orders = get_posts(array(
720
-                'numberposts' => - 1,
717
+                'numberposts' => -1,
721 718
                 'meta_key'    => '_customer_user',
722 719
                 'meta_value'  => $current_user->ID,
723
-                'post_type'   => array( 'shop_order' ),
724
-                'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded' ),
720
+                'post_type'   => array('shop_order'),
721
+                'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
725 722
             ));
726 723
         } else {
727 724
             $is_guest = "true";
728 725
             $customer_orders = get_posts(array(
729
-                'numberposts' => - 1,
726
+                'numberposts' => -1,
730 727
                 'meta_key'    => '_billing_email',
731 728
                 'meta_value'  => $billingEmail,
732
-                'post_type'   => array( 'shop_order' ),
733
-                'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded'),
729
+                'post_type'   => array('shop_order'),
730
+                'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
734 731
             ));
735 732
             foreach ($customer_orders as $customer_order) {
736 733
                 if (trim($sign_up)=='' ||
@@ -759,7 +756,7 @@  discard block
 block discarded – undo
759 756
         //Check if id exists
760 757
         $resultsSelect = $wpdb->get_results("select * from $tableName where id='$orderId'");
761 758
         $countResults = count($resultsSelect);
762
-        if ($countResults == 0) {
759
+        if ($countResults==0) {
763 760
             $wpdb->insert(
764 761
                 $tableName,
765 762
                 array('id' => $orderId, 'order_id' => $pagantisOrderId),
@@ -784,7 +781,7 @@  discard block
 block discarded – undo
784 781
         global $wpdb;
785 782
         $tableName = $wpdb->prefix.PAGANTIS_WC_ORDERS_TABLE;
786 783
 
787
-        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
784
+        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
788 785
             $charset_collate = $wpdb->get_charset_collate();
789 786
             $sql             = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50),  
790 787
                   UNIQUE KEY id (id)) $charset_collate";
@@ -817,9 +814,9 @@  discard block
 block discarded – undo
817 814
      */
818 815
     private function getNationalId($order)
819 816
     {
820
-        foreach ((array)$order->get_meta_data() as $mdObject) {
817
+        foreach ((array) $order->get_meta_data() as $mdObject) {
821 818
             $data = $mdObject->get_data();
822
-            if ($data['key'] == 'vat_number') {
819
+            if ($data['key']=='vat_number') {
823 820
                 return $data['value'];
824 821
             }
825 822
         }
@@ -834,9 +831,9 @@  discard block
 block discarded – undo
834 831
      */
835 832
     private function getTaxId($order)
836 833
     {
837
-        foreach ((array)$order->get_meta_data() as $mdObject) {
834
+        foreach ((array) $order->get_meta_data() as $mdObject) {
838 835
             $data = $mdObject->get_data();
839
-            if ($data['key'] == 'billing_cfpiva') {
836
+            if ($data['key']=='billing_cfpiva') {
840 837
                 return $data['value'];
841 838
             }
842 839
         }
@@ -866,7 +863,7 @@  discard block
 block discarded – undo
866 863
     {
867 864
         global $wpdb;
868 865
         $tableName = $wpdb->prefix.PAGANTIS_LOGS_TABLE;
869
-        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
866
+        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
870 867
             $charset_collate = $wpdb->get_charset_collate();
871 868
             $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, 
872 869
                     createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate";
@@ -885,7 +882,7 @@  discard block
 block discarded – undo
885 882
     {
886 883
         $metaProduct = get_post_meta($product_id);
887 884
         return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) &&
888
-                $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false';
885
+                $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false';
889 886
     }
890 887
 
891 888
     /**
@@ -898,8 +895,8 @@  discard block
 block discarded – undo
898 895
         $promotedAmount = 0;
899 896
         foreach ($items as $key => $item) {
900 897
             $promotedProduct = $this->isPromoted($item['product_id']);
901
-            if ($promotedProduct == 'true') {
902
-                $promotedAmount+=$item['line_total'] + $item['line_tax'];
898
+            if ($promotedProduct=='true') {
899
+                $promotedAmount += $item['line_total'] + $item['line_tax'];
903 900
             }
904 901
         }
905 902
 
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
@@ -198,10 +198,10 @@
 block discarded – undo
198 198
 
199 199
         if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM
200 200
             $logMessage = "WARNING checkMerchantOrderStatus." .
201
-                          " Merchant order id:".$this->woocommerceOrder->get_id().
202
-                          " Merchant order status:".$this->woocommerceOrder->get_status().
203
-                          " Pagantis order id:".$this->pagantisOrder->getStatus().
204
-                          " Pagantis order status:".$this->pagantisOrder->getId();
201
+                            " Merchant order id:".$this->woocommerceOrder->get_id().
202
+                            " Merchant order status:".$this->woocommerceOrder->get_status().
203
+                            " Pagantis order id:".$this->pagantisOrder->getStatus().
204
+                            " Pagantis order status:".$this->pagantisOrder->getId();
205 205
 
206 206
             $this->insertLog(null, $logMessage);
207 207
             $this->woocommerceOrder->add_order_note($logMessage);
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         try {
63 63
             require_once(__ROOT__.'/vendor/autoload.php');
64 64
             try {
65
-                if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_GET['origin'] == 'notification') {
65
+                if ($_SERVER['REQUEST_METHOD']=='GET' && $_GET['origin']=='notification') {
66 66
                     return $this->buildResponse();
67 67
                 }
68 68
                 $this->checkConcurrency();
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     private function checkConcurrency()
111 111
     {
112 112
         $this->woocommerceOrderId = $_GET['order-received'];
113
-        if ($this->woocommerceOrderId == '') {
113
+        if ($this->woocommerceOrderId=='') {
114 114
             throw new QuoteNotFoundException();
115 115
         }
116 116
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         $queryResult = $wpdb->get_row("select order_id from $tableName where id='".$this->woocommerceOrderId."'");
143 143
         $this->pagantisOrderId = $queryResult->order_id;
144 144
 
145
-        if ($this->pagantisOrderId == '') {
145
+        if ($this->pagantisOrderId=='') {
146 146
             throw new NoIdentificationException();
147 147
         }
148 148
     }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
                 $status = '-';
177 177
             }
178 178
 
179
-            if ($status === Order::STATUS_CONFIRMED) {
179
+            if ($status===Order::STATUS_CONFIRMED) {
180 180
                 return true;
181 181
             }
182 182
             throw new WrongStatusException($status);
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
         );
198 198
 
199 199
         if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM
200
-            $logMessage = "WARNING checkMerchantOrderStatus." .
200
+            $logMessage = "WARNING checkMerchantOrderStatus.".
201 201
                           " Merchant order id:".$this->woocommerceOrder->get_id().
202 202
                           " Merchant order status:".$this->woocommerceOrder->get_status().
203 203
                           " Pagantis order id:".$this->pagantisOrder->getStatus().
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
     {
220 220
         $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount();
221 221
         $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total()));
222
-        if ($pagantisAmount != $wcAmount) {
222
+        if ($pagantisAmount!=$wcAmount) {
223 223
             throw new AmountMismatchException($pagantisAmount, $wcAmount);
224 224
         }
225 225
     }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
             $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId);
244 244
         } catch (\Exception $e) {
245 245
             $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId);
246
-            if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) {
246
+            if ($this->pagantisOrder->getStatus()!==Order::STATUS_CONFIRMED) {
247 247
                 throw new UnknownException($e->getMessage());
248 248
             } else {
249 249
                 $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process';
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
         global $wpdb;
268 268
         $tableName = $wpdb->prefix.PAGANTIS_WC_ORDERS_TABLE;
269 269
 
270
-        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
270
+        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
271 271
             $charset_collate = $wpdb->get_charset_collate();
272 272
             $sql             = "CREATE TABLE $tableName (id int, order_id varchar(50), wc_order_id varchar(50), 
273 273
                   UNIQUE KEY id (id)) $charset_collate";
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
         global $wpdb;
286 286
         $tableName = $wpdb->prefix.PAGANTIS_LOGS_TABLE;
287 287
 
288
-        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
288
+        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
289 289
             $charset_collate = $wpdb->get_charset_collate();
290 290
             $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, 
291 291
                     createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate";
@@ -342,12 +342,12 @@  discard block
 block discarded – undo
342 342
             $metadataOrder = $this->pagantisOrder->getMetadata();
343 343
             $metadataInfo = null;
344 344
             foreach ($metadataOrder as $metadataKey => $metadataValue) {
345
-                if ($metadataKey == 'promotedProduct') {
346
-                    $metadataInfo.= "/Producto promocionado = $metadataValue";
345
+                if ($metadataKey=='promotedProduct') {
346
+                    $metadataInfo .= "/Producto promocionado = $metadataValue";
347 347
                 }
348 348
             }
349 349
 
350
-            if ($metadataInfo != null) {
350
+            if ($metadataInfo!=null) {
351 351
                 $this->woocommerceOrder->add_order_note($metadataInfo);
352 352
             }
353 353
 
@@ -416,13 +416,13 @@  discard block
 block discarded – undo
416 416
     {
417 417
         global $wpdb;
418 418
         $tableName = $wpdb->prefix.PAGANTIS_CONCURRENCY_TABLE;
419
-        if ($orderId == null) {
419
+        if ($orderId==null) {
420 420
             $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT." SECOND)";
421 421
         } else {
422 422
             $query = "DELETE FROM $tableName WHERE order_id = $orderId";
423 423
         }
424 424
         $resultDelete = $wpdb->query($query);
425
-        if ($resultDelete === false) {
425
+        if ($resultDelete===false) {
426 426
             throw new ConcurrencyException();
427 427
         }
428 428
     }
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
         global $wpdb;
438 438
         $tableName = $wpdb->prefix.PAGANTIS_CONCURRENCY_TABLE;
439 439
         $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId));
440
-        if ($insertResult === false) {
441
-            if ($this->getOrigin() == 'Notify') {
440
+        if ($insertResult===false) {
441
+            if ($this->getOrigin()=='Notify') {
442 442
                 throw new ConcurrencyException();
443 443
             } else {
444 444
                 $query = sprintf(
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
                 );
450 450
                 $resultSeconds = $wpdb->get_row($query);
451 451
                 $restSeconds = isset($resultSeconds) ? ($resultSeconds->rest) : 0;
452
-                $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;
453
-                sleep($secondsToExpire+1);
452
+                $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;
453
+                sleep($secondsToExpire + 1);
454 454
 
455 455
                 $logMessage = sprintf(
456 456
                     "User waiting %s seconds, default seconds %s, bd time to expire %s seconds",
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
     {
475 475
         $this->unblockConcurrency($this->woocommerceOrderId);
476 476
 
477
-        if ($exception == null) {
477
+        if ($exception==null) {
478 478
             $jsonResponse = new JsonSuccessResponse();
479 479
         } else {
480 480
             $jsonResponse = new JsonExceptionResponse();
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
         $jsonResponse->setMerchantOrderId($this->woocommerceOrderId);
485 485
         $jsonResponse->setPagantisOrderId($this->pagantisOrderId);
486 486
 
487
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
487
+        if ($_SERVER['REQUEST_METHOD']=='POST') {
488 488
             $jsonResponse->printResponse();
489 489
         } else {
490 490
             return $jsonResponse;
Please login to merge, or discard this patch.
includes/class-wc-pagantis-ajax.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (! defined('ABSPATH')) {
3
+if (!defined('ABSPATH')) {
4 4
     exit;
5 5
 }
6 6
 
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
     {
25 25
         $ajax_events = array('pagantis_checkout');
26 26
         foreach ($ajax_events as $ajax_event => $nopriv) {
27
-            add_action('wp_ajax_woocommerce_' . $ajax_event, array(__CLASS__, $ajax_event));
27
+            add_action('wp_ajax_woocommerce_'.$ajax_event, array(__CLASS__, $ajax_event));
28 28
             if ($nopriv) {
29 29
                 add_action(
30
-                    'wp_ajax_nopriv_woocommerce_' . $ajax_event,
30
+                    'wp_ajax_nopriv_woocommerce_'.$ajax_event,
31 31
                     array(__CLASS__, $ajax_event)
32 32
                 );
33 33
                 // WC AJAX can be used for frontend ajax requests.
34
-                add_action('wc_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
34
+                add_action('wc_ajax_'.$ajax_event, array(__CLASS__, $ajax_event));
35 35
             }
36 36
         }
37 37
     }
Please login to merge, or discard this patch.
includes/class-wc-pagantis-logger.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
      */
21 21
     public static function writeLog($message, $start_time = null, $end_time = null)
22 22
     {
23
-        if (! class_exists('WC_Logger')) {
23
+        if (!class_exists('WC_Logger')) {
24 24
             return;
25 25
         }
26 26
 
@@ -29,31 +29,31 @@  discard block
 block discarded – undo
29 29
                 self::$logger = wc_get_logger();
30 30
             }
31 31
 
32
-            $isDebugLogEnabled    = 'yes' === WC_Admin_Settings::get_option('debug', 'no');
32
+            $isDebugLogEnabled = 'yes'===WC_Admin_Settings::get_option('debug', 'no');
33 33
             $settings = get_option('woocommerce_pagantis_settings');
34 34
 
35 35
             if (empty($settings) || isset($settings['debug']) && $isDebugLogEnabled) {
36 36
                 return;
37 37
             }
38 38
 
39
-            if (! is_null($start_time)) {
40
-                $formatted_start_time = date_i18n(get_option('date_format') . ' g:ia', $start_time);
39
+            if (!is_null($start_time)) {
40
+                $formatted_start_time = date_i18n(get_option('date_format').' g:ia', $start_time);
41 41
                 $end_time             = is_null($end_time) ? current_time('timestamp') : $end_time;
42
-                $formatted_end_time   = date_i18n(get_option('date_format') . ' g:ia', $end_time);
42
+                $formatted_end_time   = date_i18n(get_option('date_format').' g:ia', $end_time);
43 43
                 $elapsed_time         = round(abs($end_time - $start_time) / 60, 2);
44 44
 
45
-                $log_entry  = "\n" . '====Pagantis Version: ' . PAGANTIS_VERSION . '====' . "\n";
46
-                $log_entry .= '====Start Log ' . $formatted_start_time . '====' . "\n" . $message . "\n";
47
-                $log_entry .= '====End Log ' . $formatted_end_time . ' (' . $elapsed_time . ')====' . "\n\n";
45
+                $log_entry  = "\n".'====Pagantis Version: '.PAGANTIS_VERSION.'===='."\n";
46
+                $log_entry .= '====Start Log '.$formatted_start_time.'===='."\n".$message."\n";
47
+                $log_entry .= '====End Log '.$formatted_end_time.' ('.$elapsed_time.')===='."\n\n";
48 48
             } else {
49
-                $log_entry  = "\n" . '====Pagantis Version: ' . PAGANTIS_VERSION . '====' . "\n";
50
-                $log_entry .= '====Start Log====' . "\n" . $message . "\n" . '====End Log====' . "\n\n";
49
+                $log_entry  = "\n".'====Pagantis Version: '.PAGANTIS_VERSION.'===='."\n";
50
+                $log_entry .= '====Start Log===='."\n".$message."\n".'====End Log===='."\n\n";
51 51
             }
52 52
             if (defined('WP_DEBUG') && WP_DEBUG) {
53 53
                 error_log($log_entry);
54 54
             }
55 55
             print_r($log_entry);
56
-            self::$logger->debug($log_entry, array( 'source' => self::WC_LOG_FILENAME ));
56
+            self::$logger->debug($log_entry, array('source' => self::WC_LOG_FILENAME));
57 57
         }
58 58
     }
59 59
 
Please login to merge, or discard this patch.
WC_Pagantis.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -35,28 +35,28 @@  discard block
 block discarded – undo
35 35
 {
36 36
 
37 37
     public $defaultConfigs = array(
38
-       'PAGANTIS_TITLE'=>'Pago en cuotas',
39
-       'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'sdk.simulator.types.PRODUCT_PAGE',
40
-       'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'=>'sdk.simulator.types.CHECKOUT_PAGE',
41
-       'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'sdk.simulator.skins.BLUE',
42
-       'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons',
43
-       'PAGANTIS_SIMULATOR_START_INSTALLMENTS'=>3,
44
-       'PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'=>12,
45
-       'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'=>'default',
46
-       'PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'=>'sdk.simulator.positions.INNER',
47
-       'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'=>'a:3:{i:0;s:48:"div.summary *:not(del)>.woocommerce-Price-amount";i:1;s:54:"div.entry-summary *:not(del)>.woocommerce-Price-amount";i:2;s:36:"*:not(del)>.woocommerce-Price-amount";}',
48
-       'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'=>'a:2:{i:0;s:22:"div.quantity input.qty";i:1;s:18:"div.quantity>input";}',
49
-       'PAGANTIS_FORM_DISPLAY_TYPE'=>0,
50
-       'PAGANTIS_DISPLAY_MIN_AMOUNT'=>1,
51
-       'PAGANTIS_DISPLAY_MAX_AMOUNT'=>0,
52
-       'PAGANTIS_URL_OK'=>'',
53
-       'PAGANTIS_URL_KO'=>'',
54
-       'PAGANTIS_ALLOWED_COUNTRIES' => 'a:3:{i:0;s:2:"es";i:1;s:2:"it";i:2;s:2:"fr";}',
55
-       'PAGANTIS_PROMOTION_EXTRA' => '<p>Finance this product <span class="pg-no-interest">without interest!</span></p>',
56
-       'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR' => '.',
57
-       'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR' => ',',
58
-       'PAGANTIS_SIMULATOR_DISPLAY_SITUATION' => 'default',
59
-       'PAGANTIS_SIMULATOR_SELECTOR_VARIATION' => 'default'
38
+        'PAGANTIS_TITLE'=>'Pago en cuotas',
39
+        'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'sdk.simulator.types.PRODUCT_PAGE',
40
+        'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'=>'sdk.simulator.types.CHECKOUT_PAGE',
41
+        'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'sdk.simulator.skins.BLUE',
42
+        'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons',
43
+        'PAGANTIS_SIMULATOR_START_INSTALLMENTS'=>3,
44
+        'PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'=>12,
45
+        'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'=>'default',
46
+        'PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'=>'sdk.simulator.positions.INNER',
47
+        'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'=>'a:3:{i:0;s:48:"div.summary *:not(del)>.woocommerce-Price-amount";i:1;s:54:"div.entry-summary *:not(del)>.woocommerce-Price-amount";i:2;s:36:"*:not(del)>.woocommerce-Price-amount";}',
48
+        'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'=>'a:2:{i:0;s:22:"div.quantity input.qty";i:1;s:18:"div.quantity>input";}',
49
+        'PAGANTIS_FORM_DISPLAY_TYPE'=>0,
50
+        'PAGANTIS_DISPLAY_MIN_AMOUNT'=>1,
51
+        'PAGANTIS_DISPLAY_MAX_AMOUNT'=>0,
52
+        'PAGANTIS_URL_OK'=>'',
53
+        'PAGANTIS_URL_KO'=>'',
54
+        'PAGANTIS_ALLOWED_COUNTRIES' => 'a:3:{i:0;s:2:"es";i:1;s:2:"it";i:2;s:2:"fr";}',
55
+        'PAGANTIS_PROMOTION_EXTRA' => '<p>Finance this product <span class="pg-no-interest">without interest!</span></p>',
56
+        'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR' => '.',
57
+        'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR' => ',',
58
+        'PAGANTIS_SIMULATOR_DISPLAY_SITUATION' => 'default',
59
+        'PAGANTIS_SIMULATOR_SELECTOR_VARIATION' => 'default'
60 60
     );
61 61
 
62 62
     /** @var array $extraConfig */
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
         if ($file == plugin_basename(__FILE__)) {
424 424
             $links[] = '<a href="'.PAGANTIS_GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>';
425 425
             $links[] = '<a href="'.PAGANTIS_DOC_URL.'" target="_blank">'.
426
-                       __('API documentation', 'pagantis').'</a>';
426
+                        __('API documentation', 'pagantis').'</a>';
427 427
             $links[] = '<a href="'.PAGANTIS_SUPPORT_EMAIL.'">'.__('Support', 'pagantis').'</a>';
428 428
 
429 429
             return $links;
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
         register_activation_hook(__FILE__, array($this, 'pagantisActivation'));
88 88
         add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl'));
89 89
         add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave'));
90
-        add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate'));
91
-        add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave'));
90
+        add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate'));
91
+        add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave'));
92 92
     }
93 93
 
94 94
     /**
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
     {
115 115
         $post_id = $product->get_id();
116 116
         $pagantis_promoted_value = $_REQUEST['pagantis_promoted'];
117
-        if ($pagantis_promoted_value == 'on') {
117
+        if ($pagantis_promoted_value=='on') {
118 118
             $pagantis_promoted_value = 'yes';
119 119
         } else {
120 120
             $pagantis_promoted_value = 'no';
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     public function pagantisPromotedVarSave($post_id)
149 149
     {
150 150
         $pagantis_promoted_value = $_POST['pagantis_promoted'];
151
-        if ($pagantis_promoted_value == null) {
151
+        if ($pagantis_promoted_value==null) {
152 152
             $pagantis_promoted_value = 'no';
153 153
         }
154 154
         update_post_meta($post_id, 'custom_product_pagantis_promoted', esc_attr($pagantis_promoted_value));
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public function loadPagantisTranslation($mofile, $domain)
163 163
     {
164
-        if ('pagantis' === $domain) {
165
-            $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo';
164
+        if ('pagantis'===$domain) {
165
+            $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo';
166 166
         }
167 167
         return $mofile;
168 168
     }
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
         global $wpdb;
176 176
 
177 177
         $tableName = $wpdb->prefix.PAGANTIS_CONCURRENCY_TABLE;
178
-        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
178
+        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
179 179
             $charset_collate = $wpdb->get_charset_collate();
180 180
             $sql = "CREATE TABLE $tableName ( order_id int NOT NULL,  
181 181
                     createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate";
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE;
187 187
 
188 188
         //Check if table exists
189
-        $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName;
189
+        $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName;
190 190
         if ($tableExists) {
191 191
             $charset_collate = $wpdb->get_charset_collate();
192 192
             $sql = "CREATE TABLE IF NOT EXISTS $tableName (
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
             //Updated value field to adapt to new length < v8.0.1
202 202
             $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'";
203 203
             $results = $wpdb->get_results($query, ARRAY_A);
204
-            if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') {
204
+            if ($results['0']['COLUMN_TYPE']=='varchar(100)') {
205 205
                 $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)";
206 206
                 $wpdb->query($sql);
207 207
             }
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
                                or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'";
212 212
             $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A);
213 213
             foreach ($dbCurrentConfig as $item) {
214
-                if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') {
214
+                if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') {
215 215
                     $css_price_selector = $this->preparePriceSelector($item['value']);
216
-                    if ($item['value'] != $css_price_selector) {
216
+                    if ($item['value']!=$css_price_selector) {
217 217
                         $wpdb->update(
218 218
                             $tableName,
219 219
                             array('value' => stripslashes($css_price_selector)),
@@ -222,9 +222,9 @@  discard block
 block discarded – undo
222 222
                             array('%s')
223 223
                         );
224 224
                     }
225
-                } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') {
225
+                } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') {
226 226
                     $css_quantity_selector = $this->prepareQuantitySelector($item['value']);
227
-                    if ($item['value'] != $css_quantity_selector) {
227
+                    if ($item['value']!=$css_quantity_selector) {
228 228
                         $wpdb->update(
229 229
                             $tableName,
230 230
                             array('value' => stripslashes($css_quantity_selector)),
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
         $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE;
242 242
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'";
243 243
         $results = $wpdb->get_results($query, ARRAY_A);
244
-        if (count($results) == 0) {
244
+        if (count($results)==0) {
245 245
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value'  => '.'), array('%s', '%s'));
246 246
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value'  => ','), array('%s', '%s'));
247 247
         }
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE;
251 251
         $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'";
252 252
         $results = $wpdb->get_results($query, ARRAY_A);
253
-        if (count($results) == 0) {
253
+        if (count($results)==0) {
254 254
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value'  => '0'), array('%s', '%s'));
255 255
         }
256 256
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE;
259 259
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'";
260 260
         $results = $wpdb->get_results($query, ARRAY_A);
261
-        if (count($results) == 0) {
261
+        if (count($results)==0) {
262 262
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value'  => 'default'), array('%s', '%s'));
263 263
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value'  => 'default'), array('%s', '%s'));
264 264
         }
@@ -267,17 +267,17 @@  discard block
 block discarded – undo
267 267
         $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE;
268 268
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'";
269 269
         $results = $wpdb->get_results($query, ARRAY_A);
270
-        if (count($results) == 0) {
270
+        if (count($results)==0) {
271 271
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', 'value'  => 'sdk.simulator.types.CHECKOUT_PAGE'), array('%s', '%s'));
272 272
             $wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), array('%s'), array('%s'));
273 273
         }
274 274
 
275 275
         //Adapting to variable selector < v8.3.6
276
-        $variableSelector="div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price";
276
+        $variableSelector = "div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price";
277 277
         $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE;
278 278
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'";
279 279
         $results = $wpdb->get_results($query, ARRAY_A);
280
-        if (count($results) == 0) {
280
+        if (count($results)==0) {
281 281
             $wpdb->update($tableName, array('value' => $variableSelector), array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION'), array('%s'), array('%s'));
282 282
         }
283 283
 
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
         $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'];
326 326
         $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT'];
327 327
         $totalPrice = $product->get_price();
328
-        $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0'));
329
-        if ($cfg['enabled'] !== 'yes' || $cfg['pagantis_public_key'] == '' || $cfg['pagantis_private_key'] == '' ||
330
-            $cfg['simulator'] !== 'yes'  || !$allowedCountry || !$validAmount) {
328
+        $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0'));
329
+        if ($cfg['enabled']!=='yes' || $cfg['pagantis_public_key']=='' || $cfg['pagantis_private_key']=='' ||
330
+            $cfg['simulator']!=='yes' || !$allowedCountry || !$validAmount) {
331 331
             return;
332 332
         }
333 333
         $post_id = $product->get_id();
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
      */
366 366
     public function addPagantisGateway($methods)
367 367
     {
368
-        if (! class_exists('WC_Payment_Gateway')) {
368
+        if (!class_exists('WC_Payment_Gateway')) {
369 369
             return $methods;
370 370
         }
371 371
 
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
      */
421 421
     public function pagantisRowMeta($links, $file)
422 422
     {
423
-        if ($file == plugin_basename(__FILE__)) {
423
+        if ($file==plugin_basename(__FILE__)) {
424 424
             $links[] = '<a href="'.PAGANTIS_GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>';
425 425
             $links[] = '<a href="'.PAGANTIS_DOC_URL.'" target="_blank">'.
426 426
                        __('API documentation', 'pagantis').'</a>';
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
         $tableName = $wpdb->prefix.PAGANTIS_LOGS_TABLE;
449 449
         $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc";
450 450
         $results = $wpdb->get_results($query);
451
-        if (isset($results) && $privateKey == $secretKey) {
451
+        if (isset($results) && $privateKey==$secretKey) {
452 452
             foreach ($results as $key => $result) {
453 453
                 $response[$key]['timestamp'] = $result->createdAt;
454 454
                 $response[$key]['log']       = json_decode($result->log);
@@ -475,12 +475,12 @@  discard block
 block discarded – undo
475 475
 
476 476
         $filters   = ($data->get_params());
477 477
         $secretKey = $filters['secret'];
478
-        $cfg  = get_option('woocommerce_pagantis_settings');
478
+        $cfg = get_option('woocommerce_pagantis_settings');
479 479
         $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null;
480
-        if ($privateKey != $secretKey) {
480
+        if ($privateKey!=$secretKey) {
481 481
             $response['status'] = 401;
482 482
             $response['result'] = 'Unauthorized';
483
-        } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
483
+        } elseif ($_SERVER['REQUEST_METHOD']=='POST') {
484 484
             if (count($_POST)) {
485 485
                 foreach ($_POST as $config => $value) {
486 486
                     if (isset($this->defaultConfigs[$config]) && $response['status']==null) {
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
                   and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc";
541 541
         $results = $wpdb->get_results($query);
542 542
 
543
-        if (isset($results) && $privateKey == $secretKey) {
543
+        if (isset($results) && $privateKey==$secretKey) {
544 544
             foreach ($results as $result) {
545 545
                 $key = $result->ID;
546 546
                 $response['message'][$key]['timestamp'] = $result->post_date;
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
      */
625 625
     private function prepareQuantitySelector($css_quantity_selector)
626 626
     {
627
-        if ($css_quantity_selector == 'default' || $css_quantity_selector == '') {
627
+        if ($css_quantity_selector=='default' || $css_quantity_selector=='') {
628 628
             $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'];
629 629
         } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it
630 630
             $css_quantity_selector = serialize(array($css_quantity_selector));
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
      */
641 641
     private function preparePriceSelector($css_price_selector)
642 642
     {
643
-        if ($css_price_selector == 'default' || $css_price_selector == '') {
643
+        if ($css_price_selector=='default' || $css_price_selector=='') {
644 644
             $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'];
645 645
         } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it
646 646
             $css_price_selector = serialize(array($css_price_selector));
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
     {
659 659
         $metaProduct = get_post_meta($product_id);
660 660
         return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) &&
661
-                $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false';
661
+                $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false';
662 662
     }
663 663
 }
664 664
 
Please login to merge, or discard this patch.