@@ -37,7 +37,7 @@ |
||
| 37 | 37 | selector: '.pagantisSimulator', |
| 38 | 38 | totalAmount: '<?php echo $total; ?>', |
| 39 | 39 | totalPromotedAmount: '<?php echo $promoted_amount; ?>', |
| 40 | - skin : <?php echo $pagantisSimulatorSkin;?>, |
|
| 40 | + skin : <?php echo $pagantisSimulatorSkin; ?>, |
|
| 41 | 41 | locale: locale, |
| 42 | 42 | country: country |
| 43 | 43 | }); |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <script> |
| 2 | 2 | function findPriceSelector() |
| 3 | 3 | { |
| 4 | - var priceSelectors = <?php echo json_encode($priceSelector);?>; |
|
| 4 | + var priceSelectors = <?php echo json_encode($priceSelector); ?>; |
|
| 5 | 5 | return priceSelectors.find(function(candidateSelector) { |
| 6 | 6 | var priceDOM = document.querySelector(candidateSelector); |
| 7 | 7 | return (priceDOM != null ); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | function findPositionSelector() |
| 13 | 13 | { |
| 14 | - var positionSelector = '<?php echo $positionSelector;?>'; |
|
| 14 | + var positionSelector = '<?php echo $positionSelector; ?>'; |
|
| 15 | 15 | if (positionSelector === 'default') { |
| 16 | 16 | positionSelector = '.pagantisSimulator'; |
| 17 | 17 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | function findQuantitySelector() |
| 23 | 23 | { |
| 24 | - var quantitySelectors = <?php echo json_encode($quantitySelector);?>; |
|
| 24 | + var quantitySelectors = <?php echo json_encode($quantitySelector); ?>; |
|
| 25 | 25 | return quantitySelectors.find(function(candidateSelector) { |
| 26 | 26 | var priceDOM = document.querySelector(candidateSelector); |
| 27 | 27 | return (priceDOM != null ); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | function findDestinationSim() |
| 50 | 50 | { |
| 51 | - var destinationSim = '<?php echo $finalDestination;?>'; |
|
| 51 | + var destinationSim = '<?php echo $finalDestination; ?>'; |
|
| 52 | 52 | if (destinationSim === 'default' || destinationSim == '') { |
| 53 | 53 | destinationSim = 'woocommerce-product-details__short-description'; |
| 54 | 54 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | var positionSelector = findPositionSelector(); |
| 94 | 94 | var priceSelector = findPriceSelector(); |
| 95 | - var promotedProduct = '<?php echo $promoted;?>'; |
|
| 95 | + var promotedProduct = '<?php echo $promoted; ?>'; |
|
| 96 | 96 | var quantitySelector = findQuantitySelector(); |
| 97 | 97 | |
| 98 | 98 | simulator_options = { |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | country: country, |
| 105 | 105 | itemAmountSelector: priceSelector, |
| 106 | 106 | amountParserConfig : { |
| 107 | - thousandSeparator: '<?php echo $thousandSeparator;?>', |
|
| 108 | - decimalSeparator: '<?php echo $decimalSeparator;?>' |
|
| 107 | + thousandSeparator: '<?php echo $thousandSeparator; ?>', |
|
| 108 | + decimalSeparator: '<?php echo $decimalSeparator; ?>' |
|
| 109 | 109 | }, |
| 110 | - numInstalments : '<?php echo $pagantisQuotesStart;?>', |
|
| 111 | - skin : <?php echo $pagantisSimulatorSkin;?>, |
|
| 112 | - position: <?php echo $pagantisSimulatorPosition;?> |
|
| 110 | + numInstalments : '<?php echo $pagantisQuotesStart; ?>', |
|
| 111 | + skin : <?php echo $pagantisSimulatorSkin; ?>, |
|
| 112 | + position: <?php echo $pagantisSimulatorPosition; ?> |
|
| 113 | 113 | }; |
| 114 | 114 | |
| 115 | 115 | window.pgSDK = sdk; |
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | { |
| 139 | 139 | if (window.WCSimulatorId != '') |
| 140 | 140 | { |
| 141 | - var updateSelector = '<?php echo $variationSelector;?>'; |
|
| 141 | + var updateSelector = '<?php echo $variationSelector; ?>'; |
|
| 142 | 142 | |
| 143 | - var productType = '<?php echo $productType;?>'; |
|
| 143 | + var productType = '<?php echo $productType; ?>'; |
|
| 144 | 144 | |
| 145 | 145 | if (updateSelector == 'default' || updateSelector === '' || productType!=='variable') |
| 146 | 146 | { |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | </style> |
| 175 | 175 | <?php |
| 176 | -if ($promoted == 'true') { |
|
| 176 | +if ($promoted=='true') { |
|
| 177 | 177 | echo $promotedMessage; |
| 178 | 178 | } |
| 179 | 179 | ?> |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | //namespace Gateways; |
| 11 | 11 | |
| 12 | 12 | |
| 13 | -if ( ! defined('ABSPATH')) { |
|
| 13 | +if (!defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -65,19 +65,19 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public function __construct() |
| 67 | 67 | { |
| 68 | - require_once(plugin_dir_path(__FILE__) . '/vendor/autoload.php'); |
|
| 68 | + require_once(plugin_dir_path(__FILE__).'/vendor/autoload.php'); |
|
| 69 | 69 | |
| 70 | - $this->template_path = plugin_dir_path(__FILE__) . '/templates/'; |
|
| 70 | + $this->template_path = plugin_dir_path(__FILE__).'/templates/'; |
|
| 71 | 71 | |
| 72 | 72 | $this->pagantisActivation(); |
| 73 | 73 | |
| 74 | 74 | $this->extraConfig = $this->getExtraConfig(); |
| 75 | 75 | |
| 76 | - load_plugin_textdomain('pagantis', false, basename(dirname(__FILE__)) . '/languages'); |
|
| 76 | + load_plugin_textdomain('pagantis', false, basename(dirname(__FILE__)).'/languages'); |
|
| 77 | 77 | add_filter('woocommerce_payment_gateways', array($this, 'addPagantisGateway')); |
| 78 | 78 | add_filter('woocommerce_available_payment_gateways', array($this, 'pagantisFilterGateways'), 9999); |
| 79 | 79 | add_filter('plugin_row_meta', array($this, 'pagantisRowMeta'), 10, 2); |
| 80 | - add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'pagantisActionLinks')); |
|
| 80 | + add_filter('plugin_action_links_'.plugin_basename(__FILE__), array($this, 'pagantisActionLinks')); |
|
| 81 | 81 | add_action('woocommerce_after_add_to_cart_form', array($this, 'pagantisAddProductSimulator')); |
| 82 | 82 | add_action('wp_enqueue_scripts', 'add_pagantis_widget_js'); |
| 83 | 83 | add_action('rest_api_init', array($this, 'pagantisRegisterEndpoint')); //Endpoint |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | { |
| 114 | 114 | $post_id = $product->get_id(); |
| 115 | 115 | $pagantis_promoted_value = $_REQUEST['pagantis_promoted']; |
| 116 | - if ($pagantis_promoted_value == 'on') { |
|
| 116 | + if ($pagantis_promoted_value=='on') { |
|
| 117 | 117 | $pagantis_promoted_value = 'yes'; |
| 118 | 118 | } else { |
| 119 | 119 | $pagantis_promoted_value = 'no'; |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | public function pagantisPromotedVarSave($post_id) |
| 147 | 147 | { |
| 148 | 148 | $pagantis_promoted_value = $_POST['pagantis_promoted']; |
| 149 | - if ($pagantis_promoted_value == null) { |
|
| 149 | + if ($pagantis_promoted_value==null) { |
|
| 150 | 150 | $pagantis_promoted_value = 'no'; |
| 151 | 151 | } |
| 152 | 152 | update_post_meta($post_id, 'custom_product_pagantis_promoted', esc_attr($pagantis_promoted_value)); |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function loadPagantisTranslation($mofile, $domain) |
| 161 | 161 | { |
| 162 | - if ('pagantis' === $domain) { |
|
| 163 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 162 | + if ('pagantis'===$domain) { |
|
| 163 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | return $mofile; |
@@ -173,19 +173,19 @@ discard block |
||
| 173 | 173 | { |
| 174 | 174 | global $wpdb; |
| 175 | 175 | |
| 176 | - $tableName = $wpdb->prefix . self::CONCURRENCY_TABLE; |
|
| 177 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
| 176 | + $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE; |
|
| 177 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
| 178 | 178 | $charset_collate = $wpdb->get_charset_collate(); |
| 179 | 179 | $sql = "CREATE TABLE $tableName ( order_id int NOT NULL, |
| 180 | 180 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate"; |
| 181 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 181 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 182 | 182 | dbDelta($sql); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - $tableName = $wpdb->prefix . self::CONFIG_TABLE; |
|
| 185 | + $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
|
| 186 | 186 | |
| 187 | 187 | //Check if table exists |
| 188 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; |
|
| 188 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; |
|
| 189 | 189 | if ($tableExists) { |
| 190 | 190 | $charset_collate = $wpdb->get_charset_collate(); |
| 191 | 191 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -194,13 +194,13 @@ discard block |
||
| 194 | 194 | value varchar(1000) NOT NULL, |
| 195 | 195 | UNIQUE KEY id(id)) $charset_collate"; |
| 196 | 196 | |
| 197 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 197 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 198 | 198 | dbDelta($sql); |
| 199 | 199 | } else { |
| 200 | 200 | //Updated value field to adapt to new length < v8.0.1 |
| 201 | 201 | $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'"; |
| 202 | 202 | $results = $wpdb->get_results($query, ARRAY_A); |
| 203 | - if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') { |
|
| 203 | + if ($results['0']['COLUMN_TYPE']=='varchar(100)') { |
|
| 204 | 204 | $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)"; |
| 205 | 205 | $wpdb->query($sql); |
| 206 | 206 | } |
@@ -210,15 +210,15 @@ discard block |
||
| 210 | 210 | or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
| 211 | 211 | $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A); |
| 212 | 212 | foreach ($dbCurrentConfig as $item) { |
| 213 | - if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
| 213 | + if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
| 214 | 214 | $css_price_selector = $this->preparePriceSelector($item['value']); |
| 215 | - if ($item['value'] != $css_price_selector) { |
|
| 215 | + if ($item['value']!=$css_price_selector) { |
|
| 216 | 216 | $wpdb->update($tableName, array('value' => stripslashes($css_price_selector)), |
| 217 | 217 | array('config' => 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'), array('%s'), array('%s')); |
| 218 | 218 | } |
| 219 | - } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
| 219 | + } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
| 220 | 220 | $css_quantity_selector = $this->prepareQuantitySelector($item['value']); |
| 221 | - if ($item['value'] != $css_quantity_selector) { |
|
| 221 | + if ($item['value']!=$css_quantity_selector) { |
|
| 222 | 222 | $wpdb->update($tableName, array('value' => stripslashes($css_quantity_selector)), |
| 223 | 223 | array('config' => 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'), array('%s'), array('%s')); |
| 224 | 224 | } |
@@ -227,36 +227,36 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | //Adapting selector to array < v8.2.2 |
| 230 | - $tableName = $wpdb->prefix . self::CONFIG_TABLE; |
|
| 230 | + $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
|
| 231 | 231 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
| 232 | 232 | $results = $wpdb->get_results($query, ARRAY_A); |
| 233 | - if (count($results) == 0) { |
|
| 233 | + if (count($results)==0) { |
|
| 234 | 234 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value' => '.'), array('%s', '%s')); |
| 235 | 235 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value' => ','), array('%s', '%s')); |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | //Adding new selector < v8.3.0 |
| 239 | - $tableName = $wpdb->prefix . self::CONFIG_TABLE; |
|
| 239 | + $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
|
| 240 | 240 | $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'"; |
| 241 | 241 | $results = $wpdb->get_results($query, ARRAY_A); |
| 242 | - if (count($results) == 0) { |
|
| 242 | + if (count($results)==0) { |
|
| 243 | 243 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value' => '0'), array('%s', '%s')); |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | //Adding new selector < v8.3.2 |
| 247 | - $tableName = $wpdb->prefix . self::CONFIG_TABLE; |
|
| 247 | + $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
|
| 248 | 248 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'"; |
| 249 | 249 | $results = $wpdb->get_results($query, ARRAY_A); |
| 250 | - if (count($results) == 0) { |
|
| 250 | + if (count($results)==0) { |
|
| 251 | 251 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value' => 'default'), array('%s', '%s')); |
| 252 | 252 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value' => 'default'), array('%s', '%s')); |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | //Adding new selector < v8.3.3 |
| 256 | - $tableName = $wpdb->prefix . self::CONFIG_TABLE; |
|
| 256 | + $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
|
| 257 | 257 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'"; |
| 258 | 258 | $results = $wpdb->get_results($query, ARRAY_A); |
| 259 | - if (count($results) == 0) { |
|
| 259 | + if (count($results)==0) { |
|
| 260 | 260 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', 'value' => 'sdk.simulator.types.CHECKOUT_PAGE'), |
| 261 | 261 | array('%s', '%s')); |
| 262 | 262 | $wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), |
@@ -265,10 +265,10 @@ discard block |
||
| 265 | 265 | |
| 266 | 266 | //Adapting to variable selector < v8.3.6 |
| 267 | 267 | $variableSelector = "div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
| 268 | - $tableName = $wpdb->prefix . self::CONFIG_TABLE; |
|
| 268 | + $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
|
| 269 | 269 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'"; |
| 270 | 270 | $results = $wpdb->get_results($query, ARRAY_A); |
| 271 | - if (count($results) == 0) { |
|
| 271 | + if (count($results)==0) { |
|
| 272 | 272 | $wpdb->update($tableName, array('value' => $variableSelector), array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION'), array('%s'), |
| 273 | 273 | array('%s')); |
| 274 | 274 | } |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | $simpleDbConfigs[$config['config']] = $config['value']; |
| 282 | 282 | } |
| 283 | 283 | $newConfigs = array_diff_key($this->defaultConfigs, $simpleDbConfigs); |
| 284 | - if ( ! empty($newConfigs)) { |
|
| 284 | + if (!empty($newConfigs)) { |
|
| 285 | 285 | foreach ($newConfigs as $key => $value) { |
| 286 | 286 | $wpdb->insert($tableName, array('config' => $key, 'value' => $value), array('%s', '%s')); |
| 287 | 287 | } |
@@ -290,12 +290,12 @@ discard block |
||
| 290 | 290 | //Current plugin config: pagantis_public_key => New field --- public_key => Old field |
| 291 | 291 | $settings = get_option('woocommerce_pagantis_settings'); |
| 292 | 292 | |
| 293 | - if ( ! isset($settings['pagantis_public_key']) && $settings['public_key']) { |
|
| 293 | + if (!isset($settings['pagantis_public_key']) && $settings['public_key']) { |
|
| 294 | 294 | $settings['pagantis_public_key'] = $settings['public_key']; |
| 295 | 295 | unset($settings['public_key']); |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - if ( ! isset($settings['pagantis_private_key']) && $settings['secret_key']) { |
|
| 298 | + if (!isset($settings['pagantis_private_key']) && $settings['secret_key']) { |
|
| 299 | 299 | $settings['pagantis_private_key'] = $settings['secret_key']; |
| 300 | 300 | unset($settings['secret_key']); |
| 301 | 301 | } |
@@ -317,11 +317,11 @@ discard block |
||
| 317 | 317 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
| 318 | 318 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
| 319 | 319 | $totalPrice = $product->get_price(); |
| 320 | - $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount == '0')); |
|
| 321 | - if ($cfg['enabled'] !== 'yes' || $cfg['pagantis_public_key'] == '' || $cfg['pagantis_private_key'] == '' |
|
| 322 | - || $cfg['simulator'] !== 'yes' |
|
| 323 | - || ! $allowedCountry |
|
| 324 | - || ! $validAmount |
|
| 320 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
| 321 | + if ($cfg['enabled']!=='yes' || $cfg['pagantis_public_key']=='' || $cfg['pagantis_private_key']=='' |
|
| 322 | + || $cfg['simulator']!=='yes' |
|
| 323 | + || !$allowedCountry |
|
| 324 | + || !$validAmount |
|
| 325 | 325 | ) { |
| 326 | 326 | return; |
| 327 | 327 | } |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | */ |
| 362 | 362 | public function addPagantisGateway($methods) |
| 363 | 363 | { |
| 364 | - if ( ! class_exists('WC_Payment_Gateway')) { |
|
| 364 | + if (!class_exists('WC_Payment_Gateway')) { |
|
| 365 | 365 | return $methods; |
| 366 | 366 | } |
| 367 | 367 | |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | public function pagantisFilterGateways($methods) |
| 382 | 382 | { |
| 383 | 383 | $pagantis = new WcPagantisGateway(); |
| 384 | - if ( ! $pagantis->is_available()) { |
|
| 384 | + if (!$pagantis->is_available()) { |
|
| 385 | 385 | unset($methods['pagantis']); |
| 386 | 386 | } |
| 387 | 387 | |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | { |
| 400 | 400 | $params_array = array('page' => 'wc-settings', 'tab' => 'checkout', 'section' => 'pagantis'); |
| 401 | 401 | $setting_url = esc_url(add_query_arg($params_array, admin_url('admin.php?'))); |
| 402 | - $setting_link = '<a href="' . $setting_url . '">' . __('Settings', 'pagantis') . '</a>'; |
|
| 402 | + $setting_link = '<a href="'.$setting_url.'">'.__('Settings', 'pagantis').'</a>'; |
|
| 403 | 403 | |
| 404 | 404 | array_unshift($links, $setting_link); |
| 405 | 405 | |
@@ -416,10 +416,10 @@ discard block |
||
| 416 | 416 | */ |
| 417 | 417 | public function pagantisRowMeta($links, $file) |
| 418 | 418 | { |
| 419 | - if ($file == plugin_basename(__FILE__)) { |
|
| 420 | - $links[] = '<a href="' . WcPagantis::GIT_HUB_URL . '" target="_blank">' . __('Documentation', 'pagantis') . '</a>'; |
|
| 421 | - $links[] = '<a href="' . WcPagantis::PAGANTIS_DOC_URL . '" target="_blank">' . __('API documentation', 'pagantis') . '</a>'; |
|
| 422 | - $links[] = '<a href="' . WcPagantis::SUPPORT_EML . '">' . __('Support', 'pagantis') . '</a>'; |
|
| 419 | + if ($file==plugin_basename(__FILE__)) { |
|
| 420 | + $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
|
| 421 | + $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'.__('API documentation', 'pagantis').'</a>'; |
|
| 422 | + $links[] = '<a href="'.WcPagantis::SUPPORT_EML.'">'.__('Support', 'pagantis').'</a>'; |
|
| 423 | 423 | |
| 424 | 424 | return $links; |
| 425 | 425 | } |
@@ -440,10 +440,10 @@ discard block |
||
| 440 | 440 | $to = $filters['to']; |
| 441 | 441 | $cfg = get_option('woocommerce_pagantis_settings'); |
| 442 | 442 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
| 443 | - $tableName = $wpdb->prefix . self::LOGS_TABLE; |
|
| 443 | + $tableName = $wpdb->prefix.self::LOGS_TABLE; |
|
| 444 | 444 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
| 445 | 445 | $results = $wpdb->get_results($query); |
| 446 | - if (isset($results) && $privateKey == $secretKey) { |
|
| 446 | + if (isset($results) && $privateKey==$secretKey) { |
|
| 447 | 447 | foreach ($results as $key => $result) { |
| 448 | 448 | $response[$key]['timestamp'] = $result->createdAt; |
| 449 | 449 | $response[$key]['log'] = json_decode($result->log); |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | $response = json_encode($response); |
| 455 | 455 | header("HTTP/1.1 200", true, 200); |
| 456 | 456 | header('Content-Type: application/json', true); |
| 457 | - header('Content-Length: ' . strlen($response)); |
|
| 457 | + header('Content-Length: '.strlen($response)); |
|
| 458 | 458 | echo($response); |
| 459 | 459 | exit(); |
| 460 | 460 | } |
@@ -465,20 +465,20 @@ discard block |
||
| 465 | 465 | public function updateExtraConfig($data) |
| 466 | 466 | { |
| 467 | 467 | global $wpdb; |
| 468 | - $tableName = $wpdb->prefix . self::CONFIG_TABLE; |
|
| 468 | + $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
|
| 469 | 469 | $response = array('status' => null); |
| 470 | 470 | |
| 471 | 471 | $filters = ($data->get_params()); |
| 472 | 472 | $secretKey = $filters['secret']; |
| 473 | 473 | $cfg = get_option('woocommerce_pagantis_settings'); |
| 474 | 474 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
| 475 | - if ($privateKey != $secretKey) { |
|
| 475 | + if ($privateKey!=$secretKey) { |
|
| 476 | 476 | $response['status'] = 401; |
| 477 | 477 | $response['result'] = 'Unauthorized'; |
| 478 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 478 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
| 479 | 479 | if (count($_POST)) { |
| 480 | 480 | foreach ($_POST as $config => $value) { |
| 481 | - if (isset($this->defaultConfigs[$config]) && $response['status'] == null) { |
|
| 481 | + if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |
|
| 482 | 482 | $wpdb->update($tableName, array('value' => stripslashes($value)), array('config' => $config), array('%s'), array('%s')); |
| 483 | 483 | } else { |
| 484 | 484 | $response['status'] = 400; |
@@ -491,8 +491,8 @@ discard block |
||
| 491 | 491 | } |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | - if ($response['status'] == null) { |
|
| 495 | - $tableName = $wpdb->prefix . self::CONFIG_TABLE; |
|
| 494 | + if ($response['status']==null) { |
|
| 495 | + $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
|
| 496 | 496 | $dbResult = $wpdb->get_results("select config, value from $tableName", ARRAY_A); |
| 497 | 497 | foreach ($dbResult as $value) { |
| 498 | 498 | $formattedResult[$value['config']] = $value['value']; |
@@ -501,9 +501,9 @@ discard block |
||
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | $result = json_encode($response['result']); |
| 504 | - header("HTTP/1.1 " . $response['status'], true, $response['status']); |
|
| 504 | + header("HTTP/1.1 ".$response['status'], true, $response['status']); |
|
| 505 | 505 | header('Content-Type: application/json', true); |
| 506 | - header('Content-Length: ' . strlen($result)); |
|
| 506 | + header('Content-Length: '.strlen($result)); |
|
| 507 | 507 | echo($result); |
| 508 | 508 | exit(); |
| 509 | 509 | } |
@@ -522,14 +522,14 @@ discard block |
||
| 522 | 522 | $method = ($filters['method']) ? ($filters['method']) : 'Pagantis'; |
| 523 | 523 | $cfg = get_option('woocommerce_pagantis_settings'); |
| 524 | 524 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
| 525 | - $tableName = $wpdb->prefix . self::ORDERS_TABLE; |
|
| 526 | - $tableNameInner = $wpdb->prefix . 'postmeta'; |
|
| 525 | + $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
|
| 526 | + $tableNameInner = $wpdb->prefix.'postmeta'; |
|
| 527 | 527 | $query = "select * from $tableName tn INNER JOIN $tableNameInner tn2 ON tn2.post_id = tn.id |
| 528 | - where tn.post_type='shop_order' and tn.post_date>'" . $from->format("Y-m-d") . "' |
|
| 529 | - and tn.post_date<'" . $to->format("Y-m-d") . "' order by tn.post_date desc"; |
|
| 528 | + where tn.post_type='shop_order' and tn.post_date>'".$from->format("Y-m-d")."' |
|
| 529 | + and tn.post_date<'" . $to->format("Y-m-d")."' order by tn.post_date desc"; |
|
| 530 | 530 | $results = $wpdb->get_results($query); |
| 531 | 531 | |
| 532 | - if (isset($results) && $privateKey == $secretKey) { |
|
| 532 | + if (isset($results) && $privateKey==$secretKey) { |
|
| 533 | 533 | foreach ($results as $result) { |
| 534 | 534 | $key = $result->ID; |
| 535 | 535 | $response['message'][$key]['timestamp'] = $result->post_date; |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | $response = json_encode($response); |
| 543 | 543 | header("HTTP/1.1 200", true, 200); |
| 544 | 544 | header('Content-Type: application/json', true); |
| 545 | - header('Content-Length: ' . strlen($response)); |
|
| 545 | + header('Content-Length: '.strlen($response)); |
|
| 546 | 546 | echo($response); |
| 547 | 547 | exit(); |
| 548 | 548 | } |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | private function getExtraConfig() |
| 586 | 586 | { |
| 587 | 587 | global $wpdb; |
| 588 | - $tableName = $wpdb->prefix . self::CONFIG_TABLE; |
|
| 588 | + $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
|
| 589 | 589 | $response = array(); |
| 590 | 590 | $dbResult = $wpdb->get_results("select config, value from $tableName", ARRAY_A); |
| 591 | 591 | foreach ($dbResult as $value) { |
@@ -602,9 +602,9 @@ discard block |
||
| 602 | 602 | */ |
| 603 | 603 | private function prepareQuantitySelector($css_quantity_selector) |
| 604 | 604 | { |
| 605 | - if ($css_quantity_selector == 'default' || $css_quantity_selector == '') { |
|
| 605 | + if ($css_quantity_selector=='default' || $css_quantity_selector=='') { |
|
| 606 | 606 | $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
| 607 | - } elseif ( ! unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
|
| 607 | + } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
|
| 608 | 608 | $css_quantity_selector = serialize(array($css_quantity_selector)); |
| 609 | 609 | } |
| 610 | 610 | |
@@ -618,9 +618,9 @@ discard block |
||
| 618 | 618 | */ |
| 619 | 619 | private function preparePriceSelector($css_price_selector) |
| 620 | 620 | { |
| 621 | - if ($css_price_selector == 'default' || $css_price_selector == '') { |
|
| 621 | + if ($css_price_selector=='default' || $css_price_selector=='') { |
|
| 622 | 622 | $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
| 623 | - } elseif ( ! unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
|
| 623 | + } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
|
| 624 | 624 | $css_price_selector = serialize(array($css_price_selector)); |
| 625 | 625 | } |
| 626 | 626 | |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | $metaProduct = get_post_meta($product_id); |
| 638 | 638 | |
| 639 | 639 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) |
| 640 | - && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
| 640 | + && $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
@@ -199,8 +199,8 @@ |
||
| 199 | 199 | $this->woocommerceOrder->save(); |
| 200 | 200 | if ( ! $this->woocommerceOrder->has_status($isOrderStatusValid)) { // TO CONFIRM
|
| 201 | 201 | $logMessage = "WARNING checkMerchantOrderStatus." . " Merchant order id:" . $this->woocommerceOrder->get_id() . " Merchant order status:" |
| 202 | - . $this->woocommerceOrder->get_status() . " Pagantis order id:" . $this->pagantisOrder->getStatus() |
|
| 203 | - . " Pagantis order status:" . $this->pagantisOrder->getId(); |
|
| 202 | + . $this->woocommerceOrder->get_status() . " Pagantis order id:" . $this->pagantisOrder->getStatus() |
|
| 203 | + . " Pagantis order status:" . $this->pagantisOrder->getId(); |
|
| 204 | 204 | |
| 205 | 205 | $this->insertLog(null, $logMessage); |
| 206 | 206 | $this->woocommerceOrder->add_order_note($logMessage); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | use Pagantis\ModuleUtils\Model\Log\LogEntry; |
| 17 | 17 | use Pagantis\OrdersApiClient\Model\Order; |
| 18 | 18 | |
| 19 | -if ( ! defined('ABSPATH')) {
|
|
| 19 | +if (!defined('ABSPATH')) {
|
|
| 20 | 20 | exit; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | public function processInformation() |
| 63 | 63 | {
|
| 64 | 64 | try {
|
| 65 | - require_once(__ROOT__ . '/vendor/autoload.php'); |
|
| 65 | + require_once(__ROOT__.'/vendor/autoload.php'); |
|
| 66 | 66 | try {
|
| 67 | - if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_GET['origin'] == 'notification') {
|
|
| 67 | + if ($_SERVER['REQUEST_METHOD']=='GET' && $_GET['origin']=='notification') {
|
|
| 68 | 68 | return $this->buildResponse(); |
| 69 | 69 | } |
| 70 | 70 | $this->checkConcurrency(); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | private function checkConcurrency() |
| 114 | 114 | {
|
| 115 | 115 | $this->woocommerceOrderId = $_GET['order-received']; |
| 116 | - if ($this->woocommerceOrderId == '') {
|
|
| 116 | + if ($this->woocommerceOrderId=='') {
|
|
| 117 | 117 | throw new QuoteNotFoundException(); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -141,11 +141,11 @@ discard block |
||
| 141 | 141 | {
|
| 142 | 142 | global $wpdb; |
| 143 | 143 | $this->checkDbTable(); |
| 144 | - $tableName = $wpdb->prefix . self::ORDERS_TABLE; |
|
| 145 | - $queryResult = $wpdb->get_row("select order_id from $tableName where id='" . $this->woocommerceOrderId . "'");
|
|
| 144 | + $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
|
| 145 | + $queryResult = $wpdb->get_row("select order_id from $tableName where id='".$this->woocommerceOrderId."'");
|
|
| 146 | 146 | $this->pagantisOrderId = $queryResult->order_id; |
| 147 | 147 | |
| 148 | - if ($this->pagantisOrderId == '') {
|
|
| 148 | + if ($this->pagantisOrderId=='') {
|
|
| 149 | 149 | throw new NoIdentificationException(); |
| 150 | 150 | } |
| 151 | 151 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | $status = '-'; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ($status === Order::STATUS_CONFIRMED) {
|
|
| 183 | + if ($status===Order::STATUS_CONFIRMED) {
|
|
| 184 | 184 | return true; |
| 185 | 185 | } |
| 186 | 186 | throw new WrongStatusException($status); |
@@ -197,10 +197,10 @@ discard block |
||
| 197 | 197 | $validOrderStatuses = array('on-hold', 'pending', 'failed', 'processing', 'completed');
|
| 198 | 198 | $isOrderStatusValid = apply_filters('woocommerce_valid_order_statuses_for_payment_complete', $validOrderStatuses, $this);
|
| 199 | 199 | $this->woocommerceOrder->save(); |
| 200 | - if ( ! $this->woocommerceOrder->has_status($isOrderStatusValid)) { // TO CONFIRM
|
|
| 201 | - $logMessage = "WARNING checkMerchantOrderStatus." . " Merchant order id:" . $this->woocommerceOrder->get_id() . " Merchant order status:" |
|
| 202 | - . $this->woocommerceOrder->get_status() . " Pagantis order id:" . $this->pagantisOrder->getStatus() |
|
| 203 | - . " Pagantis order status:" . $this->pagantisOrder->getId(); |
|
| 200 | + if (!$this->woocommerceOrder->has_status($isOrderStatusValid)) { // TO CONFIRM
|
|
| 201 | + $logMessage = "WARNING checkMerchantOrderStatus."." Merchant order id:".$this->woocommerceOrder->get_id()." Merchant order status:" |
|
| 202 | + . $this->woocommerceOrder->get_status()." Pagantis order id:".$this->pagantisOrder->getStatus() |
|
| 203 | + . " Pagantis order status:".$this->pagantisOrder->getId(); |
|
| 204 | 204 | |
| 205 | 205 | $this->insertLog(null, $logMessage); |
| 206 | 206 | $this->woocommerceOrder->add_order_note($logMessage); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | {
|
| 219 | 219 | $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
| 220 | 220 | $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total())); |
| 221 | - if ($pagantisAmount != $wcAmount) {
|
|
| 221 | + if ($pagantisAmount!=$wcAmount) {
|
|
| 222 | 222 | throw new AmountMismatchException($pagantisAmount, $wcAmount); |
| 223 | 223 | } |
| 224 | 224 | } |
@@ -242,10 +242,10 @@ discard block |
||
| 242 | 242 | $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId); |
| 243 | 243 | } catch (\Exception $e) {
|
| 244 | 244 | $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId); |
| 245 | - if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) {
|
|
| 245 | + if ($this->pagantisOrder->getStatus()!==Order::STATUS_CONFIRMED) {
|
|
| 246 | 246 | throw new UnknownException($e->getMessage()); |
| 247 | 247 | } else {
|
| 248 | - $logMessage = 'Concurrency issue: Order_id ' . $this->pagantisOrderId . ' was confirmed by other process'; |
|
| 248 | + $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process'; |
|
| 249 | 249 | $this->insertLog(null, $logMessage); |
| 250 | 250 | } |
| 251 | 251 | } |
@@ -265,14 +265,14 @@ discard block |
||
| 265 | 265 | private function checkDbTable() |
| 266 | 266 | {
|
| 267 | 267 | global $wpdb; |
| 268 | - $tableName = $wpdb->prefix . self::ORDERS_TABLE; |
|
| 268 | + $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
|
| 269 | 269 | |
| 270 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 270 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 271 | 271 | $charset_collate = $wpdb->get_charset_collate(); |
| 272 | 272 | $sql = "CREATE TABLE $tableName (id int, order_id varchar(50), wc_order_id varchar(50), |
| 273 | 273 | UNIQUE KEY id (id)) $charset_collate"; |
| 274 | 274 | |
| 275 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 275 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 276 | 276 | dbDelta($sql); |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -283,14 +283,14 @@ discard block |
||
| 283 | 283 | private function checkDbLogTable() |
| 284 | 284 | {
|
| 285 | 285 | global $wpdb; |
| 286 | - $tableName = $wpdb->prefix . self::LOGS_TABLE; |
|
| 286 | + $tableName = $wpdb->prefix.self::LOGS_TABLE; |
|
| 287 | 287 | |
| 288 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 288 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 289 | 289 | $charset_collate = $wpdb->get_charset_collate(); |
| 290 | 290 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
| 291 | 291 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
| 292 | 292 | |
| 293 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 293 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 294 | 294 | dbDelta($sql); |
| 295 | 295 | } |
| 296 | 296 | |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | if ($this->pagantisOrder instanceof Order) {
|
| 318 | 318 | $paid = in_array($this->pagantisOrder->getStatus(), $pagantisStatus); |
| 319 | - if ( ! $paid) {
|
|
| 319 | + if (!$paid) {
|
|
| 320 | 320 | if ($this->pagantisOrder instanceof Order) {
|
| 321 | 321 | $status = $this->pagantisOrder->getStatus(); |
| 322 | 322 | } else {
|
@@ -344,12 +344,12 @@ discard block |
||
| 344 | 344 | $metadataOrder = $this->pagantisOrder->getMetadata(); |
| 345 | 345 | $metadataInfo = null; |
| 346 | 346 | foreach ($metadataOrder as $metadataKey => $metadataValue) {
|
| 347 | - if ($metadataKey == 'promotedProduct') {
|
|
| 347 | + if ($metadataKey=='promotedProduct') {
|
|
| 348 | 348 | $metadataInfo .= "/Producto promocionado = $metadataValue"; |
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - if ($metadataInfo != null) {
|
|
| 352 | + if ($metadataInfo!=null) {
|
|
| 353 | 353 | $this->woocommerceOrder->add_order_note($metadataInfo); |
| 354 | 354 | } |
| 355 | 355 | |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | global $wpdb; |
| 378 | 378 | |
| 379 | 379 | $this->checkDbTable(); |
| 380 | - $tableName = $wpdb->prefix . self::ORDERS_TABLE; |
|
| 380 | + $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
|
| 381 | 381 | |
| 382 | 382 | $wpdb->update($tableName, array('wc_order_id' => $this->woocommerceOrderId), array('id' => $this->woocommerceOrderId), array('%s'),
|
| 383 | 383 | array('%d'));
|
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | $logEntry = $logEntry->info($message); |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - $tableName = $wpdb->prefix . self::LOGS_TABLE; |
|
| 408 | + $tableName = $wpdb->prefix.self::LOGS_TABLE; |
|
| 409 | 409 | $wpdb->insert($tableName, array('log' => $logEntry->toJson()));
|
| 410 | 410 | } |
| 411 | 411 | |
@@ -417,14 +417,14 @@ discard block |
||
| 417 | 417 | private function unblockConcurrency($orderId = null) |
| 418 | 418 | {
|
| 419 | 419 | global $wpdb; |
| 420 | - $tableName = $wpdb->prefix . self::CONCURRENCY_TABLE; |
|
| 421 | - if ($orderId == null) {
|
|
| 422 | - $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL " . self::CONCURRENCY_TIMEOUT . " SECOND)"; |
|
| 420 | + $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE; |
|
| 421 | + if ($orderId==null) {
|
|
| 422 | + $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT." SECOND)"; |
|
| 423 | 423 | } else {
|
| 424 | 424 | $query = "DELETE FROM $tableName WHERE order_id = $orderId"; |
| 425 | 425 | } |
| 426 | 426 | $resultDelete = $wpdb->query($query); |
| 427 | - if ($resultDelete === false) {
|
|
| 427 | + if ($resultDelete===false) {
|
|
| 428 | 428 | throw new ConcurrencyException(); |
| 429 | 429 | } |
| 430 | 430 | } |
@@ -437,10 +437,10 @@ discard block |
||
| 437 | 437 | private function blockConcurrency($orderId) |
| 438 | 438 | {
|
| 439 | 439 | global $wpdb; |
| 440 | - $tableName = $wpdb->prefix . self::CONCURRENCY_TABLE; |
|
| 440 | + $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE; |
|
| 441 | 441 | $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId));
|
| 442 | - if ($insertResult === false) {
|
|
| 443 | - if ($this->getOrigin() == 'Notify') {
|
|
| 442 | + if ($insertResult===false) {
|
|
| 443 | + if ($this->getOrigin()=='Notify') {
|
|
| 444 | 444 | throw new ConcurrencyException(); |
| 445 | 445 | } else {
|
| 446 | 446 | $query = |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | {
|
| 470 | 470 | $this->unblockConcurrency($this->woocommerceOrderId); |
| 471 | 471 | |
| 472 | - if ($exception == null) {
|
|
| 472 | + if ($exception==null) {
|
|
| 473 | 473 | $jsonResponse = new JsonSuccessResponse(); |
| 474 | 474 | } else {
|
| 475 | 475 | $jsonResponse = new JsonExceptionResponse(); |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | $jsonResponse->setMerchantOrderId($this->woocommerceOrderId); |
| 480 | 480 | $jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
| 481 | 481 | |
| 482 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
| 482 | + if ($_SERVER['REQUEST_METHOD']=='POST') {
|
|
| 483 | 483 | $jsonResponse->printResponse(); |
| 484 | 484 | } else {
|
| 485 | 485 | return $jsonResponse; |
@@ -196,15 +196,15 @@ discard block |
||
| 196 | 196 | ->setAddress($shippingAddress['address_1'] . " " . $shippingAddress['address_2']); |
| 197 | 197 | $orderShippingAddress = new Address(); |
| 198 | 198 | $orderShippingAddress->setZipCode($shippingAddress['postcode']) |
| 199 | - ->setFullName($shippingAddress['first_name'] . " " . $shippingAddress['last_name']) |
|
| 200 | - ->setCountryCode($shippingAddress['country'] != '' ? strtoupper($shippingAddress['country']) |
|
| 199 | + ->setFullName($shippingAddress['first_name'] . " " . $shippingAddress['last_name']) |
|
| 200 | + ->setCountryCode($shippingAddress['country'] != '' ? strtoupper($shippingAddress['country']) |
|
| 201 | 201 | : strtoupper($this->language)) |
| 202 | - ->setCity($shippingAddress['city']) |
|
| 203 | - ->setAddress($shippingAddress['address_1'] . " " . $shippingAddress['address_2']) |
|
| 204 | - ->setFixPhone($shippingAddress['phone']) |
|
| 205 | - ->setMobilePhone($shippingAddress['phone']) |
|
| 206 | - ->setNationalId($national_id) |
|
| 207 | - ->setTaxId($tax_id); |
|
| 202 | + ->setCity($shippingAddress['city']) |
|
| 203 | + ->setAddress($shippingAddress['address_1'] . " " . $shippingAddress['address_2']) |
|
| 204 | + ->setFixPhone($shippingAddress['phone']) |
|
| 205 | + ->setMobilePhone($shippingAddress['phone']) |
|
| 206 | + ->setNationalId($national_id) |
|
| 207 | + ->setTaxId($tax_id); |
|
| 208 | 208 | $orderBillingAddress = new Address(); |
| 209 | 209 | $orderBillingAddress->setZipCode($billingAddress['postcode']) |
| 210 | 210 | ->setFullName($billingAddress['first_name'] . " " . $billingAddress['last_name']) |
@@ -218,14 +218,14 @@ discard block |
||
| 218 | 218 | ->setTaxId($tax_id); |
| 219 | 219 | $orderUser = new User(); |
| 220 | 220 | $orderUser->setAddress($userAddress) |
| 221 | - ->setFullName($billingAddress['first_name'] . " " . $billingAddress['last_name']) |
|
| 222 | - ->setBillingAddress($orderBillingAddress) |
|
| 223 | - ->setEmail($billingAddress['email']) |
|
| 224 | - ->setFixPhone($billingAddress['phone']) |
|
| 225 | - ->setMobilePhone($billingAddress['phone']) |
|
| 226 | - ->setShippingAddress($orderShippingAddress) |
|
| 227 | - ->setNationalId($national_id) |
|
| 228 | - ->setTaxId($tax_id); |
|
| 221 | + ->setFullName($billingAddress['first_name'] . " " . $billingAddress['last_name']) |
|
| 222 | + ->setBillingAddress($orderBillingAddress) |
|
| 223 | + ->setEmail($billingAddress['email']) |
|
| 224 | + ->setFixPhone($billingAddress['phone']) |
|
| 225 | + ->setMobilePhone($billingAddress['phone']) |
|
| 226 | + ->setShippingAddress($orderShippingAddress) |
|
| 227 | + ->setNationalId($national_id) |
|
| 228 | + ->setTaxId($tax_id); |
|
| 229 | 229 | |
| 230 | 230 | $previousOrders = $this->getOrders($order->get_user(), $billingAddress['email']); |
| 231 | 231 | foreach ($previousOrders as $previousOrder) {
|
@@ -277,9 +277,9 @@ discard block |
||
| 277 | 277 | |
| 278 | 278 | $orderShoppingCart = new ShoppingCart(); |
| 279 | 279 | $orderShoppingCart->setDetails($details) |
| 280 | - ->setOrderReference($order->get_id()) |
|
| 281 | - ->setPromotedAmount($promotedAmount) |
|
| 282 | - ->setTotalAmount(intval(strval(100 * $order->total))); |
|
| 280 | + ->setOrderReference($order->get_id()) |
|
| 281 | + ->setPromotedAmount($promotedAmount) |
|
| 282 | + ->setTotalAmount(intval(strval(100 * $order->total))); |
|
| 283 | 283 | $orderConfigurationUrls = new Urls(); |
| 284 | 284 | $cancelUrl = $this->getKoUrl($order); |
| 285 | 285 | $callback_arg = array( |
@@ -298,10 +298,10 @@ discard block |
||
| 298 | 298 | $callback_url_notif = add_query_arg($callback_arg_notif, home_url('/'));
|
| 299 | 299 | |
| 300 | 300 | $orderConfigurationUrls->setCancel($cancelUrl) |
| 301 | - ->setKo($callback_url_user) |
|
| 302 | - ->setAuthorizedNotificationCallback($callback_url_notif) |
|
| 303 | - ->setRejectedNotificationCallback(null) |
|
| 304 | - ->setOk($callback_url_user); |
|
| 301 | + ->setKo($callback_url_user) |
|
| 302 | + ->setAuthorizedNotificationCallback($callback_url_notif) |
|
| 303 | + ->setRejectedNotificationCallback(null) |
|
| 304 | + ->setOk($callback_url_user); |
|
| 305 | 305 | $orderChannel = new Channel(); |
| 306 | 306 | $orderChannel->setAssistedSale(false)->setType(Channel::ONLINE); |
| 307 | 307 | |
@@ -316,9 +316,9 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | $orderApiClient = new Order(); |
| 318 | 318 | $orderApiClient->setConfiguration($orderConfiguration) |
| 319 | - ->setMetadata($metadataOrder) |
|
| 320 | - ->setShoppingCart($orderShoppingCart) |
|
| 321 | - ->setUser($orderUser); |
|
| 319 | + ->setMetadata($metadataOrder) |
|
| 320 | + ->setShoppingCart($orderShoppingCart) |
|
| 321 | + ->setUser($orderUser); |
|
| 322 | 322 | |
| 323 | 323 | if ($this->pagantis_public_key == '' || $this->pagantis_private_key == '') {
|
| 324 | 324 | throw new \Exception('Public and Secret Key not found');
|
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | $returnUrl = $this->getOkUrl($paymentOrder); |
| 382 | 382 | } else {
|
| 383 | 383 | $returnUrl = $this->getKoUrl($paymentOrder); |
| 384 | - $paymentOrder->delete($forceDelete = true); |
|
| 384 | + $paymentOrder->delete($forceDelete = true); |
|
| 385 | 385 | } |
| 386 | 386 | wp_redirect($returnUrl); |
| 387 | 387 | exit; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | use Pagantis\OrdersApiClient\Model\Order; |
| 17 | 17 | use Pagantis\ModuleUtils\Model\Log\LogEntry; |
| 18 | 18 | |
| 19 | -if ( ! defined('ABSPATH')) {
|
|
| 19 | +if (!defined('ABSPATH')) {
|
|
| 20 | 20 | exit; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -54,18 +54,18 @@ discard block |
||
| 54 | 54 | $this->method_title = ucfirst($this->id); |
| 55 | 55 | |
| 56 | 56 | //Useful vars |
| 57 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/'; |
|
| 57 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/'; |
|
| 58 | 58 | $this->allowed_currencies = array("EUR");
|
| 59 | - $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Pagantis.php'; |
|
| 59 | + $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)).'/WC_Pagantis.php'; |
|
| 60 | 60 | $this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false);
|
| 61 | 61 | $this->language = strstr(get_locale(), '_', true); |
| 62 | - if ($this->language == '') {
|
|
| 62 | + if ($this->language=='') {
|
|
| 63 | 63 | $this->language = 'ES'; |
| 64 | 64 | } |
| 65 | 65 | $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
| 66 | 66 | |
| 67 | 67 | //Panel form fields |
| 68 | - $this->form_fields = include(plugin_dir_path(__FILE__) . '../includes/settings-pagantis.php'); //Panel options |
|
| 68 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options |
|
| 69 | 69 | $this->init_settings(); |
| 70 | 70 | |
| 71 | 71 | $this->extraConfig = $this->getExtraConfig(); |
@@ -73,17 +73,17 @@ discard block |
||
| 73 | 73 | $this->method_description = |
| 74 | 74 | "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis."; |
| 75 | 75 | |
| 76 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK'] != '') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
| 77 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO'] != '') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
| 76 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
| 77 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
| 78 | 78 | foreach ($this->settings as $setting_key => $setting_value) {
|
| 79 | 79 | $this->$setting_key = $setting_value; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | //Hooks |
| 83 | - add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); //Save plugin options
|
|
| 84 | - add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields
|
|
| 85 | - add_action('woocommerce_receipt_' . $this->id, array($this, 'pagantisReceiptPage')); //Pagantis form
|
|
| 86 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification
|
|
| 83 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options
|
|
| 84 | + add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields
|
|
| 85 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form
|
|
| 86 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification
|
|
| 87 | 87 | add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3);
|
| 88 | 88 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2);
|
| 89 | 89 | } |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function loadPagantisTranslation($mofile, $domain) |
| 98 | 98 | {
|
| 99 | - if ('pagantis' === $domain) {
|
|
| 100 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 99 | + if ('pagantis'===$domain) {
|
|
| 100 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | return $mofile; |
@@ -130,16 +130,16 @@ discard block |
||
| 130 | 130 | public function pagantisCheckFields() |
| 131 | 131 | {
|
| 132 | 132 | $error_string = ''; |
| 133 | - if ($this->settings['enabled'] !== 'yes') {
|
|
| 133 | + if ($this->settings['enabled']!=='yes') {
|
|
| 134 | 134 | return; |
| 135 | - } elseif ( ! version_compare(phpversion(), '5.3.0', '>=')) {
|
|
| 135 | + } elseif (!version_compare(phpversion(), '5.3.0', '>=')) {
|
|
| 136 | 136 | $error_string = __(' is not compatible with your php and/or curl version', 'pagantis');
|
| 137 | 137 | $this->settings['enabled'] = 'no'; |
| 138 | - } elseif ($this->settings['pagantis_public_key'] == "" || $this->settings['pagantis_private_key'] == "") {
|
|
| 138 | + } elseif ($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="") {
|
|
| 139 | 139 | $error_string = |
| 140 | 140 | __(' is not configured correctly, the fields Public Key and Secret Key are mandatory for use this plugin', 'pagantis');
|
| 141 | 141 | $this->settings['enabled'] = 'no'; |
| 142 | - } elseif ( ! in_array(get_woocommerce_currency(), $this->allowed_currencies)) {
|
|
| 142 | + } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) {
|
|
| 143 | 143 | $error_string = __(' only can be used in Euros', 'pagantis');
|
| 144 | 144 | $this->settings['enabled'] = 'no'; |
| 145 | 145 | } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] < '2' |
@@ -154,9 +154,9 @@ discard block |
||
| 154 | 154 | $error_string = __(' can not have a minimum amount less than 0', 'pagantis');
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if ($error_string != '') {
|
|
| 157 | + if ($error_string!='') {
|
|
| 158 | 158 | $template_fields = array( |
| 159 | - 'error_msg' => ucfirst(WcPagantisGateway::METHOD_ID) . ' ' . $error_string, |
|
| 159 | + 'error_msg' => ucfirst(WcPagantisGateway::METHOD_ID).' '.$error_string, |
|
| 160 | 160 | ); |
| 161 | 161 | wc_get_template('error_msg.php', $template_fields, '', $this->template_path);
|
| 162 | 162 | } |
@@ -172,16 +172,16 @@ discard block |
||
| 172 | 172 | public function pagantisReceiptPage($order_id) |
| 173 | 173 | {
|
| 174 | 174 | try {
|
| 175 | - require_once(__ROOT__ . '/vendor/autoload.php'); |
|
| 175 | + require_once(__ROOT__.'/vendor/autoload.php'); |
|
| 176 | 176 | global $woocommerce; |
| 177 | 177 | $order = new WC_Order($order_id); |
| 178 | - if ( ! isset($order)) {
|
|
| 178 | + if (!isset($order)) {
|
|
| 179 | 179 | throw new Exception(_("Order not found"));
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | $shippingAddress = $order->get_address('shipping');
|
| 183 | 183 | $billingAddress = $order->get_address('billing');
|
| 184 | - if ($shippingAddress['address_1'] == '') {
|
|
| 184 | + if ($shippingAddress['address_1']=='') {
|
|
| 185 | 185 | $shippingAddress = $billingAddress; |
| 186 | 186 | } |
| 187 | 187 | |
@@ -190,35 +190,35 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | $userAddress = new Address(); |
| 192 | 192 | $userAddress->setZipCode($shippingAddress['postcode']) |
| 193 | - ->setFullName($shippingAddress['first_name'] . " " . $shippingAddress['last_name']) |
|
| 194 | - ->setCountryCode($shippingAddress['country'] != '' ? strtoupper($shippingAddress['country']) : strtoupper($this->language)) |
|
| 193 | + ->setFullName($shippingAddress['first_name']." ".$shippingAddress['last_name']) |
|
| 194 | + ->setCountryCode($shippingAddress['country']!='' ? strtoupper($shippingAddress['country']) : strtoupper($this->language)) |
|
| 195 | 195 | ->setCity($shippingAddress['city']) |
| 196 | - ->setAddress($shippingAddress['address_1'] . " " . $shippingAddress['address_2']); |
|
| 196 | + ->setAddress($shippingAddress['address_1']." ".$shippingAddress['address_2']); |
|
| 197 | 197 | $orderShippingAddress = new Address(); |
| 198 | 198 | $orderShippingAddress->setZipCode($shippingAddress['postcode']) |
| 199 | - ->setFullName($shippingAddress['first_name'] . " " . $shippingAddress['last_name']) |
|
| 200 | - ->setCountryCode($shippingAddress['country'] != '' ? strtoupper($shippingAddress['country']) |
|
| 199 | + ->setFullName($shippingAddress['first_name']." ".$shippingAddress['last_name']) |
|
| 200 | + ->setCountryCode($shippingAddress['country']!='' ? strtoupper($shippingAddress['country']) |
|
| 201 | 201 | : strtoupper($this->language)) |
| 202 | 202 | ->setCity($shippingAddress['city']) |
| 203 | - ->setAddress($shippingAddress['address_1'] . " " . $shippingAddress['address_2']) |
|
| 203 | + ->setAddress($shippingAddress['address_1']." ".$shippingAddress['address_2']) |
|
| 204 | 204 | ->setFixPhone($shippingAddress['phone']) |
| 205 | 205 | ->setMobilePhone($shippingAddress['phone']) |
| 206 | 206 | ->setNationalId($national_id) |
| 207 | 207 | ->setTaxId($tax_id); |
| 208 | 208 | $orderBillingAddress = new Address(); |
| 209 | 209 | $orderBillingAddress->setZipCode($billingAddress['postcode']) |
| 210 | - ->setFullName($billingAddress['first_name'] . " " . $billingAddress['last_name']) |
|
| 211 | - ->setCountryCode($billingAddress['country'] != '' ? strtoupper($billingAddress['country']) |
|
| 210 | + ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
|
| 211 | + ->setCountryCode($billingAddress['country']!='' ? strtoupper($billingAddress['country']) |
|
| 212 | 212 | : strtoupper($this->language)) |
| 213 | 213 | ->setCity($billingAddress['city']) |
| 214 | - ->setAddress($billingAddress['address_1'] . " " . $billingAddress['address_2']) |
|
| 214 | + ->setAddress($billingAddress['address_1']." ".$billingAddress['address_2']) |
|
| 215 | 215 | ->setFixPhone($billingAddress['phone']) |
| 216 | 216 | ->setMobilePhone($billingAddress['phone']) |
| 217 | 217 | ->setNationalId($national_id) |
| 218 | 218 | ->setTaxId($tax_id); |
| 219 | 219 | $orderUser = new User(); |
| 220 | 220 | $orderUser->setAddress($userAddress) |
| 221 | - ->setFullName($billingAddress['first_name'] . " " . $billingAddress['last_name']) |
|
| 221 | + ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
|
| 222 | 222 | ->setBillingAddress($orderBillingAddress) |
| 223 | 223 | ->setEmail($billingAddress['email']) |
| 224 | 224 | ->setFixPhone($billingAddress['phone']) |
@@ -265,11 +265,11 @@ discard block |
||
| 265 | 265 | $details->addProduct($product); |
| 266 | 266 | |
| 267 | 267 | $promotedProduct = $this->isPromoted($item->get_product_id()); |
| 268 | - if ($promotedProduct == 'true') {
|
|
| 269 | - $promotedAmount += $product->getAmount(); |
|
| 268 | + if ($promotedProduct=='true') {
|
|
| 269 | + $promotedAmount += $product->getAmount(); |
|
| 270 | 270 | $promotedMessage = |
| 271 | - 'Promoted Item: ' . $wcProduct->get_name() . ' - Price: ' . $item->get_total() . ' - Qty: ' . $product->getQuantity() |
|
| 272 | - . ' - Item ID: ' . $item['id_product']; |
|
| 271 | + 'Promoted Item: '.$wcProduct->get_name().' - Price: '.$item->get_total().' - Qty: '.$product->getQuantity() |
|
| 272 | + . ' - Item ID: '.$item['id_product']; |
|
| 273 | 273 | $promotedMessage = substr($promotedMessage, 0, 999); |
| 274 | 274 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage);
|
| 275 | 275 | } |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | ->setShoppingCart($orderShoppingCart) |
| 321 | 321 | ->setUser($orderUser); |
| 322 | 322 | |
| 323 | - if ($this->pagantis_public_key == '' || $this->pagantis_private_key == '') {
|
|
| 323 | + if ($this->pagantis_public_key=='' || $this->pagantis_private_key=='') {
|
|
| 324 | 324 | throw new \Exception('Public and Secret Key not found');
|
| 325 | 325 | } |
| 326 | 326 | $orderClient = new Client($this->pagantis_public_key, $this->pagantis_private_key); |
@@ -332,9 +332,9 @@ discard block |
||
| 332 | 332 | throw new OrderNotFoundException(); |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - if ($url == "") {
|
|
| 335 | + if ($url=="") {
|
|
| 336 | 336 | throw new Exception(_("No ha sido posible obtener una respuesta de Pagantis"));
|
| 337 | - } elseif ($this->extraConfig['PAGANTIS_FORM_DISPLAY_TYPE'] == '0') {
|
|
| 337 | + } elseif ($this->extraConfig['PAGANTIS_FORM_DISPLAY_TYPE']=='0') {
|
|
| 338 | 338 | wp_redirect($url); |
| 339 | 339 | exit; |
| 340 | 340 | } else {
|
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | wc_get_template('iframe.php', $template_fields, '', $this->template_path);
|
| 346 | 346 | } |
| 347 | 347 | } catch (\Exception $exception) {
|
| 348 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error');
|
|
| 348 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error');
|
|
| 349 | 349 | $this->insertLog($exception); |
| 350 | 350 | $checkout_url = get_permalink(wc_get_page_id('checkout'));
|
| 351 | 351 | wp_redirect($checkout_url); |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | public function pagantisNotification() |
| 360 | 360 | {
|
| 361 | 361 | try {
|
| 362 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
| 362 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
| 363 | 363 | |
| 364 | 364 | include_once('notifyController.php');
|
| 365 | 365 | $notify = new WcPagantisNotify(); |
@@ -398,10 +398,10 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | public function pagantisCompleteStatus($status, $order_id, $order) |
| 400 | 400 | {
|
| 401 | - if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) {
|
|
| 402 | - if ($order->get_status() == 'failed') {
|
|
| 401 | + if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) {
|
|
| 402 | + if ($order->get_status()=='failed') {
|
|
| 403 | 403 | $status = 'processing'; |
| 404 | - } elseif ($order->get_status() == 'pending' && $status == 'completed') {
|
|
| 404 | + } elseif ($order->get_status()=='pending' && $status=='completed') {
|
|
| 405 | 405 | $status = 'processing'; |
| 406 | 406 | } |
| 407 | 407 | } |
@@ -427,9 +427,9 @@ discard block |
||
| 427 | 427 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
| 428 | 428 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
| 429 | 429 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
| 430 | - $totalPrice = (int)$this->get_order_total(); |
|
| 431 | - $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount == '0')); |
|
| 432 | - if ($this->enabled === 'yes' && $this->pagantis_public_key != '' && $this->pagantis_private_key != '' && $validAmount |
|
| 430 | + $totalPrice = (int) $this->get_order_total(); |
|
| 431 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
| 432 | + if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' && $validAmount |
|
| 433 | 433 | && $allowedCountry |
| 434 | 434 | ) {
|
| 435 | 435 | return true; |
@@ -461,8 +461,8 @@ discard block |
||
| 461 | 461 | $order = new WC_Order($order_id); |
| 462 | 462 | |
| 463 | 463 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
| 464 | - if (strpos($redirectUrl, 'order-pay=') === false) {
|
|
| 465 | - $redirectUrl .= "&order-pay=" . $order_id; |
|
| 464 | + if (strpos($redirectUrl, 'order-pay=')===false) {
|
|
| 465 | + $redirectUrl .= "&order-pay=".$order_id; |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | return array( |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | 'redirect' => $redirectUrl |
| 471 | 471 | ); |
| 472 | 472 | } catch (Exception $e) {
|
| 473 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error');
|
|
| 473 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error');
|
|
| 474 | 474 | |
| 475 | 475 | return array(); |
| 476 | 476 | } |
@@ -538,12 +538,12 @@ discard block |
||
| 538 | 538 | private function generateUrl($url) |
| 539 | 539 | {
|
| 540 | 540 | $parsed_url = parse_url($url); |
| 541 | - if ($parsed_url !== false) {
|
|
| 542 | - $parsed_url['query'] = ! isset($parsed_url['query']) ? '' : $parsed_url['query']; |
|
| 541 | + if ($parsed_url!==false) {
|
|
| 542 | + $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
|
| 543 | 543 | parse_str($parsed_url['query'], $arrayParams); |
| 544 | 544 | foreach ($arrayParams as $keyParam => $valueParam) {
|
| 545 | - if ($valueParam == '') {
|
|
| 546 | - $arrayParams[$keyParam] = '{{' . $keyParam . '}}';
|
|
| 545 | + if ($valueParam=='') {
|
|
| 546 | + $arrayParams[$keyParam] = '{{'.$keyParam.'}}';
|
|
| 547 | 547 | } |
| 548 | 548 | } |
| 549 | 549 | $parsed_url['query'] = http_build_query($arrayParams); |
@@ -589,10 +589,10 @@ discard block |
||
| 589 | 589 | */ |
| 590 | 590 | private function getKeysUrl($order, $url) |
| 591 | 591 | {
|
| 592 | - $defaultFields = (get_class($order) == 'WC_Order') ? array('order-received' => $order->get_id(), 'key' => $order->get_order_key()) : array();
|
|
| 592 | + $defaultFields = (get_class($order)=='WC_Order') ? array('order-received' => $order->get_id(), 'key' => $order->get_order_key()) : array();
|
|
| 593 | 593 | |
| 594 | 594 | $parsedUrl = parse_url($url); |
| 595 | - if ($parsedUrl !== false) {
|
|
| 595 | + if ($parsedUrl!==false) {
|
|
| 596 | 596 | //Replace parameters from url |
| 597 | 597 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
| 598 | 598 | |
@@ -659,14 +659,14 @@ discard block |
||
| 659 | 659 | */ |
| 660 | 660 | private function unparseUrl($parsed_url) |
| 661 | 661 | {
|
| 662 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
| 662 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
| 663 | 663 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
| 664 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
| 665 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
| 666 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
| 664 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
| 665 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
| 666 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
| 667 | 667 | $path = $parsed_url['path']; |
| 668 | 668 | |
| 669 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
| 669 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | /** |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
|
| 706 | 706 | )); |
| 707 | 707 | foreach ($customer_orders as $customer_order) {
|
| 708 | - if (trim($sign_up) == '' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) {
|
|
| 708 | + if (trim($sign_up)=='' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) {
|
|
| 709 | 709 | $sign_up = substr($customer_order->post_date, 0, 10); |
| 710 | 710 | } |
| 711 | 711 | } |
@@ -725,12 +725,12 @@ discard block |
||
| 725 | 725 | {
|
| 726 | 726 | global $wpdb; |
| 727 | 727 | $this->checkDbTable(); |
| 728 | - $tableName = $wpdb->prefix . self::ORDERS_TABLE; |
|
| 728 | + $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
|
| 729 | 729 | |
| 730 | 730 | //Check if id exists |
| 731 | 731 | $resultsSelect = $wpdb->get_results("select * from $tableName where id='$orderId'");
|
| 732 | 732 | $countResults = count($resultsSelect); |
| 733 | - if ($countResults == 0) {
|
|
| 733 | + if ($countResults==0) {
|
|
| 734 | 734 | $wpdb->insert($tableName, array('id' => $orderId, 'order_id' => $pagantisOrderId), array('%d', '%s'));
|
| 735 | 735 | } else {
|
| 736 | 736 | $wpdb->update($tableName, array('order_id' => $pagantisOrderId), array('id' => $orderId), array('%s'), array('%d'));
|
@@ -743,14 +743,14 @@ discard block |
||
| 743 | 743 | private function checkDbTable() |
| 744 | 744 | {
|
| 745 | 745 | global $wpdb; |
| 746 | - $tableName = $wpdb->prefix . self::ORDERS_TABLE; |
|
| 746 | + $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
|
| 747 | 747 | |
| 748 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 748 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 749 | 749 | $charset_collate = $wpdb->get_charset_collate(); |
| 750 | 750 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
| 751 | 751 | UNIQUE KEY id (id)) $charset_collate"; |
| 752 | 752 | |
| 753 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 753 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 754 | 754 | dbDelta($sql); |
| 755 | 755 | } |
| 756 | 756 | } |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | private function getExtraConfig() |
| 762 | 762 | {
|
| 763 | 763 | global $wpdb; |
| 764 | - $tableName = $wpdb->prefix . self::CONFIG_TABLE; |
|
| 764 | + $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
|
| 765 | 765 | $response = array(); |
| 766 | 766 | $dbResult = $wpdb->get_results("select config, value from $tableName", ARRAY_A);
|
| 767 | 767 | foreach ($dbResult as $value) {
|
@@ -778,9 +778,9 @@ discard block |
||
| 778 | 778 | */ |
| 779 | 779 | private function getNationalId($order) |
| 780 | 780 | {
|
| 781 | - foreach ((array)$order->get_meta_data() as $mdObject) {
|
|
| 781 | + foreach ((array) $order->get_meta_data() as $mdObject) {
|
|
| 782 | 782 | $data = $mdObject->get_data(); |
| 783 | - if ($data['key'] == 'vat_number') {
|
|
| 783 | + if ($data['key']=='vat_number') {
|
|
| 784 | 784 | return $data['value']; |
| 785 | 785 | } |
| 786 | 786 | } |
@@ -795,9 +795,9 @@ discard block |
||
| 795 | 795 | */ |
| 796 | 796 | private function getTaxId($order) |
| 797 | 797 | {
|
| 798 | - foreach ((array)$order->get_meta_data() as $mdObject) {
|
|
| 798 | + foreach ((array) $order->get_meta_data() as $mdObject) {
|
|
| 799 | 799 | $data = $mdObject->get_data(); |
| 800 | - if ($data['key'] == 'billing_cfpiva') {
|
|
| 800 | + if ($data['key']=='billing_cfpiva') {
|
|
| 801 | 801 | return $data['value']; |
| 802 | 802 | } |
| 803 | 803 | } |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | } else {
|
| 818 | 818 | $logEntry = $logEntry->info($message); |
| 819 | 819 | } |
| 820 | - $tableName = $wpdb->prefix . self::LOGS_TABLE; |
|
| 820 | + $tableName = $wpdb->prefix.self::LOGS_TABLE; |
|
| 821 | 821 | $wpdb->insert($tableName, array('log' => $logEntry->toJson()));
|
| 822 | 822 | } |
| 823 | 823 | |
@@ -827,12 +827,12 @@ discard block |
||
| 827 | 827 | private function checkDbLogTable() |
| 828 | 828 | {
|
| 829 | 829 | global $wpdb; |
| 830 | - $tableName = $wpdb->prefix . self::LOGS_TABLE; |
|
| 831 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 830 | + $tableName = $wpdb->prefix.self::LOGS_TABLE; |
|
| 831 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 832 | 832 | $charset_collate = $wpdb->get_charset_collate(); |
| 833 | 833 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
| 834 | 834 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
| 835 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 835 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 836 | 836 | dbDelta($sql); |
| 837 | 837 | } |
| 838 | 838 | |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | $metaProduct = get_post_meta($product_id); |
| 850 | 850 | |
| 851 | 851 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct)
|
| 852 | - && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
| 852 | + && $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
| 853 | 853 | } |
| 854 | 854 | |
| 855 | 855 | /** |
@@ -862,7 +862,7 @@ discard block |
||
| 862 | 862 | $promotedAmount = 0; |
| 863 | 863 | foreach ($items as $key => $item) {
|
| 864 | 864 | $promotedProduct = $this->isPromoted($item['product_id']); |
| 865 | - if ($promotedProduct == 'true') {
|
|
| 865 | + if ($promotedProduct=='true') {
|
|
| 866 | 866 | $promotedAmount += $item['line_total'] + $item['line_tax']; |
| 867 | 867 | } |
| 868 | 868 | } |