@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | register_activation_hook(__FILE__, array($this, 'pagantisActivation')); |
80 | 80 | add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl')); |
81 | 81 | add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave')); |
82 | - add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate')); |
|
83 | - add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave')); |
|
82 | + add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate')); |
|
83 | + add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave')); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | $post_id = $product->get_id(); |
108 | 108 | $pagantis_promoted_value = $_REQUEST['pagantis_promoted']; |
109 | - if ($pagantis_promoted_value == 'on') { |
|
109 | + if ($pagantis_promoted_value=='on') { |
|
110 | 110 | $pagantis_promoted_value = 'yes'; |
111 | 111 | } else { |
112 | 112 | $pagantis_promoted_value = 'no'; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | public function pagantisPromotedVarSave($post_id) |
141 | 141 | { |
142 | 142 | $pagantis_promoted_value = $_POST['pagantis_promoted']; |
143 | - if ($pagantis_promoted_value == null) { |
|
143 | + if ($pagantis_promoted_value==null) { |
|
144 | 144 | $pagantis_promoted_value = 'no'; |
145 | 145 | } |
146 | 146 | update_post_meta($post_id, 'custom_product_pagantis_promoted', esc_attr($pagantis_promoted_value)); |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function loadPagantisTranslation($mofile, $domain) |
155 | 155 | { |
156 | - if ('pagantis' === $domain) { |
|
157 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
156 | + if ('pagantis'===$domain) { |
|
157 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
158 | 158 | } |
159 | 159 | return $mofile; |
160 | 160 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | global $wpdb; |
168 | 168 | |
169 | 169 | $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE; |
170 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
170 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
171 | 171 | $charset_collate = $wpdb->get_charset_collate(); |
172 | 172 | $sql = "CREATE TABLE $tableName ( order_id int NOT NULL, |
173 | 173 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate"; |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
179 | 179 | |
180 | 180 | //Check if table exists |
181 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; |
|
181 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; |
|
182 | 182 | if ($tableExists) { |
183 | 183 | $charset_collate = $wpdb->get_charset_collate(); |
184 | 184 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | //Updated value field to adapt to new length < v8.0.1 |
194 | 194 | $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'"; |
195 | 195 | $results = $wpdb->get_results($query, ARRAY_A); |
196 | - if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') { |
|
196 | + if ($results['0']['COLUMN_TYPE']=='varchar(100)') { |
|
197 | 197 | $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)"; |
198 | 198 | $wpdb->query($sql); |
199 | 199 | } |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
204 | 204 | $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A); |
205 | 205 | foreach ($dbCurrentConfig as $item) { |
206 | - if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
206 | + if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
207 | 207 | $css_price_selector = $this->preparePriceSelector($item['value']); |
208 | - if ($item['value'] != $css_price_selector) { |
|
208 | + if ($item['value']!=$css_price_selector) { |
|
209 | 209 | $wpdb->update( |
210 | 210 | $tableName, |
211 | 211 | array('value' => stripslashes($css_price_selector)), |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | array('%s') |
215 | 215 | ); |
216 | 216 | } |
217 | - } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
217 | + } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
218 | 218 | $css_quantity_selector = $this->prepareQuantitySelector($item['value']); |
219 | - if ($item['value'] != $css_quantity_selector) { |
|
219 | + if ($item['value']!=$css_quantity_selector) { |
|
220 | 220 | $wpdb->update( |
221 | 221 | $tableName, |
222 | 222 | array('value' => stripslashes($css_quantity_selector)), |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
234 | 234 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
235 | 235 | $results = $wpdb->get_results($query, ARRAY_A); |
236 | - if (count($results) == 0) { |
|
236 | + if (count($results)==0) { |
|
237 | 237 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value' => '.'), array('%s', '%s')); |
238 | 238 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value' => ','), array('%s', '%s')); |
239 | 239 | } |
@@ -279,9 +279,9 @@ discard block |
||
279 | 279 | $locale = strtolower(strstr(get_locale(), '_', true)); |
280 | 280 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
281 | 281 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
282 | - if ($cfg['enabled'] !== 'yes' || $cfg['pagantis_public_key'] == '' || $cfg['pagantis_private_key'] == '' || |
|
283 | - $cfg['simulator'] !== 'yes' || $product->price < $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] || |
|
284 | - !$allowedCountry ) { |
|
282 | + if ($cfg['enabled']!=='yes' || $cfg['pagantis_public_key']=='' || $cfg['pagantis_private_key']=='' || |
|
283 | + $cfg['simulator']!=='yes' || $product->price < $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] || |
|
284 | + !$allowedCountry) { |
|
285 | 285 | return; |
286 | 286 | } |
287 | 287 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | */ |
313 | 313 | public function addPagantisGateway($methods) |
314 | 314 | { |
315 | - if (! class_exists('WC_Payment_Gateway')) { |
|
315 | + if (!class_exists('WC_Payment_Gateway')) { |
|
316 | 316 | return $methods; |
317 | 317 | } |
318 | 318 | |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | */ |
368 | 368 | public function pagantisRowMeta($links, $file) |
369 | 369 | { |
370 | - if ($file == plugin_basename(__FILE__)) { |
|
370 | + if ($file==plugin_basename(__FILE__)) { |
|
371 | 371 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
372 | 372 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
373 | 373 | __('API documentation', 'pagantis').'</a>'; |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
396 | 396 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
397 | 397 | $results = $wpdb->get_results($query); |
398 | - if (isset($results) && $privateKey == $secretKey) { |
|
398 | + if (isset($results) && $privateKey==$secretKey) { |
|
399 | 399 | foreach ($results as $key => $result) { |
400 | 400 | $response[$key]['timestamp'] = $result->createdAt; |
401 | 401 | $response[$key]['log'] = json_decode($result->log); |
@@ -422,12 +422,12 @@ discard block |
||
422 | 422 | |
423 | 423 | $filters = ($data->get_params()); |
424 | 424 | $secretKey = $filters['secret']; |
425 | - $cfg = get_option('woocommerce_pagantis_settings'); |
|
425 | + $cfg = get_option('woocommerce_pagantis_settings'); |
|
426 | 426 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
427 | - if ($privateKey != $secretKey) { |
|
427 | + if ($privateKey!=$secretKey) { |
|
428 | 428 | $response['status'] = 401; |
429 | 429 | $response['result'] = 'Unauthorized'; |
430 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
430 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
431 | 431 | if (count($_POST)) { |
432 | 432 | foreach ($_POST as $config => $value) { |
433 | 433 | if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc"; |
488 | 488 | $results = $wpdb->get_results($query); |
489 | 489 | |
490 | - if (isset($results) && $privateKey == $secretKey) { |
|
490 | + if (isset($results) && $privateKey==$secretKey) { |
|
491 | 491 | foreach ($results as $result) { |
492 | 492 | $key = $result->ID; |
493 | 493 | $response['message'][$key]['timestamp'] = $result->post_date; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | */ |
572 | 572 | private function prepareQuantitySelector($css_quantity_selector) |
573 | 573 | { |
574 | - if ($css_quantity_selector == 'default' || $css_quantity_selector == '') { |
|
574 | + if ($css_quantity_selector=='default' || $css_quantity_selector=='') { |
|
575 | 575 | $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
576 | 576 | } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
577 | 577 | $css_quantity_selector = serialize(array($css_quantity_selector)); |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | */ |
588 | 588 | private function preparePriceSelector($css_price_selector) |
589 | 589 | { |
590 | - if ($css_price_selector == 'default' || $css_price_selector == '') { |
|
590 | + if ($css_price_selector=='default' || $css_price_selector=='') { |
|
591 | 591 | $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
592 | 592 | } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
593 | 593 | $css_price_selector = serialize(array($css_price_selector)); |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | private function isPromoted($product_id) |
605 | 605 | { |
606 | 606 | $metaProduct = get_post_meta($product_id); |
607 | - return ($metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
607 | + return ($metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
608 | 608 | } |
609 | 609 | } |
610 | 610 |
@@ -33,24 +33,24 @@ discard block |
||
33 | 33 | const ORDERS_TABLE = 'posts'; |
34 | 34 | |
35 | 35 | public $defaultConfigs = array( |
36 | - 'PAGANTIS_TITLE'=>'Instant Financing', |
|
37 | - 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'sdk.simulator.types.SIMPLE', |
|
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_URL_OK'=>'', |
|
49 | - 'PAGANTIS_URL_KO'=>'', |
|
50 | - 'PAGANTIS_ALLOWED_COUNTRIES' => 'a:2:{i:0;s:2:"es";i:1;s:2:"it";}', |
|
51 | - 'PAGANTIS_PROMOTION_EXTRA' => '<p>Finance this product <span class="pmt-no-interest">without interest!</span></p>', |
|
52 | - 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR' => '.', |
|
53 | - 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR' => ',' |
|
36 | + 'PAGANTIS_TITLE'=>'Instant Financing', |
|
37 | + 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'sdk.simulator.types.SIMPLE', |
|
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_URL_OK'=>'', |
|
49 | + 'PAGANTIS_URL_KO'=>'', |
|
50 | + 'PAGANTIS_ALLOWED_COUNTRIES' => 'a:2:{i:0;s:2:"es";i:1;s:2:"it";}', |
|
51 | + 'PAGANTIS_PROMOTION_EXTRA' => '<p>Finance this product <span class="pmt-no-interest">without interest!</span></p>', |
|
52 | + 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR' => '.', |
|
53 | + 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR' => ',' |
|
54 | 54 | ); |
55 | 55 | |
56 | 56 | /** @var Array $extraConfig */ |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | if ($file == plugin_basename(__FILE__)) { |
374 | 374 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
375 | 375 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
376 | - __('API documentation', 'pagantis').'</a>'; |
|
376 | + __('API documentation', 'pagantis').'</a>'; |
|
377 | 377 | $links[] = '<a href="'.WcPagantis::SUPPORT_EML.'">'.__('Support', 'pagantis').'</a>'; |
378 | 378 | |
379 | 379 | return $links; |
@@ -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 findPositionSelector() |
13 | 13 | { |
14 | - var positionSelector = '<?php echo $positionSelector;?>'; |
|
14 | + var positionSelector = '<?php echo $positionSelector; ?>'; |
|
15 | 15 | if (positionSelector === 'default') { |
16 | 16 | positionSelector = '.pagantisSimulator'; |
17 | 17 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | function findQuantitySelector() |
23 | 23 | { |
24 | - var quantitySelectors = <?php echo json_encode($quantitySelector);?>; |
|
24 | + var quantitySelectors = <?php echo json_encode($quantitySelector); ?>; |
|
25 | 25 | return quantitySelectors.find(function(candidateSelector) { |
26 | 26 | var priceDOM = document.querySelector(candidateSelector); |
27 | 27 | return (priceDOM != null ); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | return finishInterval(); |
63 | 63 | } |
64 | 64 | |
65 | - var price = '<?php echo $total;?>'; |
|
65 | + var price = '<?php echo $total; ?>'; |
|
66 | 66 | |
67 | 67 | var locale = '<?php echo $locale; ?>'; |
68 | 68 | if (locale == 'es' || locale == '') { |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | var positionSelector = findPositionSelector(); |
75 | 75 | var priceSelector = findPriceSelector(); |
76 | - var promotedProduct = '<?php echo $promoted;?>'; |
|
76 | + var promotedProduct = '<?php echo $promoted; ?>'; |
|
77 | 77 | var quantitySelector = findQuantitySelector(); |
78 | 78 | |
79 | 79 | simulator_options = { |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | locale: locale, |
85 | 85 | itemAmountSelector: priceSelector, |
86 | 86 | amountParserConfig : { |
87 | - thousandSeparator: '<?php echo $thousandSeparator;?>', |
|
88 | - decimalSeparator: '<?php echo $decimalSeparator;?>' |
|
87 | + thousandSeparator: '<?php echo $thousandSeparator; ?>', |
|
88 | + decimalSeparator: '<?php echo $decimalSeparator; ?>' |
|
89 | 89 | }, |
90 | - numInstalments : '<?php echo $pagantisQuotesStart;?>', |
|
91 | - skin : <?php echo $pagantisSimulatorSkin;?>, |
|
92 | - position: <?php echo $pagantisSimulatorPosition;?> |
|
90 | + numInstalments : '<?php echo $pagantisQuotesStart; ?>', |
|
91 | + skin : <?php echo $pagantisSimulatorSkin; ?>, |
|
92 | + position: <?php echo $pagantisSimulatorPosition; ?> |
|
93 | 93 | }; |
94 | 94 | |
95 | 95 | if (promotedProduct == 'true') { |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | } |
115 | 115 | </style> |
116 | 116 | <?php |
117 | -if ($promoted == 'true') { |
|
117 | +if ($promoted=='true') { |
|
118 | 118 | echo $promotedMessage; |
119 | 119 | } |
120 | 120 | ?> |