@@ -42,23 +42,23 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | if (!is_null($start_time)) { |
| 45 | - $formatted_start_time = date_i18n(get_option('date_format') . ' g:ia', $start_time); |
|
| 45 | + $formatted_start_time = date_i18n(get_option('date_format').' g:ia', $start_time); |
|
| 46 | 46 | $end_time = is_null($end_time) ? current_time('timestamp') : $end_time; |
| 47 | - $formatted_end_time = date_i18n(get_option('date_format') . ' g:ia', $end_time); |
|
| 47 | + $formatted_end_time = date_i18n(get_option('date_format').' g:ia', $end_time); |
|
| 48 | 48 | $elapsed_time = round(abs($end_time - $start_time) / 60, 2); |
| 49 | 49 | |
| 50 | - $log_entry = "\n" . '====Pagantis Version: ' . '====' . "\n"; |
|
| 51 | - $log_entry .= '====Start Log ' . $formatted_start_time . '====' . "\n" . $message . "\n"; |
|
| 52 | - $log_entry .= '====End Log ' . $formatted_end_time . ' (' . $elapsed_time . ')====' . "\n\n"; |
|
| 50 | + $log_entry = "\n".'====Pagantis Version: '.'===='."\n"; |
|
| 51 | + $log_entry .= '====Start Log '.$formatted_start_time.'===='."\n".$message."\n"; |
|
| 52 | + $log_entry .= '====End Log '.$formatted_end_time.' ('.$elapsed_time.')===='."\n\n"; |
|
| 53 | 53 | } else { |
| 54 | - $log_entry = "\n" . '====Pagantis LOG ====' . PHP_EOL; |
|
| 55 | - $log_entry .= date_i18n('M j, Y @ G:i' , strtotime( 'now' ), true ) . PHP_EOL; |
|
| 56 | - $log_entry .= json_encode($message, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ) . PHP_EOL; |
|
| 54 | + $log_entry = "\n".'====Pagantis LOG ===='.PHP_EOL; |
|
| 55 | + $log_entry .= date_i18n('M j, Y @ G:i', strtotime('now'), true).PHP_EOL; |
|
| 56 | + $log_entry .= json_encode($message, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT).PHP_EOL; |
|
| 57 | 57 | $log_entry .= PHP_EOL; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | if (version_compare(WC_VERSION, 3.0, '<')) { |
| 61 | - self::$logger->add(self::PG_LOG_FILENAME, json_encode($log_entry, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ) ); |
|
| 61 | + self::$logger->add(self::PG_LOG_FILENAME, json_encode($log_entry, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); |
|
| 62 | 62 | } else { |
| 63 | 63 | self::$logger->debug($log_entry, array('source' => self::PG_LOG_FILENAME)); |
| 64 | 64 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $out .= "<pre>"; |
| 75 | 75 | } |
| 76 | 76 | foreach ($d as $i => $r) { |
| 77 | - if (!$show_first && $i == 0) { |
|
| 77 | + if (!$show_first && $i==0) { |
|
| 78 | 78 | continue; |
| 79 | 79 | } |
| 80 | 80 | // sometimes there is undefined index 'file' |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $result = ''; |
| 106 | 106 | $length = strlen($str); |
| 107 | 107 | for ($i = 0; $i < $length; $i++) { |
| 108 | - $result .= ($str[$i] === $lowerCase[$i] ? '' : $delimiter) . $lowerCase[$i]; |
|
| 108 | + $result .= ($str[$i]===$lowerCase[$i] ? '' : $delimiter).$lowerCase[$i]; |
|
| 109 | 109 | } |
| 110 | 110 | return $result; |
| 111 | 111 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | public static function toJson($initialResponse) |
| 125 | 125 | { |
| 126 | - if (!is_array($initialResponse)){ |
|
| 126 | + if (!is_array($initialResponse)) { |
|
| 127 | 127 | return; |
| 128 | 128 | } |
| 129 | 129 | $response = self::jsonSerialize($initialResponse); |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | function requireWPPluginFunctions() |
| 4 | 4 | { |
| 5 | - if (! function_exists('is_plugin_active')) { |
|
| 6 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 5 | + if (!function_exists('is_plugin_active')) { |
|
| 6 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
| 7 | 7 | } |
| 8 | 8 | } |
| 9 | 9 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | function getConfigValue($configKey) |
| 22 | 22 | { |
| 23 | 23 | global $wpdb; |
| 24 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 24 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 25 | 25 | $value = $wpdb->get_var($wpdb->prepare("SELECT value FROM $tableName WHERE config= %s ", $configKey)); |
| 26 | 26 | |
| 27 | 27 | return $value; |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | function isPgTableCreated($tableToCheck) |
| 39 | 39 | { |
| 40 | 40 | global $wpdb; |
| 41 | - $tableName = $wpdb->prefix . $tableToCheck; |
|
| 42 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) { |
|
| 41 | + $tableName = $wpdb->prefix.$tableToCheck; |
|
| 42 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")==$tableName) { |
|
| 43 | 43 | return true; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | global $wpdb; |
| 53 | 53 | $charset_collate = $wpdb->get_charset_collate(); |
| 54 | - $LogsTableName = $wpdb->prefix . PG_LOGS_TABLE_NAME; |
|
| 54 | + $LogsTableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
|
| 55 | 55 | $sqlQuery = "CREATE TABLE $LogsTableName ( |
| 56 | 56 | id int NOT NULL AUTO_INCREMENT, |
| 57 | 57 | log text NOT NULL, |
| 58 | 58 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, |
| 59 | 59 | UNIQUE KEY id (id)) |
| 60 | 60 | $charset_collate"; |
| 61 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 61 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 62 | 62 | dbDelta($sqlQuery); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | function insertLogEntry($exception = null, $message = null) |
| 70 | 70 | { |
| 71 | 71 | global $wpdb; |
| 72 | - if (! isPgTableCreated(PG_LOGS_TABLE_NAME)) { |
|
| 72 | + if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) { |
|
| 73 | 73 | createLogsTable(); |
| 74 | 74 | } |
| 75 | 75 | $logEntry = new Pagantis\ModuleUtils\Model\Log\LogEntry(); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | } else { |
| 79 | 79 | $logEntry = $logEntry->info($message); |
| 80 | 80 | } |
| 81 | - $tableName = $wpdb->prefix . PG_LOGS_TABLE_NAME; |
|
| 81 | + $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
|
| 82 | 82 | $wpdb->insert($tableName, array('log' => $logEntry->toJson())); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | { |
| 90 | 90 | $pgDecimalSeparator = getPgSimulatorDecimalSeparatorConfig(); |
| 91 | 91 | $wc_decimal_sep = get_option('woocommerce_price_decimal_sep'); |
| 92 | - if (stripslashes($wc_decimal_sep) == stripslashes($pgDecimalSeparator)) { |
|
| 92 | + if (stripslashes($wc_decimal_sep)==stripslashes($pgDecimalSeparator)) { |
|
| 93 | 93 | return true; |
| 94 | 94 | } else { |
| 95 | 95 | return false; |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | { |
| 105 | 105 | $pgThousandSeparator = getPgSimulatorThousandsSeparator(); |
| 106 | 106 | $wc_price_thousand = get_option('woocommerce_price_thousand_sep'); |
| 107 | - if (stripslashes($wc_price_thousand) == stripslashes($pgThousandSeparator)) { |
|
| 107 | + if (stripslashes($wc_price_thousand)==stripslashes($pgThousandSeparator)) { |
|
| 108 | 108 | return true; |
| 109 | 109 | } else { |
| 110 | 110 | return false; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | function getPgSimulatorThousandsSeparator() |
| 118 | 118 | { |
| 119 | 119 | global $wpdb; |
| 120 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 120 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 121 | 121 | $query = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
| 122 | 122 | $result = $wpdb->get_row($query, ARRAY_A); |
| 123 | 123 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | function getPgSimulatorDecimalSeparatorConfig() |
| 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_DECIMAL_SEPARATOR'"; |
| 135 | 135 | $result = $wpdb->get_row($query, ARRAY_A); |
| 136 | 136 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | if (areThousandsSeparatorEqual()) { |
| 144 | 144 | return; |
| 145 | 145 | } |
| 146 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 146 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 147 | 147 | $thousandSeparator = get_option('woocommerce_price_thousand_sep'); |
| 148 | 148 | $wpdb->update( |
| 149 | 149 | $tableName, |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | if (areDecimalSeparatorEqual()) { |
| 161 | 161 | return; |
| 162 | 162 | } |
| 163 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 163 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 164 | 164 | $decimalSeparator = get_option('woocommerce_price_decimal_sep'); |
| 165 | 165 | $wpdb->update( |
| 166 | 166 | $tableName, |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | function isSimulatorTypeValid($simulatorType, $validSimulatorTypes) |
| 182 | 182 | { |
| 183 | - if (! in_array($simulatorType, $validSimulatorTypes)) { |
|
| 183 | + if (!in_array($simulatorType, $validSimulatorTypes)) { |
|
| 184 | 184 | return false; |
| 185 | 185 | } |
| 186 | 186 | |
@@ -207,8 +207,8 @@ discard block |
||
| 207 | 207 | function areMerchantKeysSet() |
| 208 | 208 | { |
| 209 | 209 | $settings = get_option('woocommerce_pagantis_settings'); |
| 210 | - $publicKey = ! empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : ''; |
|
| 211 | - $privateKey = ! empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : ''; |
|
| 210 | + $publicKey = !empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : ''; |
|
| 211 | + $privateKey = !empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : ''; |
|
| 212 | 212 | if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) { |
| 213 | 213 | return false; |
| 214 | 214 | } |
@@ -219,8 +219,8 @@ discard block |
||
| 219 | 219 | function areMerchantKeysSet4x() |
| 220 | 220 | { |
| 221 | 221 | $settings = get_option('woocommerce_pagantis_settings'); |
| 222 | - $publicKey = ! empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : ''; |
|
| 223 | - $privateKey = ! empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : ''; |
|
| 222 | + $publicKey = !empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : ''; |
|
| 223 | + $privateKey = !empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : ''; |
|
| 224 | 224 | if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) { |
| 225 | 225 | return false; |
| 226 | 226 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | function isSimulatorEnabled() |
| 232 | 232 | { |
| 233 | 233 | $settings = get_option('woocommerce_pagantis_settings'); |
| 234 | - if ((! empty($settings['simulator']) && 'yes' === $settings['simulator']) ? true : false) { |
|
| 234 | + if ((!empty($settings['simulator']) && 'yes'===$settings['simulator']) ? true : false) { |
|
| 235 | 235 | return true; |
| 236 | 236 | } |
| 237 | 237 | |
@@ -242,14 +242,14 @@ discard block |
||
| 242 | 242 | { |
| 243 | 243 | $settings = get_option('woocommerce_pagantis_settings'); |
| 244 | 244 | |
| 245 | - return (! empty($settings['enabled']) && 'yes' === $settings['enabled']); |
|
| 245 | + return (!empty($settings['enabled']) && 'yes'===$settings['enabled']); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | function isPluginEnabled4x() |
| 249 | 249 | { |
| 250 | 250 | $settings = get_option('woocommerce_pagantis_settings'); |
| 251 | 251 | |
| 252 | - return (! empty($settings['enabled_4x']) && 'yes' === $settings['enabled_4x']); |
|
| 252 | + return (!empty($settings['enabled_4x']) && 'yes'===$settings['enabled_4x']); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | { |
| 258 | 258 | $locale = strtolower(strstr(get_locale(), '_', true)); |
| 259 | 259 | $allowedCountries = maybe_unserialize(getConfigValue('PAGANTIS_ALLOWED_COUNTRIES')); |
| 260 | - if (! in_array(strtolower($locale), $allowedCountries)) { |
|
| 260 | + if (!in_array(strtolower($locale), $allowedCountries)) { |
|
| 261 | 261 | return false; |
| 262 | 262 | } |
| 263 | 263 | |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | global $product; |
| 275 | 275 | if (method_exists($product, 'get_price')) { |
| 276 | 276 | $productPrice = $product->get_price(); |
| 277 | - $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0')); |
|
| 277 | + $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0')); |
|
| 278 | 278 | if ($validAmount) { |
| 279 | 279 | return true; |
| 280 | 280 | } |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | global $product; |
| 294 | 294 | if (method_exists($product, 'get_price')) { |
| 295 | 295 | $productPrice = $product->get_price(); |
| 296 | - $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0')); |
|
| 296 | + $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0')); |
|
| 297 | 297 | if ($validAmount) { |
| 298 | 298 | return true; |
| 299 | 299 | } |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | function getExtraConfig() |
| 314 | 314 | { |
| 315 | 315 | global $wpdb; |
| 316 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 316 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 317 | 317 | $response = array(); |
| 318 | 318 | $dbResult = $wpdb->get_results("select config, value from $tableName", ARRAY_A); |
| 319 | 319 | foreach ($dbResult as $value) { |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | |
| 326 | 326 | function getModuleVersion() |
| 327 | 327 | { |
| 328 | - $mainFile = plugin_dir_path(PG_WC_MAIN_FILE) . '/WC_Pagantis.php'; |
|
| 328 | + $mainFile = plugin_dir_path(PG_WC_MAIN_FILE).'/WC_Pagantis.php'; |
|
| 329 | 329 | $version = get_file_data($mainFile, array('Version' => 'Version'), false); |
| 330 | 330 | |
| 331 | 331 | return $version['Version']; |
@@ -338,9 +338,9 @@ discard block |
||
| 338 | 338 | */ |
| 339 | 339 | function getNationalId($order) |
| 340 | 340 | { |
| 341 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
| 341 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
| 342 | 342 | $data = $mdObject->get_data(); |
| 343 | - if ($data['key'] == 'vat_number') { |
|
| 343 | + if ($data['key']=='vat_number') { |
|
| 344 | 344 | return $data['value']; |
| 345 | 345 | } |
| 346 | 346 | } |
@@ -355,9 +355,9 @@ discard block |
||
| 355 | 355 | */ |
| 356 | 356 | function getTaxId($order) |
| 357 | 357 | { |
| 358 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
| 358 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
| 359 | 359 | $data = $mdObject->get_data(); |
| 360 | - if ($data['key'] == 'billing_cfpiva') { |
|
| 360 | + if ($data['key']=='billing_cfpiva') { |
|
| 361 | 361 | return $data['value']; |
| 362 | 362 | } |
| 363 | 363 | } |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | $metaProduct = get_post_meta($product_id); |
| 375 | 375 | |
| 376 | 376 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) |
| 377 | - && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
| 377 | + && $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | /** |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | $promotedAmount = 0; |
| 386 | 386 | foreach (WC()->cart->get_cart() as $key => $item) { |
| 387 | 387 | $promotedProduct = isProductPromoted($item['product_id']); |
| 388 | - if ($promotedProduct == 'true') { |
|
| 388 | + if ($promotedProduct=='true') { |
|
| 389 | 389 | $promotedAmount += $item['line_total'] + $item['line_tax']; |
| 390 | 390 | } |
| 391 | 391 | } |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | function addOrderToProcessingQueue($cartHash, $pagantisOrderId, $wcOrderID, $paymentProcessingToken) |
| 404 | 404 | { |
| 405 | 405 | global $wpdb; |
| 406 | - $tableName = $wpdb->prefix . PG_OLD_CART_PROCESS_TABLE; |
|
| 406 | + $tableName = $wpdb->prefix.PG_OLD_CART_PROCESS_TABLE; |
|
| 407 | 407 | $wpdb->insert($tableName, array( |
| 408 | 408 | 'id' => $cartHash, |
| 409 | 409 | 'order_id' => $pagantisOrderId, |
@@ -415,8 +415,8 @@ discard block |
||
| 415 | 415 | function alterCartProcessingTable() |
| 416 | 416 | { |
| 417 | 417 | global $wpdb; |
| 418 | - $tableName = $wpdb->prefix . PG_OLD_CART_PROCESS_TABLE; |
|
| 419 | - if (! $wpdb->get_var("SHOW COLUMNS FROM `{$tableName}` LIKE 'token'")) { |
|
| 418 | + $tableName = $wpdb->prefix.PG_OLD_CART_PROCESS_TABLE; |
|
| 419 | + if (!$wpdb->get_var("SHOW COLUMNS FROM `{$tableName}` LIKE 'token'")) { |
|
| 420 | 420 | $wpdb->query("ALTER TABLE $tableName ADD COLUMN `token` VARCHAR(32) NOT NULL AFTER `wc_order_id`"); |
| 421 | 421 | $wpdb->query("ALTER TABLE $tableName DROP PRIMARY KEY, ADD PRIMARY KEY(`id`, `token`)"); |
| 422 | 422 | } |
@@ -429,9 +429,9 @@ discard block |
||
| 429 | 429 | function createOrderProcessingTable() |
| 430 | 430 | { |
| 431 | 431 | global $wpdb; |
| 432 | - $tableName = $wpdb->prefix . PG_ORDER_PROCESS_TABLE; |
|
| 432 | + $tableName = $wpdb->prefix.PG_ORDER_PROCESS_TABLE; |
|
| 433 | 433 | |
| 434 | - if (! isPgTableCreated(PG_OLD_CART_PROCESS_TABLE)) { |
|
| 434 | + if (!isPgTableCreated(PG_OLD_CART_PROCESS_TABLE)) { |
|
| 435 | 435 | $charset_collate = $wpdb->get_charset_collate(); |
| 436 | 436 | $sql = "CREATE TABLE IF NOT EXISTS $tableName |
| 437 | 437 | (id VARCHAR(60) NOT NULL, |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | token VARCHAR(32) NOT NULL, |
| 441 | 441 | PRIMARY KEY(id) ) $charset_collate"; |
| 442 | 442 | |
| 443 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 443 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 444 | 444 | dbDelta($sql); |
| 445 | 445 | } |
| 446 | 446 | } |
@@ -455,9 +455,9 @@ discard block |
||
| 455 | 455 | { |
| 456 | 456 | global $wpdb; |
| 457 | 457 | if (isPgTableCreated(PG_OLD_CART_PROCESS_TABLE)) { |
| 458 | - return $wpdb->prefix . PG_OLD_CART_PROCESS_TABLE; |
|
| 458 | + return $wpdb->prefix.PG_OLD_CART_PROCESS_TABLE; |
|
| 459 | 459 | } |
| 460 | - return $wpdb->prefix . PG_ORDER_PROCESS_TABLE; |
|
| 460 | + return $wpdb->prefix.PG_ORDER_PROCESS_TABLE; |
|
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | /** |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
| 498 | 498 | )); |
| 499 | 499 | foreach ($customer_orders as $customer_order) { |
| 500 | - if (trim($sign_up) == '' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) { |
|
| 500 | + if (trim($sign_up)=='' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) { |
|
| 501 | 501 | $sign_up = substr($customer_order->post_date, 0, 10); |
| 502 | 502 | } |
| 503 | 503 | } |
@@ -251,11 +251,11 @@ |
||
| 251 | 251 | |
| 252 | 252 | if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM |
| 253 | 253 | $logMessage = "WARNING checkMerchantOrderStatus." . |
| 254 | - " Merchant order id:".$this->woocommerceOrder->get_id(). |
|
| 255 | - " Merchant order status:".$this->woocommerceOrder->get_status(). |
|
| 256 | - " Pagantis order id:".$this->pagantisOrder->getStatus(). |
|
| 257 | - " Pagantis order status:".$this->pagantisOrder->getId(). |
|
| 258 | - " Pagantis urlToken: ".$this->getVerificationToken(); |
|
| 254 | + " Merchant order id:".$this->woocommerceOrder->get_id(). |
|
| 255 | + " Merchant order status:".$this->woocommerceOrder->get_status(). |
|
| 256 | + " Pagantis order id:".$this->pagantisOrder->getStatus(). |
|
| 257 | + " Pagantis order status:".$this->pagantisOrder->getId(). |
|
| 258 | + " Pagantis urlToken: ".$this->getVerificationToken(); |
|
| 259 | 259 | |
| 260 | 260 | $this->insertLog(null, $logMessage); |
| 261 | 261 | $this->woocommerceOrder->add_order_note($logMessage); |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | public function processNotification() |
| 66 | 66 | { |
| 67 | 67 | try { |
| 68 | - require_once(__ROOT__ . '/vendor/autoload.php'); |
|
| 68 | + require_once(__ROOT__.'/vendor/autoload.php'); |
|
| 69 | 69 | try { |
| 70 | - if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_GET['origin'] == 'notification') { |
|
| 70 | + if ($_SERVER['REQUEST_METHOD']=='GET' && $_GET['origin']=='notification') { |
|
| 71 | 71 | return $this->buildResponse(); |
| 72 | 72 | } |
| 73 | 73 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | private function setPaymentProductType() |
| 129 | 129 | { |
| 130 | - if ($_GET['product'] == '') { |
|
| 130 | + if ($_GET['product']=='') { |
|
| 131 | 131 | $this->setProduct(WcPagantisGateway::METHOD_ID); |
| 132 | 132 | } else { |
| 133 | 133 | $this->setProduct($_GET['product']); |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | { |
| 155 | 155 | global $wpdb; |
| 156 | 156 | $this->checkDbTable(); |
| 157 | - $tableName =$wpdb->prefix . PG_OLD_CART_PROCESS_TABLE; |
|
| 158 | - $tokenCount=$wpdb->get_var($wpdb->prepare("SELECT COUNT(wc_order_id) |
|
| 157 | + $tableName = $wpdb->prefix.PG_OLD_CART_PROCESS_TABLE; |
|
| 158 | + $tokenCount = $wpdb->get_var($wpdb->prepare("SELECT COUNT(wc_order_id) |
|
| 159 | 159 | FROM $tableName |
| 160 | 160 | WHERE token = %s", |
| 161 | 161 | $this->getVerificationToken())); |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | FROM $tableName |
| 165 | 165 | WHERE wc_order_id = %s", |
| 166 | 166 | $this->getWoocommerceOrderId())); |
| 167 | - if (!($tokenCount == 1 && $orderIDCount == 1)) { |
|
| 167 | + if (!($tokenCount==1 && $orderIDCount==1)) { |
|
| 168 | 168 | throw new MerchantOrderNotFoundException(); |
| 169 | 169 | } |
| 170 | 170 | } |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | $status = '-'; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - if ($status === Order::STATUS_CONFIRMED) { |
|
| 232 | + if ($status===Order::STATUS_CONFIRMED) { |
|
| 233 | 233 | return true; |
| 234 | 234 | } |
| 235 | 235 | throw new WrongStatusException($status); |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | private function checkMerchantOrderStatus() |
| 243 | 243 | { |
| 244 | 244 | //Order status reference => https://docs.woocommerce.com/document/managing-orders/ |
| 245 | - $validStatus=array('on-hold', 'pending', 'failed', 'processing', 'completed'); |
|
| 245 | + $validStatus = array('on-hold', 'pending', 'failed', 'processing', 'completed'); |
|
| 246 | 246 | $isValidStatus = apply_filters( |
| 247 | 247 | 'woocommerce_valid_order_statuses_for_payment_complete', |
| 248 | 248 | $validStatus, |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | ); |
| 251 | 251 | |
| 252 | 252 | if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM |
| 253 | - $logMessage = "WARNING checkMerchantOrderStatus." . |
|
| 253 | + $logMessage = "WARNING checkMerchantOrderStatus.". |
|
| 254 | 254 | " Merchant order id:".$this->woocommerceOrder->get_id(). |
| 255 | 255 | " Merchant order status:".$this->woocommerceOrder->get_status(). |
| 256 | 256 | " Pagantis order id:".$this->pagantisOrder->getStatus(). |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | { |
| 274 | 274 | $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
| 275 | 275 | $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total())); |
| 276 | - if ($pagantisAmount != $wcAmount) { |
|
| 276 | + if ($pagantisAmount!=$wcAmount) { |
|
| 277 | 277 | throw new AmountMismatchException($pagantisAmount, $wcAmount); |
| 278 | 278 | } |
| 279 | 279 | } |
@@ -297,10 +297,10 @@ discard block |
||
| 297 | 297 | $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId); |
| 298 | 298 | } catch (\Exception $e) { |
| 299 | 299 | $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId); |
| 300 | - if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) { |
|
| 300 | + if ($this->pagantisOrder->getStatus()!==Order::STATUS_CONFIRMED) { |
|
| 301 | 301 | throw new UnknownException($e->getMessage()); |
| 302 | 302 | } else { |
| 303 | - $logMessage = 'Concurrency issue: Order_id ' . $this->pagantisOrderId . ' was confirmed by other process'; |
|
| 303 | + $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process'; |
|
| 304 | 304 | $this->insertLog(null, $logMessage); |
| 305 | 305 | } |
| 306 | 306 | } |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | global $wpdb; |
| 336 | 336 | $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
| 337 | 337 | |
| 338 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
| 338 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
| 339 | 339 | $charset_collate = $wpdb->get_charset_collate(); |
| 340 | 340 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
| 341 | 341 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -392,12 +392,12 @@ discard block |
||
| 392 | 392 | $metadataOrder = $this->pagantisOrder->getMetadata(); |
| 393 | 393 | $metadataInfo = null; |
| 394 | 394 | foreach ($metadataOrder as $metadataKey => $metadataValue) { |
| 395 | - if ($metadataKey == 'promotedProduct') { |
|
| 395 | + if ($metadataKey=='promotedProduct') { |
|
| 396 | 396 | $metadataInfo .= "/Producto promocionado = $metadataValue"; |
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - if ($metadataInfo != null) { |
|
| 400 | + if ($metadataInfo!=null) { |
|
| 401 | 401 | $this->woocommerceOrder->add_order_note($metadataInfo); |
| 402 | 402 | } |
| 403 | 403 | |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | global $wpdb; |
| 421 | 421 | |
| 422 | 422 | $this->checkDbTable(); |
| 423 | - $tableName = $wpdb->prefix . PG_OLD_CART_PROCESS_TABLE; |
|
| 423 | + $tableName = $wpdb->prefix.PG_OLD_CART_PROCESS_TABLE; |
|
| 424 | 424 | |
| 425 | 425 | $wpdb->update( |
| 426 | 426 | $tableName, |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | $logEntry = $logEntry->info($message); |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - $tableName = $wpdb->prefix . PG_LOGS_TABLE_NAME; |
|
| 455 | + $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
|
| 456 | 456 | $wpdb->insert($tableName, array('log' => $logEntry->toJson())); |
| 457 | 457 | } |
| 458 | 458 | |
@@ -464,14 +464,14 @@ discard block |
||
| 464 | 464 | private function unblockConcurrency($orderId = null) |
| 465 | 465 | { |
| 466 | 466 | global $wpdb; |
| 467 | - $tableName = $wpdb->prefix . PG_CONCURRENCY_TABLE_NAME; |
|
| 468 | - if ($orderId == null) { |
|
| 469 | - $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL " . self::CONCURRENCY_TIMEOUT . " SECOND)"; |
|
| 467 | + $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME; |
|
| 468 | + if ($orderId==null) { |
|
| 469 | + $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT." SECOND)"; |
|
| 470 | 470 | } else { |
| 471 | 471 | $query = "DELETE FROM $tableName WHERE order_id = $orderId"; |
| 472 | 472 | } |
| 473 | 473 | $resultDelete = $wpdb->query($query); |
| 474 | - if ($resultDelete === false) { |
|
| 474 | + if ($resultDelete===false) { |
|
| 475 | 475 | throw new ConcurrencyException(); |
| 476 | 476 | } |
| 477 | 477 | } |
@@ -486,15 +486,15 @@ discard block |
||
| 486 | 486 | global $wpdb; |
| 487 | 487 | $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME; |
| 488 | 488 | $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId)); |
| 489 | - if ($insertResult === false) { |
|
| 490 | - if ($this->getOrigin() == 'Notify') { |
|
| 489 | + if ($insertResult===false) { |
|
| 490 | + if ($this->getOrigin()=='Notify') { |
|
| 491 | 491 | throw new ConcurrencyException(); |
| 492 | 492 | } else { |
| 493 | - $query = |
|
| 493 | + $query = |
|
| 494 | 494 | sprintf("SELECT TIMESTAMPDIFF(SECOND,NOW()-INTERVAL %s SECOND, createdAt) as rest FROM %s WHERE %s", |
| 495 | 495 | self::CONCURRENCY_TIMEOUT, $tableName, "order_id=$orderId"); |
| 496 | - $resultSeconds=$wpdb->get_row($query); |
|
| 497 | - $restSeconds =isset($resultSeconds) ? ($resultSeconds->rest) : 0; |
|
| 496 | + $resultSeconds = $wpdb->get_row($query); |
|
| 497 | + $restSeconds = isset($resultSeconds) ? ($resultSeconds->rest) : 0; |
|
| 498 | 498 | $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
| 499 | 499 | sleep($secondsToExpire + 1); |
| 500 | 500 | |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | { |
| 518 | 518 | $this->unblockConcurrency($this->woocommerceOrderId); |
| 519 | 519 | |
| 520 | - if ($exception == null) { |
|
| 520 | + if ($exception==null) { |
|
| 521 | 521 | $jsonResponse = new JsonSuccessResponse(); |
| 522 | 522 | } else { |
| 523 | 523 | $jsonResponse = new JsonExceptionResponse(); |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | $jsonResponse->setMerchantOrderId($this->woocommerceOrderId); |
| 527 | 527 | $jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
| 528 | 528 | |
| 529 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 529 | + if ($_SERVER['REQUEST_METHOD']=='POST') { |
|
| 530 | 530 | $jsonResponse->printResponse(); |
| 531 | 531 | } else { |
| 532 | 532 | return $jsonResponse; |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | */ |
| 559 | 559 | private function isProduct4x() |
| 560 | 560 | { |
| 561 | - return ($this->product === Ucfirst(WcPagantis4xGateway::METHOD_ID)); |
|
| 561 | + return ($this->product===Ucfirst(WcPagantis4xGateway::METHOD_ID)); |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | /** |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | public function setWoocommerceOrderId() |
| 592 | 592 | { |
| 593 | 593 | $this->woocommerceOrderId = $_GET['order-received']; |
| 594 | - if ($this->woocommerceOrderId == '') { |
|
| 594 | + if ($this->woocommerceOrderId=='') { |
|
| 595 | 595 | throw new QuoteNotFoundException(); |
| 596 | 596 | } |
| 597 | 597 | } |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | $this->paymentProcessingToken = strtoupper(md5(uniqid(rand(), true))); |
| 64 | 64 | |
| 65 | 65 | //Useful vars |
| 66 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/'; |
|
| 66 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/'; |
|
| 67 | 67 | $this->allowed_currencies = getAllowedCurrencies(); |
| 68 | - $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Pagantis.php'; |
|
| 68 | + $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)).'/WC_Pagantis.php'; |
|
| 69 | 69 | $this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false); |
| 70 | 70 | $this->language = strstr(get_locale(), '_', true); |
| 71 | 71 | if ($this->language=='') { |
@@ -74,25 +74,25 @@ discard block |
||
| 74 | 74 | $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
| 75 | 75 | |
| 76 | 76 | //Panel form fields |
| 77 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options |
|
| 77 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options |
|
| 78 | 78 | $this->init_settings(); |
| 79 | 79 | |
| 80 | 80 | $this->extraConfig = getExtraConfig(); |
| 81 | 81 | $this->title = __($this->extraConfig['PAGANTIS_TITLE'], 'pagantis'); |
| 82 | 82 | $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis."; |
| 83 | 83 | |
| 84 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl(); |
|
| 85 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl(); |
|
| 84 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
| 85 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
| 86 | 86 | foreach ($this->settings as $setting_key => $setting_value) { |
| 87 | 87 | $this->$setting_key = $setting_value; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | //Hooks |
| 91 | - add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options |
|
| 92 | - add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields |
|
| 93 | - add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
| 94 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
| 95 | - add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3); |
|
| 91 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options |
|
| 92 | + add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields |
|
| 93 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
| 94 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
| 95 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3); |
|
| 96 | 96 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function loadPagantisTranslation($mofile, $domain) |
| 106 | 106 | { |
| 107 | - if ('pagantis' === $domain) { |
|
| 108 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 107 | + if ('pagantis'===$domain) { |
|
| 108 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 109 | 109 | } |
| 110 | 110 | return $mofile; |
| 111 | 111 | } |
@@ -139,24 +139,24 @@ discard block |
||
| 139 | 139 | public function pagantisCheckFields() |
| 140 | 140 | { |
| 141 | 141 | $error_string = ''; |
| 142 | - if ($this->settings['enabled'] !== 'yes') { |
|
| 142 | + if ($this->settings['enabled']!=='yes') { |
|
| 143 | 143 | return; |
| 144 | 144 | } elseif (!version_compare(phpversion(), '5.3.0', '>=')) { |
| 145 | - $error_string = __(' is not compatible with your php and/or curl version', 'pagantis'); |
|
| 145 | + $error_string = __(' is not compatible with your php and/or curl version', 'pagantis'); |
|
| 146 | 146 | $this->settings['enabled'] = 'no'; |
| 147 | - } elseif (($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="") && (empty($this->settings['pagantis_public_key_4x']) || empty($this->settings['pagantis_private_key_4x']))) { |
|
| 147 | + } elseif (($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="") && (empty($this->settings['pagantis_public_key_4x']) || empty($this->settings['pagantis_private_key_4x']))) { |
|
| 148 | 148 | $error_string = __(' is not configured correctly, the fields Public Key and Secret Key are mandatory for use this plugin', 'pagantis'); |
| 149 | 149 | $this->settings['enabled'] = 'no'; |
| 150 | 150 | } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) { |
| 151 | - $error_string = __(' only can be used in Euros', 'pagantis'); |
|
| 151 | + $error_string = __(' only can be used in Euros', 'pagantis'); |
|
| 152 | 152 | $this->settings['enabled'] = 'no'; |
| 153 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']<'2' |
|
| 154 | - || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']>'12') { |
|
| 153 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] < '2' |
|
| 154 | + || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] > '12') { |
|
| 155 | 155 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis'); |
| 156 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']<'2' |
|
| 157 | - || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']>'12') { |
|
| 156 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] < '2' |
|
| 157 | + || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] > '12') { |
|
| 158 | 158 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis'); |
| 159 | - } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']<0) { |
|
| 159 | + } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] < 0) { |
|
| 160 | 160 | $error_string = __(' can not have a minimum amount less than 0', 'pagantis'); |
| 161 | 161 | } |
| 162 | 162 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | $shippingAddress = $order->get_address('shipping'); |
| 191 | 191 | $billingAddress = $order->get_address('billing'); |
| 192 | - if ($shippingAddress['address_1'] == '') { |
|
| 192 | + if ($shippingAddress['address_1']=='') { |
|
| 193 | 193 | $shippingAddress = $billingAddress; |
| 194 | 194 | } |
| 195 | 195 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | ->setNationalId($national_id) |
| 217 | 217 | ->setTaxId($tax_id) |
| 218 | 218 | ; |
| 219 | - $orderBillingAddress = new Address(); |
|
| 219 | + $orderBillingAddress = new Address(); |
|
| 220 | 220 | $orderBillingAddress |
| 221 | 221 | ->setZipCode($billingAddress['postcode']) |
| 222 | 222 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
@@ -289,12 +289,12 @@ discard block |
||
| 289 | 289 | $details->addProduct($product); |
| 290 | 290 | |
| 291 | 291 | $promotedProduct = isProductPromoted($item->get_product_id()); |
| 292 | - if ($promotedProduct == 'true') { |
|
| 293 | - $promotedAmount+=$product->getAmount(); |
|
| 294 | - $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
|
| 295 | - ' - Price: ' . $item->get_total() . |
|
| 296 | - ' - Qty: ' . $product->getQuantity() . |
|
| 297 | - ' - Item ID: ' . $item['id_product']; |
|
| 292 | + if ($promotedProduct=='true') { |
|
| 293 | + $promotedAmount += $product->getAmount(); |
|
| 294 | + $promotedMessage = 'Promoted Item: '.$wcProduct->get_name(). |
|
| 295 | + ' - Price: '.$item->get_total(). |
|
| 296 | + ' - Qty: '.$product->getQuantity(). |
|
| 297 | + ' - Item ID: '.$item['id_product']; |
|
| 298 | 298 | $promotedMessage = substr($promotedMessage, 0, 999); |
| 299 | 299 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
| 300 | 300 | } |
@@ -341,9 +341,7 @@ discard block |
||
| 341 | 341 | |
| 342 | 342 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
| 343 | 343 | $purchaseCountry = |
| 344 | - in_array(strtolower($this->language), $allowedCountries) ? $this->language : |
|
| 345 | - in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : |
|
| 346 | - in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null; |
|
| 344 | + 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; |
|
| 347 | 345 | |
| 348 | 346 | $orderConfiguration = new Configuration(); |
| 349 | 347 | $orderConfiguration |
@@ -367,13 +365,13 @@ discard block |
||
| 367 | 365 | $pagantisOrder = $orderClient->createOrder($orderApiClient); |
| 368 | 366 | if ($pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) { |
| 369 | 367 | $url = $pagantisOrder->getActionUrls()->getForm(); |
| 370 | - addOrderToProcessingQueue(WC()->cart->get_cart_hash(), $pagantisOrder->getId(),$order->get_id() , $this->paymentProcessingToken); |
|
| 371 | - $logEntry = "Cart Added to Processing Queu" . |
|
| 368 | + addOrderToProcessingQueue(WC()->cart->get_cart_hash(), $pagantisOrder->getId(), $order->get_id(), $this->paymentProcessingToken); |
|
| 369 | + $logEntry = "Cart Added to Processing Queu". |
|
| 372 | 370 | " cart hash: ".WC()->cart->get_cart_hash(). |
| 373 | 371 | " Merchant order id: ".$order->get_id(). |
| 374 | 372 | " Pagantis order id: ".$pagantisOrder->getId(). |
| 375 | 373 | " Pagantis urlToken: ".$this->paymentProcessingToken; |
| 376 | - insertLogEntry(null,$logEntry); |
|
| 374 | + insertLogEntry(null, $logEntry); |
|
| 377 | 375 | |
| 378 | 376 | } else { |
| 379 | 377 | throw new OrderNotFoundException(); |
@@ -392,7 +390,7 @@ discard block |
||
| 392 | 390 | wc_get_template('iframe.php', $template_fields, '', $this->template_path); |
| 393 | 391 | } |
| 394 | 392 | } catch (\Exception $exception) { |
| 395 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); |
|
| 393 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); |
|
| 396 | 394 | insertLogEntry($exception); |
| 397 | 395 | $checkout_url = get_permalink(wc_get_page_id('checkout')); |
| 398 | 396 | wp_redirect($checkout_url); |
@@ -407,7 +405,7 @@ discard block |
||
| 407 | 405 | public function pagantisNotification() |
| 408 | 406 | { |
| 409 | 407 | try { |
| 410 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
| 408 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
| 411 | 409 | |
| 412 | 410 | include_once('notifyController.php'); |
| 413 | 411 | $notify = new WcPagantisNotify(); |
@@ -446,10 +444,10 @@ discard block |
||
| 446 | 444 | */ |
| 447 | 445 | public function pagantisCompleteStatus($status, $order_id, $order) |
| 448 | 446 | { |
| 449 | - if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) { |
|
| 450 | - if ($order->get_status() == 'failed') { |
|
| 447 | + if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) { |
|
| 448 | + if ($order->get_status()=='failed') { |
|
| 451 | 449 | $status = 'processing'; |
| 452 | - } elseif ($order->get_status() == 'pending' && $status=='completed') { |
|
| 450 | + } elseif ($order->get_status()=='pending' && $status=='completed') { |
|
| 453 | 451 | $status = 'processing'; |
| 454 | 452 | } |
| 455 | 453 | } |
@@ -475,8 +473,8 @@ discard block |
||
| 475 | 473 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
| 476 | 474 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
| 477 | 475 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
| 478 | - $totalPrice = (int)$this->get_order_total(); |
|
| 479 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
| 476 | + $totalPrice = (int) $this->get_order_total(); |
|
| 477 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
| 480 | 478 | if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' && |
| 481 | 479 | $validAmount && $allowedCountry) { |
| 482 | 480 | return true; |
@@ -509,8 +507,8 @@ discard block |
||
| 509 | 507 | |
| 510 | 508 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
| 511 | 509 | if (strpos($redirectUrl, 'order-pay=')===false) { |
| 512 | - $redirectUrl.="&order-pay=".$order_id; |
|
| 513 | - $redirectUrl.="&token=".$this->paymentProcessingToken; |
|
| 510 | + $redirectUrl .= "&order-pay=".$order_id; |
|
| 511 | + $redirectUrl .= "&token=".$this->paymentProcessingToken; |
|
| 514 | 512 | } |
| 515 | 513 | |
| 516 | 514 | return array( |
@@ -518,7 +516,7 @@ discard block |
||
| 518 | 516 | 'redirect' => $redirectUrl |
| 519 | 517 | ); |
| 520 | 518 | } catch (Exception $e) { |
| 521 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); |
|
| 519 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); |
|
| 522 | 520 | return array(); |
| 523 | 521 | } |
| 524 | 522 | } |
@@ -587,7 +585,7 @@ discard block |
||
| 587 | 585 | private function generateUrl($url) |
| 588 | 586 | { |
| 589 | 587 | $parsed_url = parse_url($url); |
| 590 | - if ($parsed_url !== false) { |
|
| 588 | + if ($parsed_url!==false) { |
|
| 591 | 589 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
| 592 | 590 | parse_str($parsed_url['query'], $arrayParams); |
| 593 | 591 | foreach ($arrayParams as $keyParam => $valueParam) { |
@@ -635,11 +633,10 @@ discard block |
||
| 635 | 633 | private function getKeysUrl($order, $url) |
| 636 | 634 | { |
| 637 | 635 | $defaultFields = (get_class($order)=='WC_Order') ? |
| 638 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key(), 'token' => $this->paymentProcessingToken) : |
|
| 639 | - array(); |
|
| 636 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key(), 'token' => $this->paymentProcessingToken) : array(); |
|
| 640 | 637 | |
| 641 | 638 | $parsedUrl = parse_url($url); |
| 642 | - if ($parsedUrl !== false) { |
|
| 639 | + if ($parsedUrl!==false) { |
|
| 643 | 640 | //Replace parameters from url |
| 644 | 641 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
| 645 | 642 | |
@@ -684,7 +681,7 @@ discard block |
||
| 684 | 681 | foreach ($arrayParams as $keyParam => $valueParam) { |
| 685 | 682 | preg_match('#\{{.*?}\}#', $valueParam, $match); |
| 686 | 683 | if (count($match)) { |
| 687 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]); |
|
| 684 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]); |
|
| 688 | 685 | $arrayParams[$keyParam] = $defaultFields[$key]; |
| 689 | 686 | } |
| 690 | 687 | } |
@@ -699,13 +696,13 @@ discard block |
||
| 699 | 696 | */ |
| 700 | 697 | private function unparseUrl($parsed_url) |
| 701 | 698 | { |
| 702 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
| 699 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
| 703 | 700 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
| 704 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
| 705 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
| 706 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
| 701 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
| 702 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
| 703 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
| 707 | 704 | $path = $parsed_url['path']; |
| 708 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
| 705 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
| 709 | 706 | } |
| 710 | 707 | |
| 711 | 708 | } |
@@ -259,9 +259,9 @@ discard block |
||
| 259 | 259 | if ($promotedProduct == 'true') { |
| 260 | 260 | $promotedAmount+=$product->getAmount(); |
| 261 | 261 | $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
| 262 | - ' - Price: ' . $item->get_total() . |
|
| 263 | - ' - Qty: ' . $product->getQuantity() . |
|
| 264 | - ' - Item ID: ' . $item['id_product']; |
|
| 262 | + ' - Price: ' . $item->get_total() . |
|
| 263 | + ' - Qty: ' . $product->getQuantity() . |
|
| 264 | + ' - Item ID: ' . $item['id_product']; |
|
| 265 | 265 | $promotedMessage = substr($promotedMessage, 0, 999); |
| 266 | 266 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
| 267 | 267 | } |
@@ -277,10 +277,10 @@ discard block |
||
| 277 | 277 | $orderConfigurationUrls = new Urls(); |
| 278 | 278 | $cancelUrl = $this->getKoUrl($order); |
| 279 | 279 | $callback_arg = array('wc-api'=>'wcpagantisgateway', |
| 280 | - 'key'=>$order->get_order_key(), |
|
| 281 | - 'order-received'=>$order->get_id(), |
|
| 282 | - 'origin' => '', |
|
| 283 | - 'token' => $this->paymentProcessingToken4x |
|
| 280 | + 'key'=>$order->get_order_key(), |
|
| 281 | + 'order-received'=>$order->get_id(), |
|
| 282 | + 'origin' => '', |
|
| 283 | + 'token' => $this->paymentProcessingToken4x |
|
| 284 | 284 | ); |
| 285 | 285 | |
| 286 | 286 | $callback_arg_user = $callback_arg; |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | //Useful vars |
| 71 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/'; |
|
| 71 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/'; |
|
| 72 | 72 | $this->allowed_currencies = getAllowedCurrencies(); |
| 73 | 73 | $this->language = strstr(get_locale(), '_', true); |
| 74 | 74 | if ($this->language=='') { |
@@ -77,24 +77,24 @@ discard block |
||
| 77 | 77 | $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
| 78 | 78 | |
| 79 | 79 | //Panel form fields |
| 80 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options |
|
| 80 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options |
|
| 81 | 81 | $this->init_settings(); |
| 82 | 82 | |
| 83 | 83 | $this->extraConfig = getExtraConfig(); |
| 84 | 84 | $this->title = __($this->extraConfig['PAGANTIS_TITLE_4x'], 'pagantis'); |
| 85 | 85 | $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis."; |
| 86 | 86 | |
| 87 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl(); |
|
| 88 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl(); |
|
| 87 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
| 88 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
| 89 | 89 | foreach ($this->settings as $setting_key => $setting_value) { |
| 90 | 90 | $this->$setting_key = $setting_value; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | //Hooks |
| 94 | - add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options |
|
| 95 | - add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
| 96 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
| 97 | - add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3); |
|
| 94 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options |
|
| 95 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
| 96 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
| 97 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3); |
|
| 98 | 98 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
| 99 | 99 | } |
| 100 | 100 | |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function loadPagantisTranslation($mofile, $domain) |
| 108 | 108 | { |
| 109 | - if ('pagantis' === $domain) { |
|
| 110 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 109 | + if ('pagantis'===$domain) { |
|
| 110 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 111 | 111 | } |
| 112 | 112 | return $mofile; |
| 113 | 113 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | $shippingAddress = $order->get_address('shipping'); |
| 158 | 158 | $billingAddress = $order->get_address('billing'); |
| 159 | - if ($shippingAddress['address_1'] == '') { |
|
| 159 | + if ($shippingAddress['address_1']=='') { |
|
| 160 | 160 | $shippingAddress = $billingAddress; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | ->setNationalId($national_id) |
| 184 | 184 | ->setTaxId($tax_id) |
| 185 | 185 | ; |
| 186 | - $orderBillingAddress = new Address(); |
|
| 186 | + $orderBillingAddress = new Address(); |
|
| 187 | 187 | $orderBillingAddress |
| 188 | 188 | ->setZipCode($billingAddress['postcode']) |
| 189 | 189 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
@@ -256,12 +256,12 @@ discard block |
||
| 256 | 256 | $details->addProduct($product); |
| 257 | 257 | |
| 258 | 258 | $promotedProduct = isProductPromoted($item->get_product_id()); |
| 259 | - if ($promotedProduct == 'true') { |
|
| 260 | - $promotedAmount+=$product->getAmount(); |
|
| 261 | - $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
|
| 262 | - ' - Price: ' . $item->get_total() . |
|
| 263 | - ' - Qty: ' . $product->getQuantity() . |
|
| 264 | - ' - Item ID: ' . $item['id_product']; |
|
| 259 | + if ($promotedProduct=='true') { |
|
| 260 | + $promotedAmount += $product->getAmount(); |
|
| 261 | + $promotedMessage = 'Promoted Item: '.$wcProduct->get_name(). |
|
| 262 | + ' - Price: '.$item->get_total(). |
|
| 263 | + ' - Qty: '.$product->getQuantity(). |
|
| 264 | + ' - Item ID: '.$item['id_product']; |
|
| 265 | 265 | $promotedMessage = substr($promotedMessage, 0, 999); |
| 266 | 266 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
| 267 | 267 | } |
@@ -308,9 +308,7 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
| 310 | 310 | $purchaseCountry = |
| 311 | - in_array(strtolower($this->language), $allowedCountries) ? $this->language : |
|
| 312 | - in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : |
|
| 313 | - in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null; |
|
| 311 | + 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; |
|
| 314 | 312 | |
| 315 | 313 | $orderConfiguration = new Configuration(); |
| 316 | 314 | $orderConfiguration |
@@ -335,7 +333,7 @@ discard block |
||
| 335 | 333 | $pagantisOrder = $orderClient->createOrder($orderApiClient); |
| 336 | 334 | if ($pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) { |
| 337 | 335 | $url = $pagantisOrder->getActionUrls()->getForm(); |
| 338 | - addOrderToProcessingQueue(WC()->cart->get_cart_hash(), $pagantisOrder->getId(),$order->get_id() , $this->paymentProcessingToken4x); |
|
| 336 | + addOrderToProcessingQueue(WC()->cart->get_cart_hash(), $pagantisOrder->getId(), $order->get_id(), $this->paymentProcessingToken4x); |
|
| 339 | 337 | |
| 340 | 338 | } else { |
| 341 | 339 | throw new OrderNotFoundException(); |
@@ -355,7 +353,7 @@ discard block |
||
| 355 | 353 | wc_get_template('iframe.php', $template_fields, '', $this->template_path); |
| 356 | 354 | } |
| 357 | 355 | } catch (\Exception $exception) { |
| 358 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); |
|
| 356 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); |
|
| 359 | 357 | insertLogEntry($exception); |
| 360 | 358 | $checkout_url = get_permalink(wc_get_page_id('checkout')); |
| 361 | 359 | wp_redirect($checkout_url); |
@@ -371,7 +369,7 @@ discard block |
||
| 371 | 369 | public function pagantisNotification() |
| 372 | 370 | { |
| 373 | 371 | try { |
| 374 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
| 372 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
| 375 | 373 | |
| 376 | 374 | include_once('notifyController.php'); |
| 377 | 375 | $notify = new WcPagantisNotify(); |
@@ -410,10 +408,10 @@ discard block |
||
| 410 | 408 | */ |
| 411 | 409 | public function pagantisCompleteStatus($status, $order_id, $order) |
| 412 | 410 | { |
| 413 | - if ($order->get_payment_method() == WcPagantis4xGateway::METHOD_ID) { |
|
| 414 | - if ($order->get_status() == 'failed') { |
|
| 411 | + if ($order->get_payment_method()==WcPagantis4xGateway::METHOD_ID) { |
|
| 412 | + if ($order->get_status()=='failed') { |
|
| 415 | 413 | $status = 'processing'; |
| 416 | - } elseif ($order->get_status() == 'pending' && $status=='completed') { |
|
| 414 | + } elseif ($order->get_status()=='pending' && $status=='completed') { |
|
| 417 | 415 | $status = 'processing'; |
| 418 | 416 | } |
| 419 | 417 | } |
@@ -442,8 +440,8 @@ discard block |
||
| 442 | 440 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
| 443 | 441 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT_4x']; |
| 444 | 442 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT_4x']; |
| 445 | - $totalPrice = (int)$this->get_order_total(); |
|
| 446 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
| 443 | + $totalPrice = (int) $this->get_order_total(); |
|
| 444 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
| 447 | 445 | if ($cfg['enabled_4x']==='yes' && $cfg['pagantis_public_key_4x']!='' && $cfg['pagantis_private_key_4x']!='' && |
| 448 | 446 | $validAmount && $allowedCountry) { |
| 449 | 447 | return true; |
@@ -478,8 +476,8 @@ discard block |
||
| 478 | 476 | |
| 479 | 477 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
| 480 | 478 | if (strpos($redirectUrl, 'order-pay=')===false) { |
| 481 | - $redirectUrl.="&order-pay=".$order_id; |
|
| 482 | - $redirectUrl.="&token=".$this->paymentProcessingToken4x; |
|
| 479 | + $redirectUrl .= "&order-pay=".$order_id; |
|
| 480 | + $redirectUrl .= "&token=".$this->paymentProcessingToken4x; |
|
| 483 | 481 | } |
| 484 | 482 | |
| 485 | 483 | return array( |
@@ -487,7 +485,7 @@ discard block |
||
| 487 | 485 | 'redirect' => $redirectUrl |
| 488 | 486 | ); |
| 489 | 487 | } catch (Exception $e) { |
| 490 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); |
|
| 488 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); |
|
| 491 | 489 | return array(); |
| 492 | 490 | } |
| 493 | 491 | } |
@@ -558,7 +556,7 @@ discard block |
||
| 558 | 556 | private function generateUrl($url) |
| 559 | 557 | { |
| 560 | 558 | $parsed_url = parse_url($url); |
| 561 | - if ($parsed_url !== false) { |
|
| 559 | + if ($parsed_url!==false) { |
|
| 562 | 560 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
| 563 | 561 | parse_str($parsed_url['query'], $arrayParams); |
| 564 | 562 | foreach ($arrayParams as $keyParam => $valueParam) { |
@@ -606,11 +604,10 @@ discard block |
||
| 606 | 604 | private function getKeysUrl($order, $url) |
| 607 | 605 | { |
| 608 | 606 | $defaultFields = (get_class($order)=='WC_Order') ? |
| 609 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key(), 'token' => $this->paymentProcessingToken4x) : |
|
| 610 | - array(); |
|
| 607 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key(), 'token' => $this->paymentProcessingToken4x) : array(); |
|
| 611 | 608 | |
| 612 | 609 | $parsedUrl = parse_url($url); |
| 613 | - if ($parsedUrl !== false) { |
|
| 610 | + if ($parsedUrl!==false) { |
|
| 614 | 611 | //Replace parameters from url |
| 615 | 612 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
| 616 | 613 | |
@@ -655,7 +652,7 @@ discard block |
||
| 655 | 652 | foreach ($arrayParams as $keyParam => $valueParam) { |
| 656 | 653 | preg_match('#\{{.*?}\}#', $valueParam, $match); |
| 657 | 654 | if (count($match)) { |
| 658 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]); |
|
| 655 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]); |
|
| 659 | 656 | $arrayParams[$keyParam] = $defaultFields[$key]; |
| 660 | 657 | } |
| 661 | 658 | } |
@@ -670,12 +667,12 @@ discard block |
||
| 670 | 667 | */ |
| 671 | 668 | private function unparseUrl($parsed_url) |
| 672 | 669 | { |
| 673 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
| 670 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
| 674 | 671 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
| 675 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
| 676 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
| 677 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
| 672 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
| 673 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
| 674 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
| 678 | 675 | $path = $parsed_url['path']; |
| 679 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
| 676 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
| 680 | 677 | } |
| 681 | 678 | } |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | // Creating new cart processing table < 8.6.13 |
| 258 | 258 | if (isPgTableCreated(PG_OLD_CART_PROCESS_TABLE)){ |
| 259 | - alterCartProcessingTable(); |
|
| 259 | + alterCartProcessingTable(); |
|
| 260 | 260 | } else{ |
| 261 | 261 | createOrderProcessingTable(); |
| 262 | 262 | } |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | if ($file == plugin_basename(__FILE__)) { |
| 625 | 625 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
| 626 | 626 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
| 627 | - __('API documentation', 'pagantis').'</a>'; |
|
| 627 | + __('API documentation', 'pagantis').'</a>'; |
|
| 628 | 628 | $links[] = '<a href="'.WcPagantis::SUPPORT_EML.'">'.__('Support', 'pagantis').'</a>'; |
| 629 | 629 | |
| 630 | 630 | return $links; |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | |
| 20 | -require_once(__DIR__ . '/includes/pg-functions.php'); |
|
| 20 | +require_once(__DIR__.'/includes/pg-functions.php'); |
|
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * Required minimums and constants |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | public function __construct() |
| 81 | 81 | { |
| 82 | 82 | require_once(plugin_dir_path(__FILE__).'/vendor/autoload.php'); |
| 83 | - require_once(PG_ABSPATH . '/includes/pg-functions.php'); |
|
| 83 | + require_once(PG_ABSPATH.'/includes/pg-functions.php'); |
|
| 84 | 84 | $this->template_path = plugin_dir_path(__FILE__).'/templates/'; |
| 85 | 85 | |
| 86 | 86 | $this->pagantisActivation(); |
@@ -96,15 +96,15 @@ discard block |
||
| 96 | 96 | add_action('init', array($this, 'checkWcPriceSettings'), 10); |
| 97 | 97 | add_action('woocommerce_after_template_part', array($this, 'pagantisAddSimulatorHtmlDiv'), 10); |
| 98 | 98 | add_action('woocommerce_single_product_summary', array($this, 'pagantisInitProductSimulator'), 20); |
| 99 | - add_action('woocommerce_single_variation', array($this,'pagantisAddProductSnippetForVariations'), 30); |
|
| 99 | + add_action('woocommerce_single_variation', array($this, 'pagantisAddProductSnippetForVariations'), 30); |
|
| 100 | 100 | add_action('wp_enqueue_scripts', 'add_pagantis_widget_js'); |
| 101 | 101 | add_action('rest_api_init', array($this, 'pagantisRegisterEndpoint')); //Endpoint |
| 102 | 102 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
| 103 | 103 | register_activation_hook(__FILE__, array($this, 'pagantisActivation')); |
| 104 | 104 | add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl')); |
| 105 | 105 | add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave')); |
| 106 | - add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate')); |
|
| 107 | - add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave')); |
|
| 106 | + add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate')); |
|
| 107 | + add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave')); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | { |
| 131 | 131 | $post_id = $product->get_id(); |
| 132 | 132 | $pagantis_promoted_value = $_REQUEST['pagantis_promoted']; |
| 133 | - if ($pagantis_promoted_value === 'on') { |
|
| 133 | + if ($pagantis_promoted_value==='on') { |
|
| 134 | 134 | $pagantis_promoted_value = 'yes'; |
| 135 | 135 | } else { |
| 136 | 136 | $pagantis_promoted_value = 'no'; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | public function pagantisPromotedVarSave($post_id) |
| 165 | 165 | { |
| 166 | 166 | $pagantis_promoted_value = $_POST['pagantis_promoted']; |
| 167 | - if ($pagantis_promoted_value !== 'yes') { |
|
| 167 | + if ($pagantis_promoted_value!=='yes') { |
|
| 168 | 168 | $pagantis_promoted_value = 'no'; |
| 169 | 169 | } |
| 170 | 170 | |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function loadPagantisTranslation($mofile, $domain) |
| 180 | 180 | { |
| 181 | - if ('pagantis' === $domain) { |
|
| 182 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 181 | + if ('pagantis'===$domain) { |
|
| 182 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 183 | 183 | } |
| 184 | 184 | return $mofile; |
| 185 | 185 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | global $wpdb; |
| 193 | 193 | |
| 194 | 194 | $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME; |
| 195 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
| 195 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
| 196 | 196 | $charset_collate = $wpdb->get_charset_collate(); |
| 197 | 197 | $sql = "CREATE TABLE $tableName ( order_id int NOT NULL, |
| 198 | 198 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate"; |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 204 | 204 | |
| 205 | 205 | //Check if table exists |
| 206 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; |
|
| 206 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; |
|
| 207 | 207 | if ($tableExists) { |
| 208 | 208 | $charset_collate = $wpdb->get_charset_collate(); |
| 209 | 209 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | //Updated value field to adapt to new length < v8.0.1 |
| 219 | 219 | $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'"; |
| 220 | 220 | $results = $wpdb->get_results($query, ARRAY_A); |
| 221 | - if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') { |
|
| 221 | + if ($results['0']['COLUMN_TYPE']=='varchar(100)') { |
|
| 222 | 222 | $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)"; |
| 223 | 223 | $wpdb->query($sql); |
| 224 | 224 | } |
@@ -228,9 +228,9 @@ discard block |
||
| 228 | 228 | or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
| 229 | 229 | $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A); |
| 230 | 230 | foreach ($dbCurrentConfig as $item) { |
| 231 | - if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
| 231 | + if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
| 232 | 232 | $css_price_selector = $this->preparePriceSelector($item['value']); |
| 233 | - if ($item['value'] != $css_price_selector) { |
|
| 233 | + if ($item['value']!=$css_price_selector) { |
|
| 234 | 234 | $wpdb->update( |
| 235 | 235 | $tableName, |
| 236 | 236 | array('value' => stripslashes($css_price_selector)), |
@@ -239,9 +239,9 @@ discard block |
||
| 239 | 239 | array('%s') |
| 240 | 240 | ); |
| 241 | 241 | } |
| 242 | - } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
| 242 | + } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
| 243 | 243 | $css_quantity_selector = $this->prepareQuantitySelector($item['value']); |
| 244 | - if ($item['value'] != $css_quantity_selector) { |
|
| 244 | + if ($item['value']!=$css_quantity_selector) { |
|
| 245 | 245 | $wpdb->update( |
| 246 | 246 | $tableName, |
| 247 | 247 | array('value' => stripslashes($css_quantity_selector)), |
@@ -255,14 +255,14 @@ discard block |
||
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | // Creating new cart processing table < 8.6.13 |
| 258 | - if (isPgTableCreated(PG_OLD_CART_PROCESS_TABLE)){ |
|
| 258 | + if (isPgTableCreated(PG_OLD_CART_PROCESS_TABLE)) { |
|
| 259 | 259 | alterCartProcessingTable(); |
| 260 | - } else{ |
|
| 260 | + } else { |
|
| 261 | 261 | createOrderProcessingTable(); |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | // Making sure DB tables are created < v8.6.9 |
| 265 | - if (!isPgTableCreated(PG_LOGS_TABLE_NAME)){ |
|
| 265 | + if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) { |
|
| 266 | 266 | createLogsTable(); |
| 267 | 267 | } |
| 268 | 268 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 271 | 271 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
| 272 | 272 | $results = $wpdb->get_results($query, ARRAY_A); |
| 273 | - if (count($results) == 0) { |
|
| 273 | + if (count($results)==0) { |
|
| 274 | 274 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value' => '.'), array('%s', '%s')); |
| 275 | 275 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value' => ','), array('%s', '%s')); |
| 276 | 276 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 280 | 280 | $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'"; |
| 281 | 281 | $results = $wpdb->get_results($query, ARRAY_A); |
| 282 | - if (count($results) == 0) { |
|
| 282 | + if (count($results)==0) { |
|
| 283 | 283 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value' => '0'), array('%s', '%s')); |
| 284 | 284 | } |
| 285 | 285 | |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 288 | 288 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'"; |
| 289 | 289 | $results = $wpdb->get_results($query, ARRAY_A); |
| 290 | - if (count($results) == 0) { |
|
| 290 | + if (count($results)==0) { |
|
| 291 | 291 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value' => 'default'), array('%s', '%s')); |
| 292 | 292 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value' => 'default'), array('%s', '%s')); |
| 293 | 293 | } |
@@ -297,17 +297,17 @@ discard block |
||
| 297 | 297 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 298 | 298 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'"; |
| 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_TYPE_CHECKOUT', 'value' => 'sdk.simulator.types.CHECKOUT_PAGE'), array('%s', '%s')); |
| 302 | 302 | $wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), array('%s'), array('%s')); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | //Adapting to variable selector < v8.3.6 |
| 306 | - $variableSelector="div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
| 306 | + $variableSelector = "div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
| 307 | 307 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 308 | 308 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'"; |
| 309 | 309 | $results = $wpdb->get_results($query, ARRAY_A); |
| 310 | - if (count($results) == 0) { |
|
| 310 | + if (count($results)==0) { |
|
| 311 | 311 | $wpdb->update($tableName, array('value' => $variableSelector), array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION'), array('%s'), array('%s')); |
| 312 | 312 | } |
| 313 | 313 | |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 316 | 316 | $query = "select * from $tableName where config='PAGANTIS_TITLE_4x'"; |
| 317 | 317 | $results = $wpdb->get_results($query, ARRAY_A); |
| 318 | - if (count($results) == 0) { |
|
| 318 | + if (count($results)==0) { |
|
| 319 | 319 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_TITLE_4x', 'value' => 'Until 4 installments, without fees'), array('%s', '%s')); |
| 320 | 320 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MIN_AMOUNT_4x', 'value' => 1), array('%s', '%s')); |
| 321 | 321 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT_4x', 'value' => 800), array('%s', '%s')); |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 329 | 329 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X'"; |
| 330 | 330 | $results = $wpdb->get_results($query, ARRAY_A); |
| 331 | - if (count($results) == 0) { |
|
| 331 | + if (count($results)==0) { |
|
| 332 | 332 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X', 'value' => 'default'), array('%s', '%s')); |
| 333 | 333 | } |
| 334 | 334 | |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 345 | 345 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
| 346 | 346 | $results = $wpdb->get_results($query, ARRAY_A); |
| 347 | - if (count($results) == 0) { |
|
| 347 | + if (count($results)==0) { |
|
| 348 | 348 | $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')); |
| 349 | 349 | } |
| 350 | 350 | |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | $isAtcTplPresent = isTemplatePresent( |
| 438 | 438 | $template_name, |
| 439 | 439 | array('single-product/add-to-cart/variation-add-to-cart-button.php', |
| 440 | - 'single-product/add-to-cart/variation.php','single-product/add-to-cart/simple.php') |
|
| 440 | + 'single-product/add-to-cart/variation.php', 'single-product/add-to-cart/simple.php') |
|
| 441 | 441 | ); |
| 442 | 442 | |
| 443 | 443 | $html = apply_filters('pagantis_simulator_selector_html', '<div class="mainPagantisSimulator"></div><div class="pagantisSimulator"></div>'); |
@@ -449,10 +449,10 @@ discard block |
||
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | $pagantisSimulator4x = 'enabled'; |
| 452 | - if (!isPluginEnabled4x() || !areMerchantKeysSet4x() || !isCountryShopContextValid() || !isProductAmountValid4x()) { |
|
| 452 | + if (!isPluginEnabled4x() || !areMerchantKeysSet4x() || !isCountryShopContextValid() || !isProductAmountValid4x()) { |
|
| 453 | 453 | $pagantisSimulator4x = 'disabled'; |
| 454 | 454 | } |
| 455 | - if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') { |
|
| 455 | + if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') { |
|
| 456 | 456 | return; |
| 457 | 457 | } |
| 458 | 458 | |
@@ -508,12 +508,12 @@ discard block |
||
| 508 | 508 | $pagantisSimulator4x = 'disabled'; |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') { |
|
| 511 | + if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') { |
|
| 512 | 512 | return; |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | $totalPrice = $product->get_price(); |
| 516 | - $formattedInstallments = number_format($totalPrice/4, 2); |
|
| 516 | + $formattedInstallments = number_format($totalPrice / 4, 2); |
|
| 517 | 517 | $simulatorMessage = sprintf(__('or 4 installments of %s€, without fees, with ', 'pagantis'), $formattedInstallments); |
| 518 | 518 | $post_id = $product->get_id(); |
| 519 | 519 | $logo = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | */ |
| 557 | 557 | public function addPagantisGateway($methods) |
| 558 | 558 | { |
| 559 | - if (! class_exists('WC_Payment_Gateway')) { |
|
| 559 | + if (!class_exists('WC_Payment_Gateway')) { |
|
| 560 | 560 | return $methods; |
| 561 | 561 | } |
| 562 | 562 | |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | */ |
| 622 | 622 | public function pagantisRowMeta($links, $file) |
| 623 | 623 | { |
| 624 | - if ($file == plugin_basename(__FILE__)) { |
|
| 624 | + if ($file==plugin_basename(__FILE__)) { |
|
| 625 | 625 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
| 626 | 626 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
| 627 | 627 | __('API documentation', 'pagantis').'</a>'; |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
| 651 | 651 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
| 652 | 652 | $results = $wpdb->get_results($query); |
| 653 | - if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) { |
|
| 653 | + if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) { |
|
| 654 | 654 | foreach ($results as $key => $result) { |
| 655 | 655 | $response[$key]['timestamp'] = $result->createdAt; |
| 656 | 656 | $response[$key]['log'] = json_decode($result->log); |
@@ -677,13 +677,13 @@ discard block |
||
| 677 | 677 | |
| 678 | 678 | $filters = ($data->get_params()); |
| 679 | 679 | $secretKey = $filters['secret']; |
| 680 | - $cfg = get_option('woocommerce_pagantis_settings'); |
|
| 680 | + $cfg = get_option('woocommerce_pagantis_settings'); |
|
| 681 | 681 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
| 682 | 682 | $privateKey4x = isset($cfg['pagantis_private_key_4x']) ? $cfg['pagantis_private_key_4x'] : null; |
| 683 | - if ($privateKey != $secretKey && $privateKey4x != $secretKey) { |
|
| 683 | + if ($privateKey!=$secretKey && $privateKey4x!=$secretKey) { |
|
| 684 | 684 | $response['status'] = 401; |
| 685 | 685 | $response['result'] = 'Unauthorized'; |
| 686 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 686 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
| 687 | 687 | if (count($_POST)) { |
| 688 | 688 | foreach ($_POST as $config => $value) { |
| 689 | 689 | if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc"; |
| 745 | 745 | $results = $wpdb->get_results($query); |
| 746 | 746 | |
| 747 | - if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) { |
|
| 747 | + if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) { |
|
| 748 | 748 | foreach ($results as $result) { |
| 749 | 749 | $key = $result->ID; |
| 750 | 750 | $response['message'][$key]['timestamp'] = $result->post_date; |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | */ |
| 818 | 818 | private function prepareQuantitySelector($css_quantity_selector) |
| 819 | 819 | { |
| 820 | - if ($css_quantity_selector == 'default' || $css_quantity_selector == '') { |
|
| 820 | + if ($css_quantity_selector=='default' || $css_quantity_selector=='') { |
|
| 821 | 821 | $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
| 822 | 822 | } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
| 823 | 823 | $css_quantity_selector = serialize(array($css_quantity_selector)); |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | */ |
| 834 | 834 | private function preparePriceSelector($css_price_selector) |
| 835 | 835 | { |
| 836 | - if ($css_price_selector == 'default' || $css_price_selector == '') { |
|
| 836 | + if ($css_price_selector=='default' || $css_price_selector=='') { |
|
| 837 | 837 | $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
| 838 | 838 | } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
| 839 | 839 | $css_price_selector = serialize(array($css_price_selector)); |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | { |
| 852 | 852 | $metaProduct = get_post_meta($product_id); |
| 853 | 853 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && |
| 854 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
| 854 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | /** |