@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | function requireWPPluginFunctions() |
3 | 3 | { |
4 | - if (! function_exists('is_plugin_active')) { |
|
5 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
4 | + if (!function_exists('is_plugin_active')) { |
|
5 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
6 | 6 | } |
7 | 7 | } |
8 | 8 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | function getConfigValue($configKey) |
21 | 21 | { |
22 | 22 | global $wpdb; |
23 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
23 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
24 | 24 | $value = $wpdb->get_var($wpdb->prepare("SELECT value FROM $tableName WHERE config= %s ", $configKey)); |
25 | 25 | |
26 | 26 | return $value; |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | function isPgTableCreated($tableToCheck) |
38 | 38 | { |
39 | 39 | global $wpdb; |
40 | - $tableName = $wpdb->prefix . $tableToCheck; |
|
41 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) { |
|
40 | + $tableName = $wpdb->prefix.$tableToCheck; |
|
41 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")==$tableName) { |
|
42 | 42 | return true; |
43 | 43 | } |
44 | 44 | |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | function createPgCartTable() |
52 | 52 | { |
53 | 53 | global $wpdb; |
54 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
54 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
55 | 55 | $charset_collate = $wpdb->get_charset_collate(); |
56 | 56 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
57 | 57 | UNIQUE KEY id (id)) $charset_collate"; |
58 | 58 | |
59 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
59 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
60 | 60 | dbDelta($sql); |
61 | 61 | } |
62 | 62 | |
@@ -64,14 +64,14 @@ discard block |
||
64 | 64 | { |
65 | 65 | global $wpdb; |
66 | 66 | $charset_collate = $wpdb->get_charset_collate(); |
67 | - $LogsTableName = $wpdb->prefix . PG_LOGS_TABLE_NAME; |
|
67 | + $LogsTableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
|
68 | 68 | $sqlQuery = "CREATE TABLE $LogsTableName ( |
69 | 69 | id int NOT NULL AUTO_INCREMENT, |
70 | 70 | log text NOT NULL, |
71 | 71 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, |
72 | 72 | UNIQUE KEY id (id)) |
73 | 73 | $charset_collate"; |
74 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
74 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
75 | 75 | dbDelta($sqlQuery); |
76 | 76 | } |
77 | 77 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | function insertLogEntry($exception = null, $message = null) |
83 | 83 | { |
84 | 84 | global $wpdb; |
85 | - if (! isPgTableCreated(PG_LOGS_TABLE_NAME)) { |
|
85 | + if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) { |
|
86 | 86 | createLogsTable(); |
87 | 87 | } |
88 | 88 | $logEntry = new Pagantis\ModuleUtils\Model\Log\LogEntry(); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | } else { |
92 | 92 | $logEntry = $logEntry->info($message); |
93 | 93 | } |
94 | - $tableName = $wpdb->prefix . PG_LOGS_TABLE_NAME; |
|
94 | + $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
|
95 | 95 | $wpdb->insert($tableName, array('log' => $logEntry->toJson())); |
96 | 96 | } |
97 | 97 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | { |
103 | 103 | $pgDecimalSeparator = getPgSimulatorDecimalSeparatorConfig(); |
104 | 104 | $wc_decimal_sep = get_option('woocommerce_price_decimal_sep'); |
105 | - if (stripslashes($wc_decimal_sep) == stripslashes($pgDecimalSeparator)) { |
|
105 | + if (stripslashes($wc_decimal_sep)==stripslashes($pgDecimalSeparator)) { |
|
106 | 106 | return true; |
107 | 107 | } else { |
108 | 108 | return false; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | { |
118 | 118 | $pgThousandSeparator = getPgSimulatorThousandsSeparator(); |
119 | 119 | $wc_price_thousand = get_option('woocommerce_price_thousand_sep'); |
120 | - if (stripslashes($wc_price_thousand) == stripslashes($pgThousandSeparator)) { |
|
120 | + if (stripslashes($wc_price_thousand)==stripslashes($pgThousandSeparator)) { |
|
121 | 121 | return true; |
122 | 122 | } else { |
123 | 123 | return false; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | function getPgSimulatorThousandsSeparator() |
131 | 131 | { |
132 | 132 | global $wpdb; |
133 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
133 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
134 | 134 | $query = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
135 | 135 | $result = $wpdb->get_row($query, ARRAY_A); |
136 | 136 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | function getPgSimulatorDecimalSeparatorConfig() |
144 | 144 | { |
145 | 145 | global $wpdb; |
146 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
146 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
147 | 147 | $query = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'"; |
148 | 148 | $result = $wpdb->get_row($query, ARRAY_A); |
149 | 149 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | if (areThousandsSeparatorEqual()) { |
157 | 157 | return; |
158 | 158 | } |
159 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
159 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
160 | 160 | $thousandSeparator = get_option('woocommerce_price_thousand_sep'); |
161 | 161 | $wpdb->update( |
162 | 162 | $tableName, |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | if (areDecimalSeparatorEqual()) { |
174 | 174 | return; |
175 | 175 | } |
176 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
176 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
177 | 177 | $decimalSeparator = get_option('woocommerce_price_decimal_sep'); |
178 | 178 | $wpdb->update( |
179 | 179 | $tableName, |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | function isSimulatorTypeValid($simulatorType, $validSimulatorTypes) |
195 | 195 | { |
196 | - if (! in_array($simulatorType, $validSimulatorTypes)) { |
|
196 | + if (!in_array($simulatorType, $validSimulatorTypes)) { |
|
197 | 197 | return false; |
198 | 198 | } |
199 | 199 | |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | function areMerchantKeysSet() |
221 | 221 | { |
222 | 222 | $settings = get_option('woocommerce_pagantis_settings'); |
223 | - $publicKey = ! empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : ''; |
|
224 | - $privateKey = ! empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : ''; |
|
223 | + $publicKey = !empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : ''; |
|
224 | + $privateKey = !empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : ''; |
|
225 | 225 | if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) { |
226 | 226 | return false; |
227 | 227 | } |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | function areMerchantKeysSet4x() |
233 | 233 | { |
234 | 234 | $settings = get_option('woocommerce_pagantis_settings'); |
235 | - $publicKey = ! empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : ''; |
|
236 | - $privateKey = ! empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : ''; |
|
235 | + $publicKey = !empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : ''; |
|
236 | + $privateKey = !empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : ''; |
|
237 | 237 | if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) { |
238 | 238 | return false; |
239 | 239 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | function isSimulatorEnabled() |
245 | 245 | { |
246 | 246 | $settings = get_option('woocommerce_pagantis_settings'); |
247 | - if ((! empty($settings['simulator']) && 'yes' === $settings['simulator']) ? true : false) { |
|
247 | + if ((!empty($settings['simulator']) && 'yes'===$settings['simulator']) ? true : false) { |
|
248 | 248 | return true; |
249 | 249 | } |
250 | 250 | |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | { |
256 | 256 | $settings = get_option('woocommerce_pagantis_settings'); |
257 | 257 | |
258 | - return (! empty($settings['enabled']) && 'yes' === $settings['enabled']); |
|
258 | + return (!empty($settings['enabled']) && 'yes'===$settings['enabled']); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | function isPluginEnabled4x() |
262 | 262 | { |
263 | 263 | $settings = get_option('woocommerce_pagantis_settings'); |
264 | - return (! empty($settings['enabled_4x']) && 'yes' === $settings['enabled_4x']); |
|
264 | + return (!empty($settings['enabled_4x']) && 'yes'===$settings['enabled_4x']); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | { |
270 | 270 | $locale = strtolower(strstr(get_locale(), '_', true)); |
271 | 271 | $allowedCountries = maybe_unserialize(getConfigValue('PAGANTIS_ALLOWED_COUNTRIES')); |
272 | - if (! in_array(strtolower($locale), $allowedCountries)) { |
|
272 | + if (!in_array(strtolower($locale), $allowedCountries)) { |
|
273 | 273 | return false; |
274 | 274 | } |
275 | 275 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | global $product; |
287 | 287 | if (method_exists($product, 'get_price')) { |
288 | 288 | $productPrice = $product->get_price(); |
289 | - $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0')); |
|
289 | + $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0')); |
|
290 | 290 | if ($validAmount) { |
291 | 291 | return true; |
292 | 292 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | global $product; |
306 | 306 | if (method_exists($product, 'get_price')) { |
307 | 307 | $productPrice = $product->get_price(); |
308 | - $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0')); |
|
308 | + $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0')); |
|
309 | 309 | if ($validAmount) { |
310 | 310 | return true; |
311 | 311 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | function getExtraConfig() |
325 | 325 | { |
326 | 326 | global $wpdb; |
327 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
327 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
328 | 328 | $response = array(); |
329 | 329 | $dbResult = $wpdb->get_results("select config, value from $tableName", ARRAY_A); |
330 | 330 | foreach ($dbResult as $value) { |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | function getModuleVersion() |
338 | 338 | { |
339 | 339 | |
340 | - $mainFile = plugin_dir_path(PG_WC_MAIN_FILE). '/WC_Pagantis.php'; |
|
340 | + $mainFile = plugin_dir_path(PG_WC_MAIN_FILE).'/WC_Pagantis.php'; |
|
341 | 341 | $version = get_file_data($mainFile, array('Version' => 'Version'), false); |
342 | 342 | return $version['Version']; |
343 | 343 | } |
@@ -349,9 +349,9 @@ discard block |
||
349 | 349 | */ |
350 | 350 | function getNationalId($order) |
351 | 351 | { |
352 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
352 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
353 | 353 | $data = $mdObject->get_data(); |
354 | - if ($data['key'] == 'vat_number') { |
|
354 | + if ($data['key']=='vat_number') { |
|
355 | 355 | return $data['value']; |
356 | 356 | } |
357 | 357 | } |
@@ -366,9 +366,9 @@ discard block |
||
366 | 366 | */ |
367 | 367 | function getTaxId($order) |
368 | 368 | { |
369 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
369 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
370 | 370 | $data = $mdObject->get_data(); |
371 | - if ($data['key'] == 'billing_cfpiva') { |
|
371 | + if ($data['key']=='billing_cfpiva') { |
|
372 | 372 | return $data['value']; |
373 | 373 | } |
374 | 374 | } |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | $metaProduct = get_post_meta($product_id); |
386 | 386 | |
387 | 387 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) |
388 | - && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
388 | + && $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | $promotedAmount = 0; |
397 | 397 | foreach (WC()->cart->get_cart() as $key => $item) { |
398 | 398 | $promotedProduct = isProductPromoted($item['product_id']); |
399 | - if ($promotedProduct == 'true') { |
|
399 | + if ($promotedProduct=='true') { |
|
400 | 400 | $promotedAmount += $item['line_total'] + $item['line_tax']; |
401 | 401 | } |
402 | 402 | } |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | { |
415 | 415 | global $wpdb; |
416 | 416 | checkCartProcessTable(); |
417 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
417 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
418 | 418 | $wpdb->insert($tableName, array('id' => $orderId, 'order_id' => $pagantisOrderId, 'token' => $token), array('%d', '%s', '%s')); |
419 | 419 | } |
420 | 420 | |
@@ -424,14 +424,14 @@ discard block |
||
424 | 424 | function checkCartProcessTable() |
425 | 425 | { |
426 | 426 | global $wpdb; |
427 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
427 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
428 | 428 | |
429 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
429 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
430 | 430 | $charset_collate = $wpdb->get_charset_collate(); |
431 | 431 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), token varchar(32) |
432 | 432 | UNIQUE KEY id (id)) $charset_collate"; |
433 | 433 | |
434 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
434 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
435 | 435 | dbDelta($sql); |
436 | 436 | } |
437 | 437 | } |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
475 | 475 | )); |
476 | 476 | foreach ($customer_orders as $customer_order) { |
477 | - if (trim($sign_up) == '' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) { |
|
477 | + if (trim($sign_up)=='' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) { |
|
478 | 478 | $sign_up = substr($customer_order->post_date, 0, 10); |
479 | 479 | } |
480 | 480 | } |
@@ -485,5 +485,5 @@ discard block |
||
485 | 485 | |
486 | 486 | function isPagePaymentPage() |
487 | 487 | { |
488 | - return (is_checkout() && ! is_order_received_page()) || is_checkout_pay_page(); |
|
488 | + return (is_checkout() && !is_order_received_page()) || is_checkout_pay_page(); |
|
489 | 489 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | |
22 | -require_once(__DIR__ . '/includes/pg-functions.php'); |
|
22 | +require_once(__DIR__.'/includes/pg-functions.php'); |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Required minimums and constants |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | public function __construct() |
82 | 82 | { |
83 | 83 | require_once(plugin_dir_path(__FILE__).'/vendor/autoload.php'); |
84 | - require_once(PG_ABSPATH . '/includes/pg-functions.php'); |
|
84 | + require_once(PG_ABSPATH.'/includes/pg-functions.php'); |
|
85 | 85 | $this->template_path = plugin_dir_path(__FILE__).'/templates/'; |
86 | 86 | |
87 | 87 | $this->pagantisActivation(); |
@@ -98,15 +98,15 @@ discard block |
||
98 | 98 | add_action('init', array($this, 'checkWcPriceSettings'), 10); |
99 | 99 | add_action('woocommerce_after_template_part', array($this, 'pagantisAddSimulatorHtmlDiv'), 10); |
100 | 100 | add_action('woocommerce_single_product_summary', array($this, 'pagantisInitProductSimulator'), 20); |
101 | - add_action('woocommerce_single_variation', array($this,'pagantisAddProductSnippetForVariations'), 30); |
|
101 | + add_action('woocommerce_single_variation', array($this, 'pagantisAddProductSnippetForVariations'), 30); |
|
102 | 102 | add_action('wp_enqueue_scripts', 'add_pagantis_widget_js'); |
103 | 103 | add_action('rest_api_init', array($this, 'pagantisRegisterEndpoint')); //Endpoint |
104 | 104 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
105 | 105 | register_activation_hook(__FILE__, array($this, 'pagantisActivation')); |
106 | 106 | add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl')); |
107 | 107 | add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave')); |
108 | - add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate')); |
|
109 | - add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave')); |
|
108 | + add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate')); |
|
109 | + add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave')); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | { |
133 | 133 | $post_id = $product->get_id(); |
134 | 134 | $pagantis_promoted_value = $_REQUEST['pagantis_promoted']; |
135 | - if ($pagantis_promoted_value === 'on') { |
|
135 | + if ($pagantis_promoted_value==='on') { |
|
136 | 136 | $pagantis_promoted_value = 'yes'; |
137 | 137 | } else { |
138 | 138 | $pagantis_promoted_value = 'no'; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | public function pagantisPromotedVarSave($post_id) |
167 | 167 | { |
168 | 168 | $pagantis_promoted_value = $_POST['pagantis_promoted']; |
169 | - if ($pagantis_promoted_value !== 'yes') { |
|
169 | + if ($pagantis_promoted_value!=='yes') { |
|
170 | 170 | $pagantis_promoted_value = 'no'; |
171 | 171 | } |
172 | 172 | |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function loadPagantisTranslation($mofile, $domain) |
182 | 182 | { |
183 | - if ('pagantis' === $domain) { |
|
184 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
183 | + if ('pagantis'===$domain) { |
|
184 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
185 | 185 | } |
186 | 186 | return $mofile; |
187 | 187 | } |
@@ -193,14 +193,14 @@ discard block |
||
193 | 193 | public function pagantisCheckTables() |
194 | 194 | { |
195 | 195 | // Creating new cart processing table < 8.6.13 |
196 | - if (isPgTableCreated(PG_CART_PROCESS_TABLE)){ |
|
196 | + if (isPgTableCreated(PG_CART_PROCESS_TABLE)) { |
|
197 | 197 | alterCartProcessingTable(); |
198 | - } else{ |
|
198 | + } else { |
|
199 | 199 | createCartProcessingTable(); |
200 | 200 | } |
201 | 201 | |
202 | 202 | // Making sure DB tables are created < v8.6.9 |
203 | - if (!isPgTableCreated(PG_LOGS_TABLE_NAME)){ |
|
203 | + if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) { |
|
204 | 204 | createLogsTable(); |
205 | 205 | } |
206 | 206 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | global $wpdb; |
214 | 214 | |
215 | 215 | $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME; |
216 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
216 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
217 | 217 | $charset_collate = $wpdb->get_charset_collate(); |
218 | 218 | $sql = "CREATE TABLE $tableName ( order_id int NOT NULL, |
219 | 219 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate"; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
225 | 225 | |
226 | 226 | //Check if table exists |
227 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; |
|
227 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; |
|
228 | 228 | if ($tableExists) { |
229 | 229 | $charset_collate = $wpdb->get_charset_collate(); |
230 | 230 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | //Updated value field to adapt to new length < v8.0.1 |
240 | 240 | $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'"; |
241 | 241 | $results = $wpdb->get_results($query, ARRAY_A); |
242 | - if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') { |
|
242 | + if ($results['0']['COLUMN_TYPE']=='varchar(100)') { |
|
243 | 243 | $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)"; |
244 | 244 | $wpdb->query($sql); |
245 | 245 | } |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
250 | 250 | $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A); |
251 | 251 | foreach ($dbCurrentConfig as $item) { |
252 | - if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
252 | + if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
253 | 253 | $css_price_selector = $this->preparePriceSelector($item['value']); |
254 | - if ($item['value'] != $css_price_selector) { |
|
254 | + if ($item['value']!=$css_price_selector) { |
|
255 | 255 | $wpdb->update( |
256 | 256 | $tableName, |
257 | 257 | array('value' => stripslashes($css_price_selector)), |
@@ -260,9 +260,9 @@ discard block |
||
260 | 260 | array('%s') |
261 | 261 | ); |
262 | 262 | } |
263 | - } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
263 | + } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
264 | 264 | $css_quantity_selector = $this->prepareQuantitySelector($item['value']); |
265 | - if ($item['value'] != $css_quantity_selector) { |
|
265 | + if ($item['value']!=$css_quantity_selector) { |
|
266 | 266 | $wpdb->update( |
267 | 267 | $tableName, |
268 | 268 | array('value' => stripslashes($css_quantity_selector)), |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
281 | 281 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
282 | 282 | $results = $wpdb->get_results($query, ARRAY_A); |
283 | - if (count($results) == 0) { |
|
283 | + if (count($results)==0) { |
|
284 | 284 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value' => '.'), array('%s', '%s')); |
285 | 285 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value' => ','), array('%s', '%s')); |
286 | 286 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
290 | 290 | $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'"; |
291 | 291 | $results = $wpdb->get_results($query, ARRAY_A); |
292 | - if (count($results) == 0) { |
|
292 | + if (count($results)==0) { |
|
293 | 293 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value' => '0'), array('%s', '%s')); |
294 | 294 | } |
295 | 295 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
298 | 298 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'"; |
299 | 299 | $results = $wpdb->get_results($query, ARRAY_A); |
300 | - if (count($results) == 0) { |
|
300 | + if (count($results)==0) { |
|
301 | 301 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value' => 'default'), array('%s', '%s')); |
302 | 302 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value' => 'default'), array('%s', '%s')); |
303 | 303 | } |
@@ -307,17 +307,17 @@ discard block |
||
307 | 307 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
308 | 308 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'"; |
309 | 309 | $results = $wpdb->get_results($query, ARRAY_A); |
310 | - if (count($results) == 0) { |
|
310 | + if (count($results)==0) { |
|
311 | 311 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', 'value' => 'sdk.simulator.types.CHECKOUT_PAGE'), array('%s', '%s')); |
312 | 312 | $wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), array('%s'), array('%s')); |
313 | 313 | } |
314 | 314 | |
315 | 315 | //Adapting to variable selector < v8.3.6 |
316 | - $variableSelector="div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
316 | + $variableSelector = "div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
317 | 317 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
318 | 318 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'"; |
319 | 319 | $results = $wpdb->get_results($query, ARRAY_A); |
320 | - if (count($results) == 0) { |
|
320 | + if (count($results)==0) { |
|
321 | 321 | $wpdb->update($tableName, array('value' => $variableSelector), array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION'), array('%s'), array('%s')); |
322 | 322 | } |
323 | 323 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
326 | 326 | $query = "select * from $tableName where config='PAGANTIS_TITLE_4x'"; |
327 | 327 | $results = $wpdb->get_results($query, ARRAY_A); |
328 | - if (count($results) == 0) { |
|
328 | + if (count($results)==0) { |
|
329 | 329 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_TITLE_4x', 'value' => 'Until 4 installments, without fees'), array('%s', '%s')); |
330 | 330 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MIN_AMOUNT_4x', 'value' => 1), array('%s', '%s')); |
331 | 331 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT_4x', 'value' => 800), array('%s', '%s')); |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
339 | 339 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X'"; |
340 | 340 | $results = $wpdb->get_results($query, ARRAY_A); |
341 | - if (count($results) == 0) { |
|
341 | + if (count($results)==0) { |
|
342 | 342 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X', 'value' => 'default'), array('%s', '%s')); |
343 | 343 | } |
344 | 344 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
355 | 355 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
356 | 356 | $results = $wpdb->get_results($query, ARRAY_A); |
357 | - if (count($results) == 0) { |
|
357 | + if (count($results)==0) { |
|
358 | 358 | $wpdb->update($tableName, array('value' => 'a:4:{i:0;s:52:"div.summary *:not(del)>.woocommerce-Price-amount bdi";i:1;s:48:"div.summary *:not(del)>.woocommerce-Price-amount";i:2;s:54:"div.entry-summary *:not(del)>.woocommerce-Price-amount";i:3;s:36:"*:not(del)>.woocommerce-Price-amount";}'), array('config' => 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'), array('%s'), array('%s')); |
359 | 359 | } |
360 | 360 | |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | $isAtcTplPresent = isTemplatePresent( |
448 | 448 | $template_name, |
449 | 449 | array('single-product/add-to-cart/variation-add-to-cart-button.php', |
450 | - 'single-product/add-to-cart/variation.php','single-product/add-to-cart/simple.php') |
|
450 | + 'single-product/add-to-cart/variation.php', 'single-product/add-to-cart/simple.php') |
|
451 | 451 | ); |
452 | 452 | |
453 | 453 | $html = apply_filters('pagantis_simulator_selector_html', '<div class="mainPagantisSimulator"></div><div class="pagantisSimulator"></div>'); |
@@ -459,10 +459,10 @@ discard block |
||
459 | 459 | } |
460 | 460 | |
461 | 461 | $pagantisSimulator4x = 'enabled'; |
462 | - if (!isPluginEnabled4x() || !areMerchantKeysSet4x() || !isCountryShopContextValid() || !isProductAmountValid4x()) { |
|
462 | + if (!isPluginEnabled4x() || !areMerchantKeysSet4x() || !isCountryShopContextValid() || !isProductAmountValid4x()) { |
|
463 | 463 | $pagantisSimulator4x = 'disabled'; |
464 | 464 | } |
465 | - if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') { |
|
465 | + if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') { |
|
466 | 466 | return; |
467 | 467 | } |
468 | 468 | |
@@ -518,12 +518,12 @@ discard block |
||
518 | 518 | $pagantisSimulator4x = 'disabled'; |
519 | 519 | } |
520 | 520 | |
521 | - if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') { |
|
521 | + if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') { |
|
522 | 522 | return; |
523 | 523 | } |
524 | 524 | |
525 | 525 | $totalPrice = $product->get_price(); |
526 | - $formattedInstallments = number_format($totalPrice/4, 2); |
|
526 | + $formattedInstallments = number_format($totalPrice / 4, 2); |
|
527 | 527 | $simulatorMessage = sprintf(__('or 4 installments of %s€, without fees, with ', 'pagantis'), $formattedInstallments); |
528 | 528 | $post_id = $product->get_id(); |
529 | 529 | $logo = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | */ |
567 | 567 | public function addPagantisGateway($methods) |
568 | 568 | { |
569 | - if (! class_exists('WC_Payment_Gateway')) { |
|
569 | + if (!class_exists('WC_Payment_Gateway')) { |
|
570 | 570 | return $methods; |
571 | 571 | } |
572 | 572 | |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | */ |
632 | 632 | public function pagantisRowMeta($links, $file) |
633 | 633 | { |
634 | - if ($file == plugin_basename(__FILE__)) { |
|
634 | + if ($file==plugin_basename(__FILE__)) { |
|
635 | 635 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
636 | 636 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
637 | 637 | __('API documentation', 'pagantis').'</a>'; |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
661 | 661 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
662 | 662 | $results = $wpdb->get_results($query); |
663 | - if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) { |
|
663 | + if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) { |
|
664 | 664 | foreach ($results as $key => $result) { |
665 | 665 | $response[$key]['timestamp'] = $result->createdAt; |
666 | 666 | $response[$key]['log'] = json_decode($result->log); |
@@ -687,13 +687,13 @@ discard block |
||
687 | 687 | |
688 | 688 | $filters = ($data->get_params()); |
689 | 689 | $secretKey = $filters['secret']; |
690 | - $cfg = get_option('woocommerce_pagantis_settings'); |
|
690 | + $cfg = get_option('woocommerce_pagantis_settings'); |
|
691 | 691 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
692 | 692 | $privateKey4x = isset($cfg['pagantis_private_key_4x']) ? $cfg['pagantis_private_key_4x'] : null; |
693 | - if ($privateKey != $secretKey && $privateKey4x != $secretKey) { |
|
693 | + if ($privateKey!=$secretKey && $privateKey4x!=$secretKey) { |
|
694 | 694 | $response['status'] = 401; |
695 | 695 | $response['result'] = 'Unauthorized'; |
696 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
696 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
697 | 697 | if (count($_POST)) { |
698 | 698 | foreach ($_POST as $config => $value) { |
699 | 699 | if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc"; |
755 | 755 | $results = $wpdb->get_results($query); |
756 | 756 | |
757 | - if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) { |
|
757 | + if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) { |
|
758 | 758 | foreach ($results as $result) { |
759 | 759 | $key = $result->ID; |
760 | 760 | $response['message'][$key]['timestamp'] = $result->post_date; |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | */ |
828 | 828 | private function prepareQuantitySelector($css_quantity_selector) |
829 | 829 | { |
830 | - if ($css_quantity_selector == 'default' || $css_quantity_selector == '') { |
|
830 | + if ($css_quantity_selector=='default' || $css_quantity_selector=='') { |
|
831 | 831 | $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
832 | 832 | } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
833 | 833 | $css_quantity_selector = serialize(array($css_quantity_selector)); |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | */ |
844 | 844 | private function preparePriceSelector($css_price_selector) |
845 | 845 | { |
846 | - if ($css_price_selector == 'default' || $css_price_selector == '') { |
|
846 | + if ($css_price_selector=='default' || $css_price_selector=='') { |
|
847 | 847 | $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
848 | 848 | } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
849 | 849 | $css_price_selector = serialize(array($css_price_selector)); |
@@ -861,7 +861,7 @@ discard block |
||
861 | 861 | { |
862 | 862 | $metaProduct = get_post_meta($product_id); |
863 | 863 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && |
864 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
864 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | try { |
69 | 69 | require_once(__ROOT__.'/vendor/autoload.php'); |
70 | 70 | try { |
71 | - if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_GET['origin'] == 'notification') { |
|
71 | + if ($_SERVER['REQUEST_METHOD']=='GET' && $_GET['origin']=='notification') { |
|
72 | 72 | return $this->buildResponse(); |
73 | 73 | } |
74 | 74 | $this->checkConcurrency(); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | private function checkConcurrency() |
118 | 118 | { |
119 | 119 | $this->woocommerceOrderId = $_GET['order-received']; |
120 | - if ($this->woocommerceOrderId == '') { |
|
120 | + if ($this->woocommerceOrderId=='') { |
|
121 | 121 | throw new QuoteNotFoundException(); |
122 | 122 | } |
123 | 123 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | private function getProductType() |
132 | 132 | { |
133 | - if ($_GET['product'] == '') { |
|
133 | + if ($_GET['product']=='') { |
|
134 | 134 | $this->setProduct(WcPagantisGateway::METHOD_ID); |
135 | 135 | } else { |
136 | 136 | $this->setProduct($_GET['product']); |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $queryResult = $wpdb->get_row("select order_id from $tableName where id='".WC()->cart->get_cart_hash()."'"); |
162 | 162 | $this->pagantisOrderId = $queryResult->order_id; |
163 | 163 | |
164 | - if ($this->pagantisOrderId == '') { |
|
164 | + if ($this->pagantisOrderId=='') { |
|
165 | 165 | throw new NoIdentificationException(); |
166 | 166 | } |
167 | 167 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $status = '-'; |
205 | 205 | } |
206 | 206 | |
207 | - if ($status === Order::STATUS_CONFIRMED) { |
|
207 | + if ($status===Order::STATUS_CONFIRMED) { |
|
208 | 208 | return true; |
209 | 209 | } |
210 | 210 | throw new WrongStatusException($status); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | ); |
226 | 226 | |
227 | 227 | if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM |
228 | - $logMessage = "WARNING checkMerchantOrderStatus." . |
|
228 | + $logMessage = "WARNING checkMerchantOrderStatus.". |
|
229 | 229 | " Merchant order id:".$this->woocommerceOrder->get_id(). |
230 | 230 | " Merchant order status:".$this->woocommerceOrder->get_status(). |
231 | 231 | " Pagantis order id:".$this->pagantisOrder->getStatus(). |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | { |
248 | 248 | $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
249 | 249 | $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total())); |
250 | - if ($pagantisAmount != $wcAmount) { |
|
250 | + if ($pagantisAmount!=$wcAmount) { |
|
251 | 251 | throw new AmountMismatchException($pagantisAmount, $wcAmount); |
252 | 252 | } |
253 | 253 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId); |
272 | 272 | } catch (\Exception $e) { |
273 | 273 | $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId); |
274 | - if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) { |
|
274 | + if ($this->pagantisOrder->getStatus()!==Order::STATUS_CONFIRMED) { |
|
275 | 275 | throw new UnknownException($e->getMessage()); |
276 | 276 | } else { |
277 | 277 | $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process'; |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | */ |
293 | 293 | private function checkDbTable() |
294 | 294 | { |
295 | - if (isPgTableCreated(PG_CART_PROCESS_TABLE)){ |
|
295 | + if (isPgTableCreated(PG_CART_PROCESS_TABLE)) { |
|
296 | 296 | alterCartProcessingTable(); |
297 | - } else{ |
|
297 | + } else { |
|
298 | 298 | createCartProcessingTable(); |
299 | 299 | } |
300 | 300 | } |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | global $wpdb; |
308 | 308 | $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
309 | 309 | |
310 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
310 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
311 | 311 | $charset_collate = $wpdb->get_charset_collate(); |
312 | 312 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
313 | 313 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -364,12 +364,12 @@ discard block |
||
364 | 364 | $metadataOrder = $this->pagantisOrder->getMetadata(); |
365 | 365 | $metadataInfo = null; |
366 | 366 | foreach ($metadataOrder as $metadataKey => $metadataValue) { |
367 | - if ($metadataKey == 'promotedProduct') { |
|
368 | - $metadataInfo.= "/Producto promocionado = $metadataValue"; |
|
367 | + if ($metadataKey=='promotedProduct') { |
|
368 | + $metadataInfo .= "/Producto promocionado = $metadataValue"; |
|
369 | 369 | } |
370 | 370 | } |
371 | 371 | |
372 | - if ($metadataInfo != null) { |
|
372 | + if ($metadataInfo!=null) { |
|
373 | 373 | $this->woocommerceOrder->add_order_note($metadataInfo); |
374 | 374 | } |
375 | 375 | |
@@ -438,13 +438,13 @@ discard block |
||
438 | 438 | { |
439 | 439 | global $wpdb; |
440 | 440 | $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME; |
441 | - if ($orderId == null) { |
|
441 | + if ($orderId==null) { |
|
442 | 442 | $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT." SECOND)"; |
443 | 443 | } else { |
444 | 444 | $query = "DELETE FROM $tableName WHERE order_id = $orderId"; |
445 | 445 | } |
446 | 446 | $resultDelete = $wpdb->query($query); |
447 | - if ($resultDelete === false) { |
|
447 | + if ($resultDelete===false) { |
|
448 | 448 | throw new ConcurrencyException(); |
449 | 449 | } |
450 | 450 | } |
@@ -459,8 +459,8 @@ discard block |
||
459 | 459 | global $wpdb; |
460 | 460 | $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME; |
461 | 461 | $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId)); |
462 | - if ($insertResult === false) { |
|
463 | - if ($this->getOrigin() == 'Notify') { |
|
462 | + if ($insertResult===false) { |
|
463 | + if ($this->getOrigin()=='Notify') { |
|
464 | 464 | throw new ConcurrencyException(); |
465 | 465 | } else { |
466 | 466 | $query = sprintf( |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | ); |
472 | 472 | $resultSeconds = $wpdb->get_row($query); |
473 | 473 | $restSeconds = isset($resultSeconds) ? ($resultSeconds->rest) : 0; |
474 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
475 | - sleep($secondsToExpire+1); |
|
474 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
475 | + sleep($secondsToExpire + 1); |
|
476 | 476 | |
477 | 477 | $logMessage = sprintf( |
478 | 478 | "User waiting %s seconds, default seconds %s, bd time to expire %s seconds", |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | { |
497 | 497 | $this->unblockConcurrency($this->woocommerceOrderId); |
498 | 498 | |
499 | - if ($exception == null) { |
|
499 | + if ($exception==null) { |
|
500 | 500 | $jsonResponse = new JsonSuccessResponse(); |
501 | 501 | } else { |
502 | 502 | $jsonResponse = new JsonExceptionResponse(); |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | $jsonResponse->setMerchantOrderId($this->woocommerceOrderId); |
507 | 507 | $jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
508 | 508 | |
509 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
509 | + if ($_SERVER['REQUEST_METHOD']=='POST') { |
|
510 | 510 | $jsonResponse->printResponse(); |
511 | 511 | } else { |
512 | 512 | return $jsonResponse; |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | */ |
539 | 539 | private function isProduct4x() |
540 | 540 | { |
541 | - return ($this->product === Ucfirst(WcPagantis4xGateway::METHOD_ID)); |
|
541 | + return ($this->product===Ucfirst(WcPagantis4xGateway::METHOD_ID)); |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | /** |