@@ -1,7 +1,7 @@ discard block  | 
                                                    ||
| 1 | 1 | <script>  | 
                                                        
| 2 | 2 | function findPriceSelector()  | 
                                                        
| 3 | 3 |      { | 
                                                        
| 4 | - var priceSelectors = <?php echo json_encode($priceSelector);?>;  | 
                                                        |
| 4 | + var priceSelectors = <?php echo json_encode($priceSelector); ?>;  | 
                                                        |
| 5 | 5 |          return priceSelectors.find(function(candidateSelector) { | 
                                                        
| 6 | 6 | var priceDOM = document.querySelector(candidateSelector);  | 
                                                        
| 7 | 7 | return (priceDOM != null );  | 
                                                        
@@ -11,7 +11,7 @@ discard block  | 
                                                    ||
| 11 | 11 | |
| 12 | 12 | function findQuantitySelector()  | 
                                                        
| 13 | 13 |      { | 
                                                        
| 14 | - var quantitySelectors = <?php echo json_encode($quantitySelector);?>;  | 
                                                        |
| 14 | + var quantitySelectors = <?php echo json_encode($quantitySelector); ?>;  | 
                                                        |
| 15 | 15 |          return quantitySelectors.find(function(candidateSelector) { | 
                                                        
| 16 | 16 | var priceDOM = document.querySelector(candidateSelector);  | 
                                                        
| 17 | 17 | return (priceDOM != null );  | 
                                                        
@@ -51,7 +51,7 @@ discard block  | 
                                                    ||
| 51 | 51 | return finishInterval();  | 
                                                        
| 52 | 52 | }  | 
                                                        
| 53 | 53 | |
| 54 | - var price = '<?php echo $total;?>';  | 
                                                        |
| 54 | + var price = '<?php echo $total; ?>';  | 
                                                        |
| 55 | 55 | |
| 56 | 56 | var locale = '<?php echo $locale; ?>';  | 
                                                        
| 57 | 57 |          if (locale == 'es' || locale == '') { | 
                                                        
@@ -60,7 +60,7 @@ discard block  | 
                                                    ||
| 60 | 60 | var sdk = pgSDK;  | 
                                                        
| 61 | 61 | }  | 
                                                        
| 62 | 62 | |
| 63 | - var positionSelector = '<?php echo $positionSelector;?>';  | 
                                                        |
| 63 | + var positionSelector = '<?php echo $positionSelector; ?>';  | 
                                                        |
| 64 | 64 |          if (positionSelector === 'default') { | 
                                                        
| 65 | 65 | positionSelector = '.pagantisSimulator';  | 
                                                        
| 66 | 66 | }  | 
                                                        
@@ -52,29 +52,29 @@ discard block  | 
                                                    ||
| 52 | 52 | $this->title = $this->extraConfig['PAGANTIS_TITLE'];  | 
                                                        
| 53 | 53 | |
| 54 | 54 | //Useful vars  | 
                                                        
| 55 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/';  | 
                                                        |
| 55 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/';  | 
                                                        |
| 56 | 56 |          $this->allowed_currencies = array("EUR");
 | 
                                                        
| 57 | - $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Pagantis.php';  | 
                                                        |
| 57 | + $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)).'/WC_Pagantis.php';  | 
                                                        |
| 58 | 58 |          $this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false);
 | 
                                                        
| 59 | 59 | |
| 60 | 60 | //Panel form fields  | 
                                                        
| 61 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options  | 
                                                        |
| 61 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options  | 
                                                        |
| 62 | 62 | $this->init_settings();  | 
                                                        
| 63 | 63 | |
| 64 | 64 | $this->extraConfig = $this->getExtraConfig();  | 
                                                        
| 65 | 65 | |
| 66 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl();  | 
                                                        |
| 67 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl();  | 
                                                        |
| 66 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl();  | 
                                                        |
| 67 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl();  | 
                                                        |
| 68 | 68 |          foreach ($this->settings as $setting_key => $setting_value) {
 | 
                                                        
| 69 | 69 | $this->$setting_key = $setting_value;  | 
                                                        
| 70 | 70 | }  | 
                                                        
| 71 | 71 | |
| 72 | 72 | //Hooks  | 
                                                        
| 73 | -        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options
 | 
                                                        |
| 74 | -        add_action('admin_notices', array($this, 'pagantisCheckFields'));                          //Check config fields
 | 
                                                        |
| 75 | -        add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage'));          //Pagantis form
 | 
                                                        |
| 76 | -        add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification'));      //Json Notification
 | 
                                                        |
| 77 | -        add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3);
 | 
                                                        |
| 73 | +        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options
 | 
                                                        |
| 74 | +        add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields
 | 
                                                        |
| 75 | +        add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form
 | 
                                                        |
| 76 | +        add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification
 | 
                                                        |
| 77 | +        add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3);
 | 
                                                        |
| 78 | 78 |          add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2);
 | 
                                                        
| 79 | 79 | }  | 
                                                        
| 80 | 80 | |
@@ -86,8 +86,8 @@ discard block  | 
                                                    ||
| 86 | 86 | */  | 
                                                        
| 87 | 87 | public function loadPagantisTranslation($mofile, $domain)  | 
                                                        
| 88 | 88 |      {
 | 
                                                        
| 89 | -        if ('pagantis' === $domain) {
 | 
                                                        |
| 90 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo';  | 
                                                        |
| 89 | +        if ('pagantis'===$domain) {
 | 
                                                        |
| 90 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo';  | 
                                                        |
| 91 | 91 | }  | 
                                                        
| 92 | 92 | return $mofile;  | 
                                                        
| 93 | 93 | }  | 
                                                        
@@ -106,7 +106,7 @@ discard block  | 
                                                    ||
| 106 | 106 | $template_fields = array(  | 
                                                        
| 107 | 107 | 'panel_header' => $this->title,  | 
                                                        
| 108 | 108 | 'panel_description' => $this->method_description,  | 
                                                        
| 109 | -            'button1_label' => __('Login to panel of ', 'pagantis') . ucfirst(WcPagantisGateway::METHOD_ID),
 | 
                                                        |
| 109 | +            'button1_label' => __('Login to panel of ', 'pagantis').ucfirst(WcPagantisGateway::METHOD_ID),
 | 
                                                        |
| 110 | 110 |              'button2_label' => __('Documentation', 'pagantis'),
 | 
                                                        
| 111 | 111 | 'logo' => $this->icon,  | 
                                                        
| 112 | 112 | 'settings' => $this->generate_settings_html($this->form_fields, false)  | 
                                                        
@@ -120,24 +120,24 @@ discard block  | 
                                                    ||
| 120 | 120 | public function pagantisCheckFields()  | 
                                                        
| 121 | 121 |      {
 | 
                                                        
| 122 | 122 | $error_string = '';  | 
                                                        
| 123 | -        if ($this->settings['enabled'] !== 'yes') {
 | 
                                                        |
| 123 | +        if ($this->settings['enabled']!=='yes') {
 | 
                                                        |
| 124 | 124 | return;  | 
                                                        
| 125 | 125 |          } elseif (!version_compare(phpversion(), '5.3.0', '>=')) {
 | 
                                                        
| 126 | -            $error_string =  __(' is not compatible with your php and/or curl version', 'pagantis');
 | 
                                                        |
| 126 | +            $error_string = __(' is not compatible with your php and/or curl version', 'pagantis');
 | 
                                                        |
| 127 | 127 | $this->settings['enabled'] = 'no';  | 
                                                        
| 128 | 128 |          } elseif ($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="") {
 | 
                                                        
| 129 | 129 |              $error_string = __(' is not configured correctly, the fields Public Key and Secret Key are mandatory for use this plugin', 'pagantis');
 | 
                                                        
| 130 | 130 | $this->settings['enabled'] = 'no';  | 
                                                        
| 131 | 131 |          } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) {
 | 
                                                        
| 132 | -            $error_string =  __(' only can be used in Euros', 'pagantis');
 | 
                                                        |
| 132 | +            $error_string = __(' only can be used in Euros', 'pagantis');
 | 
                                                        |
| 133 | 133 | $this->settings['enabled'] = 'no';  | 
                                                        
| 134 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']<'2'  | 
                                                        |
| 135 | -                  || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']>'12') {
 | 
                                                        |
| 134 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] < '2'  | 
                                                        |
| 135 | +                  || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] > '12') {
 | 
                                                        |
| 136 | 136 |              $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis');
 | 
                                                        
| 137 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']<'2'  | 
                                                        |
| 138 | -                  || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']>'12') {
 | 
                                                        |
| 137 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] < '2'  | 
                                                        |
| 138 | +                  || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] > '12') {
 | 
                                                        |
| 139 | 139 |              $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis');
 | 
                                                        
| 140 | -        } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']<0) {
 | 
                                                        |
| 140 | +        } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] < 0) {
 | 
                                                        |
| 141 | 141 |              $error_string = __(' can not have a minimum amount less than 0', 'pagantis');
 | 
                                                        
| 142 | 142 | }  | 
                                                        
| 143 | 143 | |
@@ -171,7 +171,7 @@ discard block  | 
                                                    ||
| 171 | 171 | |
| 172 | 172 |              $shippingAddress = $order->get_address('shipping');
 | 
                                                        
| 173 | 173 |              $billingAddress = $order->get_address('billing');
 | 
                                                        
| 174 | -            if ($shippingAddress['address_1'] == '') {
 | 
                                                        |
| 174 | +            if ($shippingAddress['address_1']=='') {
 | 
                                                        |
| 175 | 175 | $shippingAddress = $billingAddress;  | 
                                                        
| 176 | 176 | }  | 
                                                        
| 177 | 177 | |
@@ -198,7 +198,7 @@ discard block  | 
                                                    ||
| 198 | 198 | ->setNationalId($national_id)  | 
                                                        
| 199 | 199 | ->setTaxId($tax_id)  | 
                                                        
| 200 | 200 | ;  | 
                                                        
| 201 | - $orderBillingAddress = new Address();  | 
                                                        |
| 201 | + $orderBillingAddress = new Address();  | 
                                                        |
| 202 | 202 | $orderBillingAddress  | 
                                                        
| 203 | 203 | ->setZipCode($billingAddress['postcode'])  | 
                                                        
| 204 | 204 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name'])  | 
                                                        
@@ -329,7 +329,7 @@ discard block  | 
                                                    ||
| 329 | 329 |                  wc_get_template('iframe.php', $template_fields, '', $this->template_path);
 | 
                                                        
| 330 | 330 | }  | 
                                                        
| 331 | 331 |          } catch (\Exception $exception) {
 | 
                                                        
| 332 | -            wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error');
 | 
                                                        |
| 332 | +            wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error');
 | 
                                                        |
| 333 | 333 | $this->insertLog($exception);  | 
                                                        
| 334 | 334 |              $checkout_url = get_permalink(wc_get_page_id('checkout'));
 | 
                                                        
| 335 | 335 | wp_redirect($checkout_url);  | 
                                                        
@@ -343,7 +343,7 @@ discard block  | 
                                                    ||
| 343 | 343 | public function pagantisNotification()  | 
                                                        
| 344 | 344 |      {
 | 
                                                        
| 345 | 345 |          try {
 | 
                                                        
| 346 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order';  | 
                                                        |
| 346 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order';  | 
                                                        |
| 347 | 347 | |
| 348 | 348 |              include_once('notifyController.php');
 | 
                                                        
| 349 | 349 | $notify = new WcPagantisNotify();  | 
                                                        
@@ -382,10 +382,10 @@ discard block  | 
                                                    ||
| 382 | 382 | */  | 
                                                        
| 383 | 383 | public function pagantisCompleteStatus($status, $order_id, $order)  | 
                                                        
| 384 | 384 |      {
 | 
                                                        
| 385 | -        if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) {
 | 
                                                        |
| 386 | -            if ($order->get_status() == 'failed') {
 | 
                                                        |
| 385 | +        if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) {
 | 
                                                        |
| 386 | +            if ($order->get_status()=='failed') {
 | 
                                                        |
| 387 | 387 | $status = 'processing';  | 
                                                        
| 388 | -            } elseif ($order->get_status() == 'pending' && $status=='completed') {
 | 
                                                        |
| 388 | +            } elseif ($order->get_status()=='pending' && $status=='completed') {
 | 
                                                        |
| 389 | 389 | $status = 'processing';  | 
                                                        
| 390 | 390 | }  | 
                                                        
| 391 | 391 | }  | 
                                                        
@@ -409,7 +409,7 @@ discard block  | 
                                                    ||
| 409 | 409 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']);  | 
                                                        
| 410 | 410 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries));  | 
                                                        
| 411 | 411 | if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' &&  | 
                                                        
| 412 | -            (int)$this->get_order_total()>$this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] && $allowedCountry) {
 | 
                                                        |
| 412 | +            (int) $this->get_order_total() > $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] && $allowedCountry) {
 | 
                                                        |
| 413 | 413 | return true;  | 
                                                        
| 414 | 414 | }  | 
                                                        
| 415 | 415 | |
@@ -437,7 +437,7 @@ discard block  | 
                                                    ||
| 437 | 437 | |
| 438 | 438 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function  | 
                                                        
| 439 | 439 |              if (strpos($redirectUrl, 'order-pay=')===false) {
 | 
                                                        
| 440 | - $redirectUrl.="&order-pay=".$order_id;  | 
                                                        |
| 440 | + $redirectUrl .= "&order-pay=".$order_id;  | 
                                                        |
| 441 | 441 | }  | 
                                                        
| 442 | 442 | |
| 443 | 443 | return array(  | 
                                                        
@@ -446,7 +446,7 @@ discard block  | 
                                                    ||
| 446 | 446 | );  | 
                                                        
| 447 | 447 | |
| 448 | 448 |          } catch (Exception $e) {
 | 
                                                        
| 449 | -            wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error');
 | 
                                                        |
| 449 | +            wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error');
 | 
                                                        |
| 450 | 450 | return array();  | 
                                                        
| 451 | 451 | }  | 
                                                        
| 452 | 452 | }  | 
                                                        
@@ -506,7 +506,7 @@ discard block  | 
                                                    ||
| 506 | 506 | private function generateUrl($url)  | 
                                                        
| 507 | 507 |      {
 | 
                                                        
| 508 | 508 | $parsed_url = parse_url($url);  | 
                                                        
| 509 | -        if ($parsed_url !== false) {
 | 
                                                        |
| 509 | +        if ($parsed_url!==false) {
 | 
                                                        |
| 510 | 510 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query'];  | 
                                                        
| 511 | 511 | parse_str($parsed_url['query'], $arrayParams);  | 
                                                        
| 512 | 512 |              foreach ($arrayParams as $keyParam => $valueParam) {
 | 
                                                        
@@ -554,11 +554,10 @@ discard block  | 
                                                    ||
| 554 | 554 | private function getKeysUrl($order, $url)  | 
                                                        
| 555 | 555 |      {
 | 
                                                        
| 556 | 556 | $defaultFields = (get_class($order)=='WC_Order') ?  | 
                                                        
| 557 | -            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) :
 | 
                                                        |
| 558 | - array();  | 
                                                        |
| 557 | +            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array();
 | 
                                                        |
| 559 | 558 | |
| 560 | 559 | $parsedUrl = parse_url($url);  | 
                                                        
| 561 | -        if ($parsedUrl !== false) {
 | 
                                                        |
| 560 | +        if ($parsedUrl!==false) {
 | 
                                                        |
| 562 | 561 | //Replace parameters from url  | 
                                                        
| 563 | 562 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields);  | 
                                                        
| 564 | 563 | |
@@ -603,7 +602,7 @@ discard block  | 
                                                    ||
| 603 | 602 |          foreach ($arrayParams as $keyParam => $valueParam) {
 | 
                                                        
| 604 | 603 |              preg_match('#\{{.*?}\}#', $valueParam, $match);
 | 
                                                        
| 605 | 604 |              if (count($match)) {
 | 
                                                        
| 606 | -                $key = str_replace(array('{{','}}'), array('',''), $match[0]);
 | 
                                                        |
| 605 | +                $key = str_replace(array('{{', '}}'), array('', ''), $match[0]);
 | 
                                                        |
| 607 | 606 | $arrayParams[$keyParam] = $defaultFields[$key];  | 
                                                        
| 608 | 607 | }  | 
                                                        
| 609 | 608 | }  | 
                                                        
@@ -618,13 +617,13 @@ discard block  | 
                                                    ||
| 618 | 617 | */  | 
                                                        
| 619 | 618 | private function unparseUrl($parsed_url)  | 
                                                        
| 620 | 619 |      {
 | 
                                                        
| 621 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';  | 
                                                        |
| 620 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : '';  | 
                                                        |
| 622 | 621 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : '';  | 
                                                        
| 623 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';  | 
                                                        |
| 624 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';  | 
                                                        |
| 625 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';  | 
                                                        |
| 622 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : '';  | 
                                                        |
| 623 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : '';  | 
                                                        |
| 624 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : '';  | 
                                                        |
| 626 | 625 | $path = $parsed_url['path'];  | 
                                                        
| 627 | - return $scheme . $host . $port . $path . $query . $fragment;  | 
                                                        |
| 626 | + return $scheme.$host.$port.$path.$query.$fragment;  | 
                                                        |
| 628 | 627 | }  | 
                                                        
| 629 | 628 | |
| 630 | 629 | /**  | 
                                                        
@@ -646,20 +645,20 @@ discard block  | 
                                                    ||
| 646 | 645 | $is_guest = "false";  | 
                                                        
| 647 | 646 | $sign_up = substr($current_user->user_registered, 0, 10);  | 
                                                        
| 648 | 647 | $customer_orders = get_posts(array(  | 
                                                        
| 649 | - 'numberposts' => - 1,  | 
                                                        |
| 648 | + 'numberposts' => -1,  | 
                                                        |
| 650 | 649 | 'meta_key' => '_customer_user',  | 
                                                        
| 651 | 650 | 'meta_value' => $current_user->ID,  | 
                                                        
| 652 | - 'post_type' => array( 'shop_order' ),  | 
                                                        |
| 653 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded' ),  | 
                                                        |
| 651 | +                'post_type'   => array('shop_order'),
 | 
                                                        |
| 652 | +                'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
 | 
                                                        |
| 654 | 653 | ));  | 
                                                        
| 655 | 654 |          } else {
 | 
                                                        
| 656 | 655 | $is_guest = "true";  | 
                                                        
| 657 | 656 | $customer_orders = get_posts(array(  | 
                                                        
| 658 | - 'numberposts' => - 1,  | 
                                                        |
| 657 | + 'numberposts' => -1,  | 
                                                        |
| 659 | 658 | 'meta_key' => '_billing_email',  | 
                                                        
| 660 | 659 | 'meta_value' => $billingEmail,  | 
                                                        
| 661 | - 'post_type' => array( 'shop_order' ),  | 
                                                        |
| 662 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded'),  | 
                                                        |
| 660 | +                'post_type'   => array('shop_order'),
 | 
                                                        |
| 661 | +                'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
 | 
                                                        |
| 663 | 662 | ));  | 
                                                        
| 664 | 663 |              foreach ($customer_orders as $customer_order) {
 | 
                                                        
| 665 | 664 | if (trim($sign_up)=='' ||  | 
                                                        
@@ -688,7 +687,7 @@ discard block  | 
                                                    ||
| 688 | 687 | //Check if id exists  | 
                                                        
| 689 | 688 |          $resultsSelect = $wpdb->get_results("select * from $tableName where id='$orderId'");
 | 
                                                        
| 690 | 689 | $countResults = count($resultsSelect);  | 
                                                        
| 691 | -        if ($countResults == 0) {
 | 
                                                        |
| 690 | +        if ($countResults==0) {
 | 
                                                        |
| 692 | 691 | $wpdb->insert(  | 
                                                        
| 693 | 692 | $tableName,  | 
                                                        
| 694 | 693 |                  array('id' => $orderId, 'order_id' => $pagantisOrderId),
 | 
                                                        
@@ -713,7 +712,7 @@ discard block  | 
                                                    ||
| 713 | 712 | global $wpdb;  | 
                                                        
| 714 | 713 | $tableName = $wpdb->prefix.self::ORDERS_TABLE;  | 
                                                        
| 715 | 714 | |
| 716 | -        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
 | 
                                                        |
| 715 | +        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
 | 
                                                        |
| 717 | 716 | $charset_collate = $wpdb->get_charset_collate();  | 
                                                        
| 718 | 717 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50),  | 
                                                        
| 719 | 718 | UNIQUE KEY id (id)) $charset_collate";  | 
                                                        
@@ -746,9 +745,9 @@ discard block  | 
                                                    ||
| 746 | 745 | */  | 
                                                        
| 747 | 746 | private function getNationalId($order)  | 
                                                        
| 748 | 747 |      {
 | 
                                                        
| 749 | -        foreach ((array)$order->get_meta_data() as $mdObject) {
 | 
                                                        |
| 748 | +        foreach ((array) $order->get_meta_data() as $mdObject) {
 | 
                                                        |
| 750 | 749 | $data = $mdObject->get_data();  | 
                                                        
| 751 | -            if ($data['key'] == 'vat_number') {
 | 
                                                        |
| 750 | +            if ($data['key']=='vat_number') {
 | 
                                                        |
| 752 | 751 | return $data['value'];  | 
                                                        
| 753 | 752 | }  | 
                                                        
| 754 | 753 | }  | 
                                                        
@@ -763,9 +762,9 @@ discard block  | 
                                                    ||
| 763 | 762 | */  | 
                                                        
| 764 | 763 | private function getTaxId($order)  | 
                                                        
| 765 | 764 |      {
 | 
                                                        
| 766 | -        foreach ((array)$order->get_meta_data() as $mdObject) {
 | 
                                                        |
| 765 | +        foreach ((array) $order->get_meta_data() as $mdObject) {
 | 
                                                        |
| 767 | 766 | $data = $mdObject->get_data();  | 
                                                        
| 768 | -            if ($data['key'] == 'billing_cfpiva') {
 | 
                                                        |
| 767 | +            if ($data['key']=='billing_cfpiva') {
 | 
                                                        |
| 769 | 768 | return $data['value'];  | 
                                                        
| 770 | 769 | }  | 
                                                        
| 771 | 770 | }  | 
                                                        
@@ -795,7 +794,7 @@ discard block  | 
                                                    ||
| 795 | 794 |      {
 | 
                                                        
| 796 | 795 | global $wpdb;  | 
                                                        
| 797 | 796 | $tableName = $wpdb->prefix.self::LOGS_TABLE;  | 
                                                        
| 798 | -        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
 | 
                                                        |
| 797 | +        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
 | 
                                                        |
| 799 | 798 | $charset_collate = $wpdb->get_charset_collate();  | 
                                                        
| 800 | 799 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL,  | 
                                                        
| 801 | 800 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate";  |