@@ -33,25 +33,25 @@ discard block |
||
33 | 33 | const ORDERS_TABLE = 'posts'; |
34 | 34 | |
35 | 35 | public $defaultConfigs = array( |
36 | - 'PAGANTIS_TITLE'=>'Pago en cuotas', |
|
37 | - 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'sdk.simulator.types.SELECTABLE_TEXT_CUSTOM', |
|
38 | - 'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'sdk.simulator.skins.BLUE', |
|
39 | - 'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons', |
|
40 | - 'PAGANTIS_SIMULATOR_START_INSTALLMENTS'=>3, |
|
41 | - 'PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'=>12, |
|
42 | - 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'=>'default', |
|
43 | - 'PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'=>'sdk.simulator.positions.INNER', |
|
44 | - '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";}', |
|
45 | - 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'=>'a:2:{i:0;s:22:"div.quantity input.qty";i:1;s:18:"div.quantity>input";}', |
|
46 | - 'PAGANTIS_FORM_DISPLAY_TYPE'=>0, |
|
47 | - 'PAGANTIS_DISPLAY_MIN_AMOUNT'=>1, |
|
48 | - 'PAGANTIS_DISPLAY_MAX_AMOUNT'=>0, |
|
49 | - 'PAGANTIS_URL_OK'=>'', |
|
50 | - 'PAGANTIS_URL_KO'=>'', |
|
51 | - 'PAGANTIS_ALLOWED_COUNTRIES' => 'a:3:{i:0;s:2:"es";i:1;s:2:"it";i:2;s:2:"fr";}', |
|
52 | - 'PAGANTIS_PROMOTION_EXTRA' => '<p>Finance this product <span class="pg-no-interest">without interest!</span></p>', |
|
53 | - 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR' => '.', |
|
54 | - 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR' => ',' |
|
36 | + 'PAGANTIS_TITLE'=>'Pago en cuotas', |
|
37 | + 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'sdk.simulator.types.SELECTABLE_TEXT_CUSTOM', |
|
38 | + 'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'sdk.simulator.skins.BLUE', |
|
39 | + 'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons', |
|
40 | + 'PAGANTIS_SIMULATOR_START_INSTALLMENTS'=>3, |
|
41 | + 'PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'=>12, |
|
42 | + 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'=>'default', |
|
43 | + 'PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'=>'sdk.simulator.positions.INNER', |
|
44 | + '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";}', |
|
45 | + 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'=>'a:2:{i:0;s:22:"div.quantity input.qty";i:1;s:18:"div.quantity>input";}', |
|
46 | + 'PAGANTIS_FORM_DISPLAY_TYPE'=>0, |
|
47 | + 'PAGANTIS_DISPLAY_MIN_AMOUNT'=>1, |
|
48 | + 'PAGANTIS_DISPLAY_MAX_AMOUNT'=>0, |
|
49 | + 'PAGANTIS_URL_OK'=>'', |
|
50 | + 'PAGANTIS_URL_KO'=>'', |
|
51 | + 'PAGANTIS_ALLOWED_COUNTRIES' => 'a:3:{i:0;s:2:"es";i:1;s:2:"it";i:2;s:2:"fr";}', |
|
52 | + 'PAGANTIS_PROMOTION_EXTRA' => '<p>Finance this product <span class="pg-no-interest">without interest!</span></p>', |
|
53 | + 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR' => '.', |
|
54 | + 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR' => ',' |
|
55 | 55 | ); |
56 | 56 | |
57 | 57 | /** @var Array $extraConfig */ |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | if ($file == plugin_basename(__FILE__)) { |
388 | 388 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
389 | 389 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
390 | - __('API documentation', 'pagantis').'</a>'; |
|
390 | + __('API documentation', 'pagantis').'</a>'; |
|
391 | 391 | $links[] = '<a href="'.WcPagantis::SUPPORT_EML.'">'.__('Support', 'pagantis').'</a>'; |
392 | 392 | |
393 | 393 | return $links; |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | register_activation_hook(__FILE__, array($this, 'pagantisActivation')); |
81 | 81 | add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl')); |
82 | 82 | add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave')); |
83 | - add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate')); |
|
84 | - add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave')); |
|
83 | + add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate')); |
|
84 | + add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave')); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | { |
108 | 108 | $post_id = $product->get_id(); |
109 | 109 | $pagantis_promoted_value = $_REQUEST['pagantis_promoted']; |
110 | - if ($pagantis_promoted_value == 'on') { |
|
110 | + if ($pagantis_promoted_value=='on') { |
|
111 | 111 | $pagantis_promoted_value = 'yes'; |
112 | 112 | } else { |
113 | 113 | $pagantis_promoted_value = 'no'; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | public function pagantisPromotedVarSave($post_id) |
142 | 142 | { |
143 | 143 | $pagantis_promoted_value = $_POST['pagantis_promoted']; |
144 | - if ($pagantis_promoted_value == null) { |
|
144 | + if ($pagantis_promoted_value==null) { |
|
145 | 145 | $pagantis_promoted_value = 'no'; |
146 | 146 | } |
147 | 147 | update_post_meta($post_id, 'custom_product_pagantis_promoted', esc_attr($pagantis_promoted_value)); |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function loadPagantisTranslation($mofile, $domain) |
156 | 156 | { |
157 | - if ('pagantis' === $domain) { |
|
158 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
157 | + if ('pagantis'===$domain) { |
|
158 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
159 | 159 | } |
160 | 160 | return $mofile; |
161 | 161 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | global $wpdb; |
169 | 169 | |
170 | 170 | $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE; |
171 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
171 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
172 | 172 | $charset_collate = $wpdb->get_charset_collate(); |
173 | 173 | $sql = "CREATE TABLE $tableName ( order_id int NOT NULL, |
174 | 174 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate"; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
180 | 180 | |
181 | 181 | //Check if table exists |
182 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; |
|
182 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; |
|
183 | 183 | if ($tableExists) { |
184 | 184 | $charset_collate = $wpdb->get_charset_collate(); |
185 | 185 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | //Updated value field to adapt to new length < v8.0.1 |
195 | 195 | $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'"; |
196 | 196 | $results = $wpdb->get_results($query, ARRAY_A); |
197 | - if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') { |
|
197 | + if ($results['0']['COLUMN_TYPE']=='varchar(100)') { |
|
198 | 198 | $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)"; |
199 | 199 | $wpdb->query($sql); |
200 | 200 | } |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
205 | 205 | $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A); |
206 | 206 | foreach ($dbCurrentConfig as $item) { |
207 | - if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
207 | + if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
208 | 208 | $css_price_selector = $this->preparePriceSelector($item['value']); |
209 | - if ($item['value'] != $css_price_selector) { |
|
209 | + if ($item['value']!=$css_price_selector) { |
|
210 | 210 | $wpdb->update( |
211 | 211 | $tableName, |
212 | 212 | array('value' => stripslashes($css_price_selector)), |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | array('%s') |
216 | 216 | ); |
217 | 217 | } |
218 | - } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
218 | + } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
219 | 219 | $css_quantity_selector = $this->prepareQuantitySelector($item['value']); |
220 | - if ($item['value'] != $css_quantity_selector) { |
|
220 | + if ($item['value']!=$css_quantity_selector) { |
|
221 | 221 | $wpdb->update( |
222 | 222 | $tableName, |
223 | 223 | array('value' => stripslashes($css_quantity_selector)), |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
235 | 235 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
236 | 236 | $results = $wpdb->get_results($query, ARRAY_A); |
237 | - if (count($results) == 0) { |
|
237 | + if (count($results)==0) { |
|
238 | 238 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value' => '.'), array('%s', '%s')); |
239 | 239 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value' => ','), array('%s', '%s')); |
240 | 240 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
244 | 244 | $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'"; |
245 | 245 | $results = $wpdb->get_results($query, ARRAY_A); |
246 | - if (count($results) == 0) { |
|
246 | + if (count($results)==0) { |
|
247 | 247 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value' => '0'), array('%s', '%s')); |
248 | 248 | } |
249 | 249 | |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
292 | 292 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
293 | 293 | $totalPrice = $product->get_price(); |
294 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
295 | - if ($cfg['enabled'] !== 'yes' || $cfg['pagantis_public_key'] == '' || $cfg['pagantis_private_key'] == '' || |
|
296 | - $cfg['simulator'] !== 'yes' || !$allowedCountry || !$validAmount) { |
|
294 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
295 | + if ($cfg['enabled']!=='yes' || $cfg['pagantis_public_key']=='' || $cfg['pagantis_private_key']=='' || |
|
296 | + $cfg['simulator']!=='yes' || !$allowedCountry || !$validAmount) { |
|
297 | 297 | return; |
298 | 298 | } |
299 | 299 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | */ |
330 | 330 | public function addPagantisGateway($methods) |
331 | 331 | { |
332 | - if (! class_exists('WC_Payment_Gateway')) { |
|
332 | + if (!class_exists('WC_Payment_Gateway')) { |
|
333 | 333 | return $methods; |
334 | 334 | } |
335 | 335 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | */ |
385 | 385 | public function pagantisRowMeta($links, $file) |
386 | 386 | { |
387 | - if ($file == plugin_basename(__FILE__)) { |
|
387 | + if ($file==plugin_basename(__FILE__)) { |
|
388 | 388 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
389 | 389 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
390 | 390 | __('API documentation', 'pagantis').'</a>'; |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
413 | 413 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
414 | 414 | $results = $wpdb->get_results($query); |
415 | - if (isset($results) && $privateKey == $secretKey) { |
|
415 | + if (isset($results) && $privateKey==$secretKey) { |
|
416 | 416 | foreach ($results as $key => $result) { |
417 | 417 | $response[$key]['timestamp'] = $result->createdAt; |
418 | 418 | $response[$key]['log'] = json_decode($result->log); |
@@ -439,12 +439,12 @@ discard block |
||
439 | 439 | |
440 | 440 | $filters = ($data->get_params()); |
441 | 441 | $secretKey = $filters['secret']; |
442 | - $cfg = get_option('woocommerce_pagantis_settings'); |
|
442 | + $cfg = get_option('woocommerce_pagantis_settings'); |
|
443 | 443 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
444 | - if ($privateKey != $secretKey) { |
|
444 | + if ($privateKey!=$secretKey) { |
|
445 | 445 | $response['status'] = 401; |
446 | 446 | $response['result'] = 'Unauthorized'; |
447 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
447 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
448 | 448 | if (count($_POST)) { |
449 | 449 | foreach ($_POST as $config => $value) { |
450 | 450 | if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc"; |
505 | 505 | $results = $wpdb->get_results($query); |
506 | 506 | |
507 | - if (isset($results) && $privateKey == $secretKey) { |
|
507 | + if (isset($results) && $privateKey==$secretKey) { |
|
508 | 508 | foreach ($results as $result) { |
509 | 509 | $key = $result->ID; |
510 | 510 | $response['message'][$key]['timestamp'] = $result->post_date; |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | */ |
589 | 589 | private function prepareQuantitySelector($css_quantity_selector) |
590 | 590 | { |
591 | - if ($css_quantity_selector == 'default' || $css_quantity_selector == '') { |
|
591 | + if ($css_quantity_selector=='default' || $css_quantity_selector=='') { |
|
592 | 592 | $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
593 | 593 | } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
594 | 594 | $css_quantity_selector = serialize(array($css_quantity_selector)); |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | */ |
605 | 605 | private function preparePriceSelector($css_price_selector) |
606 | 606 | { |
607 | - if ($css_price_selector == 'default' || $css_price_selector == '') { |
|
607 | + if ($css_price_selector=='default' || $css_price_selector=='') { |
|
608 | 608 | $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
609 | 609 | } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
610 | 610 | $css_price_selector = serialize(array($css_price_selector)); |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | { |
623 | 623 | $metaProduct = get_post_meta($product_id); |
624 | 624 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && |
625 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
625 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
626 | 626 | } |
627 | 627 | } |
628 | 628 |
@@ -54,33 +54,33 @@ discard block |
||
54 | 54 | $this->method_title = ucfirst($this->id); |
55 | 55 | |
56 | 56 | //Useful vars |
57 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/'; |
|
57 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/'; |
|
58 | 58 | $this->allowed_currencies = array("EUR"); |
59 | - $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Pagantis.php'; |
|
59 | + $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)).'/WC_Pagantis.php'; |
|
60 | 60 | $this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false); |
61 | 61 | $this->language = strstr(get_locale(), '_', true); |
62 | 62 | $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
63 | 63 | |
64 | 64 | //Panel form fields |
65 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options |
|
65 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options |
|
66 | 66 | $this->init_settings(); |
67 | 67 | |
68 | 68 | $this->extraConfig = $this->getExtraConfig(); |
69 | 69 | $this->title = __($this->extraConfig['PAGANTIS_TITLE'], 'pagantis'); |
70 | 70 | $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis."; |
71 | 71 | |
72 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl(); |
|
73 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl(); |
|
72 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
73 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
74 | 74 | foreach ($this->settings as $setting_key => $setting_value) { |
75 | 75 | $this->$setting_key = $setting_value; |
76 | 76 | } |
77 | 77 | |
78 | 78 | //Hooks |
79 | - add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options |
|
80 | - add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields |
|
81 | - add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
82 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
83 | - add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3); |
|
79 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options |
|
80 | + add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields |
|
81 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
82 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
83 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3); |
|
84 | 84 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
85 | 85 | } |
86 | 86 | |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function loadPagantisTranslation($mofile, $domain) |
94 | 94 | { |
95 | - if ('pagantis' === $domain) { |
|
96 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
95 | + if ('pagantis'===$domain) { |
|
96 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
97 | 97 | } |
98 | 98 | return $mofile; |
99 | 99 | } |
@@ -125,24 +125,24 @@ discard block |
||
125 | 125 | public function pagantisCheckFields() |
126 | 126 | { |
127 | 127 | $error_string = ''; |
128 | - if ($this->settings['enabled'] !== 'yes') { |
|
128 | + if ($this->settings['enabled']!=='yes') { |
|
129 | 129 | return; |
130 | 130 | } elseif (!version_compare(phpversion(), '5.3.0', '>=')) { |
131 | - $error_string = __(' is not compatible with your php and/or curl version', 'pagantis'); |
|
131 | + $error_string = __(' is not compatible with your php and/or curl version', 'pagantis'); |
|
132 | 132 | $this->settings['enabled'] = 'no'; |
133 | 133 | } elseif ($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="") { |
134 | 134 | $error_string = __(' is not configured correctly, the fields Public Key and Secret Key are mandatory for use this plugin', 'pagantis'); |
135 | 135 | $this->settings['enabled'] = 'no'; |
136 | 136 | } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) { |
137 | - $error_string = __(' only can be used in Euros', 'pagantis'); |
|
137 | + $error_string = __(' only can be used in Euros', 'pagantis'); |
|
138 | 138 | $this->settings['enabled'] = 'no'; |
139 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']<'2' |
|
140 | - || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']>'12') { |
|
139 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] < '2' |
|
140 | + || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] > '12') { |
|
141 | 141 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis'); |
142 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']<'2' |
|
143 | - || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']>'12') { |
|
142 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] < '2' |
|
143 | + || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] > '12') { |
|
144 | 144 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis'); |
145 | - } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']<0) { |
|
145 | + } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] < 0) { |
|
146 | 146 | $error_string = __(' can not have a minimum amount less than 0', 'pagantis'); |
147 | 147 | } |
148 | 148 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | $shippingAddress = $order->get_address('shipping'); |
178 | 178 | $billingAddress = $order->get_address('billing'); |
179 | - if ($shippingAddress['address_1'] == '') { |
|
179 | + if ($shippingAddress['address_1']=='') { |
|
180 | 180 | $shippingAddress = $billingAddress; |
181 | 181 | } |
182 | 182 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | ->setNationalId($national_id) |
204 | 204 | ->setTaxId($tax_id) |
205 | 205 | ; |
206 | - $orderBillingAddress = new Address(); |
|
206 | + $orderBillingAddress = new Address(); |
|
207 | 207 | $orderBillingAddress |
208 | 208 | ->setZipCode($billingAddress['postcode']) |
209 | 209 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | $details->addProduct($product); |
275 | 275 | |
276 | 276 | $promotedProduct = $this->isPromoted($item->get_product_id()); |
277 | - if ($promotedProduct == 'true') { |
|
278 | - $promotedAmount+=$product->getAmount(); |
|
279 | - $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
|
280 | - ' - Price: ' . $item->get_total() . |
|
281 | - ' - Qty: ' . $product->getQuantity() . |
|
282 | - ' - Item ID: ' . $item['id_product']; |
|
277 | + if ($promotedProduct=='true') { |
|
278 | + $promotedAmount += $product->getAmount(); |
|
279 | + $promotedMessage = 'Promoted Item: '.$wcProduct->get_name(). |
|
280 | + ' - Price: '.$item->get_total(). |
|
281 | + ' - Qty: '.$product->getQuantity(). |
|
282 | + ' - Item ID: '.$item['id_product']; |
|
283 | 283 | $promotedMessage = substr($promotedMessage, 0, 999); |
284 | 284 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
285 | 285 | } |
@@ -323,9 +323,7 @@ discard block |
||
323 | 323 | |
324 | 324 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
325 | 325 | $purchaseCountry = |
326 | - in_array(strtolower($this->language), $allowedCountries) ? $this->language : |
|
327 | - in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : |
|
328 | - in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null; |
|
326 | + 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; |
|
329 | 327 | |
330 | 328 | $orderConfiguration = new Configuration(); |
331 | 329 | $orderConfiguration |
@@ -367,7 +365,7 @@ discard block |
||
367 | 365 | wc_get_template('iframe.php', $template_fields, '', $this->template_path); |
368 | 366 | } |
369 | 367 | } catch (\Exception $exception) { |
370 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); |
|
368 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); |
|
371 | 369 | $this->insertLog($exception); |
372 | 370 | $checkout_url = get_permalink(wc_get_page_id('checkout')); |
373 | 371 | wp_redirect($checkout_url); |
@@ -381,7 +379,7 @@ discard block |
||
381 | 379 | public function pagantisNotification() |
382 | 380 | { |
383 | 381 | try { |
384 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
382 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
385 | 383 | |
386 | 384 | include_once('notifyController.php'); |
387 | 385 | $notify = new WcPagantisNotify(); |
@@ -420,10 +418,10 @@ discard block |
||
420 | 418 | */ |
421 | 419 | public function pagantisCompleteStatus($status, $order_id, $order) |
422 | 420 | { |
423 | - if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) { |
|
424 | - if ($order->get_status() == 'failed') { |
|
421 | + if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) { |
|
422 | + if ($order->get_status()=='failed') { |
|
425 | 423 | $status = 'processing'; |
426 | - } elseif ($order->get_status() == 'pending' && $status=='completed') { |
|
424 | + } elseif ($order->get_status()=='pending' && $status=='completed') { |
|
427 | 425 | $status = 'processing'; |
428 | 426 | } |
429 | 427 | } |
@@ -448,8 +446,8 @@ discard block |
||
448 | 446 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
449 | 447 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
450 | 448 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
451 | - $totalPrice = (int)$this->get_order_total(); |
|
452 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
449 | + $totalPrice = (int) $this->get_order_total(); |
|
450 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
453 | 451 | if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' && |
454 | 452 | $validAmount && $allowedCountry) { |
455 | 453 | return true; |
@@ -479,7 +477,7 @@ discard block |
||
479 | 477 | |
480 | 478 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
481 | 479 | if (strpos($redirectUrl, 'order-pay=')===false) { |
482 | - $redirectUrl.="&order-pay=".$order_id; |
|
480 | + $redirectUrl .= "&order-pay=".$order_id; |
|
483 | 481 | } |
484 | 482 | |
485 | 483 | return array( |
@@ -488,7 +486,7 @@ discard block |
||
488 | 486 | ); |
489 | 487 | |
490 | 488 | } catch (Exception $e) { |
491 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); |
|
489 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); |
|
492 | 490 | return array(); |
493 | 491 | } |
494 | 492 | } |
@@ -553,7 +551,7 @@ discard block |
||
553 | 551 | private function generateUrl($url) |
554 | 552 | { |
555 | 553 | $parsed_url = parse_url($url); |
556 | - if ($parsed_url !== false) { |
|
554 | + if ($parsed_url!==false) { |
|
557 | 555 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
558 | 556 | parse_str($parsed_url['query'], $arrayParams); |
559 | 557 | foreach ($arrayParams as $keyParam => $valueParam) { |
@@ -601,11 +599,10 @@ discard block |
||
601 | 599 | private function getKeysUrl($order, $url) |
602 | 600 | { |
603 | 601 | $defaultFields = (get_class($order)=='WC_Order') ? |
604 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : |
|
605 | - array(); |
|
602 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array(); |
|
606 | 603 | |
607 | 604 | $parsedUrl = parse_url($url); |
608 | - if ($parsedUrl !== false) { |
|
605 | + if ($parsedUrl!==false) { |
|
609 | 606 | //Replace parameters from url |
610 | 607 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
611 | 608 | |
@@ -650,7 +647,7 @@ discard block |
||
650 | 647 | foreach ($arrayParams as $keyParam => $valueParam) { |
651 | 648 | preg_match('#\{{.*?}\}#', $valueParam, $match); |
652 | 649 | if (count($match)) { |
653 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]); |
|
650 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]); |
|
654 | 651 | $arrayParams[$keyParam] = $defaultFields[$key]; |
655 | 652 | } |
656 | 653 | } |
@@ -665,13 +662,13 @@ discard block |
||
665 | 662 | */ |
666 | 663 | private function unparseUrl($parsed_url) |
667 | 664 | { |
668 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
665 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
669 | 666 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
670 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
671 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
672 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
667 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
668 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
669 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
673 | 670 | $path = $parsed_url['path']; |
674 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
671 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
675 | 672 | } |
676 | 673 | |
677 | 674 | /** |
@@ -693,20 +690,20 @@ discard block |
||
693 | 690 | $is_guest = "false"; |
694 | 691 | $sign_up = substr($current_user->user_registered, 0, 10); |
695 | 692 | $customer_orders = get_posts(array( |
696 | - 'numberposts' => - 1, |
|
693 | + 'numberposts' => -1, |
|
697 | 694 | 'meta_key' => '_customer_user', |
698 | 695 | 'meta_value' => $current_user->ID, |
699 | - 'post_type' => array( 'shop_order' ), |
|
700 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded' ), |
|
696 | + 'post_type' => array('shop_order'), |
|
697 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
|
701 | 698 | )); |
702 | 699 | } else { |
703 | 700 | $is_guest = "true"; |
704 | 701 | $customer_orders = get_posts(array( |
705 | - 'numberposts' => - 1, |
|
702 | + 'numberposts' => -1, |
|
706 | 703 | 'meta_key' => '_billing_email', |
707 | 704 | 'meta_value' => $billingEmail, |
708 | - 'post_type' => array( 'shop_order' ), |
|
709 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded'), |
|
705 | + 'post_type' => array('shop_order'), |
|
706 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
|
710 | 707 | )); |
711 | 708 | foreach ($customer_orders as $customer_order) { |
712 | 709 | if (trim($sign_up)=='' || |
@@ -735,7 +732,7 @@ discard block |
||
735 | 732 | //Check if id exists |
736 | 733 | $resultsSelect = $wpdb->get_results("select * from $tableName where id='$orderId'"); |
737 | 734 | $countResults = count($resultsSelect); |
738 | - if ($countResults == 0) { |
|
735 | + if ($countResults==0) { |
|
739 | 736 | $wpdb->insert( |
740 | 737 | $tableName, |
741 | 738 | array('id' => $orderId, 'order_id' => $pagantisOrderId), |
@@ -760,7 +757,7 @@ discard block |
||
760 | 757 | global $wpdb; |
761 | 758 | $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
762 | 759 | |
763 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
760 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
764 | 761 | $charset_collate = $wpdb->get_charset_collate(); |
765 | 762 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
766 | 763 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -793,9 +790,9 @@ discard block |
||
793 | 790 | */ |
794 | 791 | private function getNationalId($order) |
795 | 792 | { |
796 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
793 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
797 | 794 | $data = $mdObject->get_data(); |
798 | - if ($data['key'] == 'vat_number') { |
|
795 | + if ($data['key']=='vat_number') { |
|
799 | 796 | return $data['value']; |
800 | 797 | } |
801 | 798 | } |
@@ -810,9 +807,9 @@ discard block |
||
810 | 807 | */ |
811 | 808 | private function getTaxId($order) |
812 | 809 | { |
813 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
810 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
814 | 811 | $data = $mdObject->get_data(); |
815 | - if ($data['key'] == 'billing_cfpiva') { |
|
812 | + if ($data['key']=='billing_cfpiva') { |
|
816 | 813 | return $data['value']; |
817 | 814 | } |
818 | 815 | } |
@@ -842,7 +839,7 @@ discard block |
||
842 | 839 | { |
843 | 840 | global $wpdb; |
844 | 841 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
845 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
842 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
846 | 843 | $charset_collate = $wpdb->get_charset_collate(); |
847 | 844 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
848 | 845 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -861,7 +858,7 @@ discard block |
||
861 | 858 | { |
862 | 859 | $metaProduct = get_post_meta($product_id); |
863 | 860 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && |
864 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
861 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
865 | 862 | } |
866 | 863 | |
867 | 864 | /** |
@@ -874,8 +871,8 @@ discard block |
||
874 | 871 | $promotedAmount = 0; |
875 | 872 | foreach ($items as $key => $item) { |
876 | 873 | $promotedProduct = $this->isPromoted($item['product_id']); |
877 | - if ($promotedProduct == 'true') { |
|
878 | - $promotedAmount+=$item['line_total'] + $item['line_tax']; |
|
874 | + if ($promotedProduct=='true') { |
|
875 | + $promotedAmount += $item['line_total'] + $item['line_tax']; |
|
879 | 876 | } |
880 | 877 | } |
881 | 878 |