@@ -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 ); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | function findDestinationSim() |
50 | 50 | { |
51 | - var destinationSim = '<?php echo $finalDestination;?>'; |
|
51 | + var destinationSim = '<?php echo $finalDestination; ?>'; |
|
52 | 52 | if (destinationSim === 'default' || destinationSim == '') { |
53 | 53 | destinationSim = 'woocommerce-product-details__short-description'; |
54 | 54 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | var positionSelector = findPositionSelector(); |
94 | 94 | var priceSelector = findPriceSelector(); |
95 | - var promotedProduct = '<?php echo $promoted;?>'; |
|
95 | + var promotedProduct = '<?php echo $promoted; ?>'; |
|
96 | 96 | var quantitySelector = findQuantitySelector(); |
97 | 97 | |
98 | 98 | simulator_options = { |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | country: country, |
105 | 105 | itemAmountSelector: priceSelector, |
106 | 106 | amountParserConfig : { |
107 | - thousandSeparator: '<?php echo $thousandSeparator;?>', |
|
108 | - decimalSeparator: '<?php echo $decimalSeparator;?>' |
|
107 | + thousandSeparator: '<?php echo $thousandSeparator; ?>', |
|
108 | + decimalSeparator: '<?php echo $decimalSeparator; ?>' |
|
109 | 109 | }, |
110 | - numInstalments : '<?php echo $pagantisQuotesStart;?>', |
|
111 | - skin : <?php echo $pagantisSimulatorSkin;?>, |
|
112 | - position: <?php echo $pagantisSimulatorPosition;?> |
|
110 | + numInstalments : '<?php echo $pagantisQuotesStart; ?>', |
|
111 | + skin : <?php echo $pagantisSimulatorSkin; ?>, |
|
112 | + position: <?php echo $pagantisSimulatorPosition; ?> |
|
113 | 113 | }; |
114 | 114 | |
115 | 115 | window.pgSDK = sdk; |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | { |
139 | 139 | if (window.WCSimulatorId != '') |
140 | 140 | { |
141 | - var updateSelector = '<?php echo $variationSelector;?>'; |
|
141 | + var updateSelector = '<?php echo $variationSelector; ?>'; |
|
142 | 142 | |
143 | - var productType = '<?php echo $productType;?>'; |
|
143 | + var productType = '<?php echo $productType; ?>'; |
|
144 | 144 | |
145 | 145 | if (updateSelector == 'default' || updateSelector === '' || productType!=='variable') |
146 | 146 | { |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | } |
174 | 174 | </style> |
175 | 175 | <?php |
176 | -if ($promoted == 'true') { |
|
176 | +if ($promoted=='true') { |
|
177 | 177 | echo $promotedMessage; |
178 | 178 | } |
179 | 179 | ?> |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | register_activation_hook(__FILE__, array($this, 'pagantisActivation')); |
86 | 86 | add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl')); |
87 | 87 | add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave')); |
88 | - add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate')); |
|
89 | - add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave')); |
|
88 | + add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate')); |
|
89 | + add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave')); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | { |
113 | 113 | $post_id = $product->get_id(); |
114 | 114 | $pagantis_promoted_value = $_REQUEST['pagantis_promoted']; |
115 | - if ($pagantis_promoted_value == 'on') { |
|
115 | + if ($pagantis_promoted_value=='on') { |
|
116 | 116 | $pagantis_promoted_value = 'yes'; |
117 | 117 | } else { |
118 | 118 | $pagantis_promoted_value = 'no'; |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | public function pagantisPromotedVarSave($post_id) |
147 | 147 | { |
148 | 148 | $pagantis_promoted_value = $_POST['pagantis_promoted']; |
149 | - if ($pagantis_promoted_value == null) { |
|
149 | + if ($pagantis_promoted_value==null) { |
|
150 | 150 | $pagantis_promoted_value = 'no'; |
151 | 151 | } |
152 | 152 | update_post_meta($post_id, 'custom_product_pagantis_promoted', esc_attr($pagantis_promoted_value)); |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function loadPagantisTranslation($mofile, $domain) |
161 | 161 | { |
162 | - if ('pagantis' === $domain) { |
|
163 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
162 | + if ('pagantis'===$domain) { |
|
163 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
164 | 164 | } |
165 | 165 | return $mofile; |
166 | 166 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | global $wpdb; |
174 | 174 | |
175 | 175 | $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE; |
176 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
176 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
177 | 177 | $charset_collate = $wpdb->get_charset_collate(); |
178 | 178 | $sql = "CREATE TABLE $tableName ( order_id int NOT NULL, |
179 | 179 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate"; |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
185 | 185 | |
186 | 186 | //Check if table exists |
187 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; |
|
187 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; |
|
188 | 188 | if ($tableExists) { |
189 | 189 | $charset_collate = $wpdb->get_charset_collate(); |
190 | 190 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | //Updated value field to adapt to new length < v8.0.1 |
200 | 200 | $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'"; |
201 | 201 | $results = $wpdb->get_results($query, ARRAY_A); |
202 | - if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') { |
|
202 | + if ($results['0']['COLUMN_TYPE']=='varchar(100)') { |
|
203 | 203 | $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)"; |
204 | 204 | $wpdb->query($sql); |
205 | 205 | } |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
210 | 210 | $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A); |
211 | 211 | foreach ($dbCurrentConfig as $item) { |
212 | - if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
212 | + if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
213 | 213 | $css_price_selector = $this->preparePriceSelector($item['value']); |
214 | - if ($item['value'] != $css_price_selector) { |
|
214 | + if ($item['value']!=$css_price_selector) { |
|
215 | 215 | $wpdb->update( |
216 | 216 | $tableName, |
217 | 217 | array('value' => stripslashes($css_price_selector)), |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | array('%s') |
221 | 221 | ); |
222 | 222 | } |
223 | - } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
223 | + } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
224 | 224 | $css_quantity_selector = $this->prepareQuantitySelector($item['value']); |
225 | - if ($item['value'] != $css_quantity_selector) { |
|
225 | + if ($item['value']!=$css_quantity_selector) { |
|
226 | 226 | $wpdb->update( |
227 | 227 | $tableName, |
228 | 228 | array('value' => stripslashes($css_quantity_selector)), |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
240 | 240 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
241 | 241 | $results = $wpdb->get_results($query, ARRAY_A); |
242 | - if (count($results) == 0) { |
|
242 | + if (count($results)==0) { |
|
243 | 243 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value' => '.'), array('%s', '%s')); |
244 | 244 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value' => ','), array('%s', '%s')); |
245 | 245 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
249 | 249 | $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'"; |
250 | 250 | $results = $wpdb->get_results($query, ARRAY_A); |
251 | - if (count($results) == 0) { |
|
251 | + if (count($results)==0) { |
|
252 | 252 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value' => '0'), array('%s', '%s')); |
253 | 253 | } |
254 | 254 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
257 | 257 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'"; |
258 | 258 | $results = $wpdb->get_results($query, ARRAY_A); |
259 | - if (count($results) == 0) { |
|
259 | + if (count($results)==0) { |
|
260 | 260 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value' => 'default'), array('%s', '%s')); |
261 | 261 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value' => 'default'), array('%s', '%s')); |
262 | 262 | } |
@@ -265,17 +265,17 @@ discard block |
||
265 | 265 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
266 | 266 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'"; |
267 | 267 | $results = $wpdb->get_results($query, ARRAY_A); |
268 | - if (count($results) == 0) { |
|
268 | + if (count($results)==0) { |
|
269 | 269 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', 'value' => 'sdk.simulator.types.CHECKOUT_PAGE'), array('%s', '%s')); |
270 | 270 | $wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), array('%s'), array('%s')); |
271 | 271 | } |
272 | 272 | |
273 | 273 | //Adapting to variable selector < v8.3.6 |
274 | - $variableSelector="div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
274 | + $variableSelector = "div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
275 | 275 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
276 | 276 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'"; |
277 | 277 | $results = $wpdb->get_results($query, ARRAY_A); |
278 | - if (count($results) == 0) { |
|
278 | + if (count($results)==0) { |
|
279 | 279 | $wpdb->update($tableName, array('value' => $variableSelector), array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION'), array('%s'), array('%s')); |
280 | 280 | } |
281 | 281 | |
@@ -323,9 +323,9 @@ discard block |
||
323 | 323 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
324 | 324 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
325 | 325 | $totalPrice = $product->get_price(); |
326 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
327 | - if ($cfg['enabled'] !== 'yes' || $cfg['pagantis_public_key'] == '' || $cfg['pagantis_private_key'] == '' || |
|
328 | - $cfg['simulator'] !== 'yes' || !$allowedCountry || !$validAmount) { |
|
326 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
327 | + if ($cfg['enabled']!=='yes' || $cfg['pagantis_public_key']=='' || $cfg['pagantis_private_key']=='' || |
|
328 | + $cfg['simulator']!=='yes' || !$allowedCountry || !$validAmount) { |
|
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | */ |
365 | 365 | public function addPagantisGateway($methods) |
366 | 366 | { |
367 | - if (! class_exists('WC_Payment_Gateway')) { |
|
367 | + if (!class_exists('WC_Payment_Gateway')) { |
|
368 | 368 | return $methods; |
369 | 369 | } |
370 | 370 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | */ |
420 | 420 | public function pagantisRowMeta($links, $file) |
421 | 421 | { |
422 | - if ($file == plugin_basename(__FILE__)) { |
|
422 | + if ($file==plugin_basename(__FILE__)) { |
|
423 | 423 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
424 | 424 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
425 | 425 | __('API documentation', 'pagantis').'</a>'; |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
448 | 448 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
449 | 449 | $results = $wpdb->get_results($query); |
450 | - if (isset($results) && $privateKey == $secretKey) { |
|
450 | + if (isset($results) && $privateKey==$secretKey) { |
|
451 | 451 | foreach ($results as $key => $result) { |
452 | 452 | $response[$key]['timestamp'] = $result->createdAt; |
453 | 453 | $response[$key]['log'] = json_decode($result->log); |
@@ -474,12 +474,12 @@ discard block |
||
474 | 474 | |
475 | 475 | $filters = ($data->get_params()); |
476 | 476 | $secretKey = $filters['secret']; |
477 | - $cfg = get_option('woocommerce_pagantis_settings'); |
|
477 | + $cfg = get_option('woocommerce_pagantis_settings'); |
|
478 | 478 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
479 | - if ($privateKey != $secretKey) { |
|
479 | + if ($privateKey!=$secretKey) { |
|
480 | 480 | $response['status'] = 401; |
481 | 481 | $response['result'] = 'Unauthorized'; |
482 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
482 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
483 | 483 | if (count($_POST)) { |
484 | 484 | foreach ($_POST as $config => $value) { |
485 | 485 | if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc"; |
540 | 540 | $results = $wpdb->get_results($query); |
541 | 541 | |
542 | - if (isset($results) && $privateKey == $secretKey) { |
|
542 | + if (isset($results) && $privateKey==$secretKey) { |
|
543 | 543 | foreach ($results as $result) { |
544 | 544 | $key = $result->ID; |
545 | 545 | $response['message'][$key]['timestamp'] = $result->post_date; |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | */ |
624 | 624 | private function prepareQuantitySelector($css_quantity_selector) |
625 | 625 | { |
626 | - if ($css_quantity_selector == 'default' || $css_quantity_selector == '') { |
|
626 | + if ($css_quantity_selector=='default' || $css_quantity_selector=='') { |
|
627 | 627 | $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
628 | 628 | } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
629 | 629 | $css_quantity_selector = serialize(array($css_quantity_selector)); |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | */ |
640 | 640 | private function preparePriceSelector($css_price_selector) |
641 | 641 | { |
642 | - if ($css_price_selector == 'default' || $css_price_selector == '') { |
|
642 | + if ($css_price_selector=='default' || $css_price_selector=='') { |
|
643 | 643 | $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
644 | 644 | } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
645 | 645 | $css_price_selector = serialize(array($css_price_selector)); |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | { |
658 | 658 | $metaProduct = get_post_meta($product_id); |
659 | 659 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && |
660 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
660 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
661 | 661 | } |
662 | 662 | } |
663 | 663 |