@@ -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 | ?> |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! defined('ABSPATH')) { |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | 4 | exit; |
5 | 5 | } |
6 | 6 | |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | { |
25 | 25 | $ajax_events = array('pagantis_checkout'); |
26 | 26 | foreach ($ajax_events as $ajax_event => $nopriv) { |
27 | - add_action('wp_ajax_woocommerce_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
27 | + add_action('wp_ajax_woocommerce_'.$ajax_event, array(__CLASS__, $ajax_event)); |
|
28 | 28 | if ($nopriv) { |
29 | 29 | add_action( |
30 | - 'wp_ajax_nopriv_woocommerce_' . $ajax_event, |
|
30 | + 'wp_ajax_nopriv_woocommerce_'.$ajax_event, |
|
31 | 31 | array(__CLASS__, $ajax_event) |
32 | 32 | ); |
33 | 33 | // WC AJAX can be used for frontend ajax requests. |
34 | - add_action('wc_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
34 | + add_action('wc_ajax_'.$ajax_event, array(__CLASS__, $ajax_event)); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | } |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | public function __construct() |
37 | 37 | { |
38 | 38 | |
39 | - require_once dirname(__FILE__) . '/../includes/class-wc-pagantis-config.php'; |
|
40 | - require_once dirname(__FILE__) . '/../includes/functions.php'; |
|
39 | + require_once dirname(__FILE__).'/../includes/class-wc-pagantis-config.php'; |
|
40 | + require_once dirname(__FILE__).'/../includes/functions.php'; |
|
41 | 41 | $this->settings = get_option('woocommerce_pagantis_settings'); |
42 | 42 | $this->extraConfig = WC_Pagantis_Config::getExtraConfig(); |
43 | 43 | $this->allowed_currencies = array('EUR'); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | if (!pg_wc_is_screen_correct()) { |
56 | 56 | return; |
57 | 57 | } |
58 | - if ($this->settings['enabled'] !== 'yes') { |
|
58 | + if ($this->settings['enabled']!=='yes') { |
|
59 | 59 | WC_Admin_Notices::add_custom_notice( |
60 | 60 | PAGANTIS_PLUGIN_ID, |
61 | 61 | sprintf( |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | ); |
67 | 67 | } |
68 | 68 | |
69 | - if ($this->settings['pagantis_public_key'] === '' xor $this->settings['pagantis_private_key'] === '' |
|
70 | - || $this->settings['enabled'] === 'yes' |
|
69 | + if ($this->settings['pagantis_public_key']==='' xor $this->settings['pagantis_private_key']==='' |
|
70 | + || $this->settings['enabled']==='yes' |
|
71 | 71 | ) { |
72 | 72 | WC_Admin_Notices::add_custom_notice( |
73 | 73 | PAGANTIS_PLUGIN_ID.'keys_setup', |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | |
83 | - if ($this->settings['pagantis_public_key'] === '' xor $this->settings['pagantis_private_key'] === '') { |
|
83 | + if ($this->settings['pagantis_public_key']==='' xor $this->settings['pagantis_private_key']==='') { |
|
84 | 84 | WC_Admin_Notices::add_custom_notice( |
85 | 85 | PAGANTIS_PLUGIN_ID, |
86 | 86 | sprintf( |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | ); |
92 | 92 | } |
93 | 93 | |
94 | - if ($this->settings['pagantis_public_key'] === '' || $this->settings['pagantis_private_key'] === '') { |
|
94 | + if ($this->settings['pagantis_public_key']==='' || $this->settings['pagantis_private_key']==='') { |
|
95 | 95 | WC_Admin_Notices::add_custom_notice( |
96 | 96 | PAGANTIS_PLUGIN_ID.'keys_error', |
97 | 97 | sprintf( |
@@ -102,15 +102,15 @@ discard block |
||
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
105 | - if ($this->settings['pagantis_public_key'] !== '' xor $this->settings['pagantis_private_key'] !== '') { |
|
105 | + if ($this->settings['pagantis_public_key']!=='' xor $this->settings['pagantis_private_key']!=='') { |
|
106 | 106 | WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID.'keys_setup'); |
107 | 107 | } |
108 | 108 | |
109 | - if ($this->settings['pagantis_public_key'] !== '' || $this->settings['pagantis_private_key'] !== '') { |
|
109 | + if ($this->settings['pagantis_public_key']!=='' || $this->settings['pagantis_private_key']!=='') { |
|
110 | 110 | WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID.'keys_error'); |
111 | 111 | } |
112 | 112 | |
113 | - if (! in_array(get_woocommerce_currency(), $this->allowed_currencies, true)) { |
|
113 | + if (!in_array(get_woocommerce_currency(), $this->allowed_currencies, true)) { |
|
114 | 114 | WC_Admin_Settings::add_error(__('Error: Pagantis only can be used in Euros.', 'pagantis')); |
115 | 115 | $this->settings['enabled'] = 'no'; |
116 | 116 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | include_once('class-wc-pagantis-logger.php'); |
17 | 17 | $config = self::getExtraConfig(); |
18 | 18 | $value = $config[$key]; |
19 | - if ($unSerialized === true) { |
|
19 | + if ($unSerialized===true) { |
|
20 | 20 | return unserialize($value); |
21 | 21 | } else { |
22 | 22 | return $value; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | public static function getExtraConfig() |
63 | 63 | { |
64 | 64 | global $wpdb; |
65 | - $tableName = $wpdb->prefix . PAGANTIS_CONFIG_TABLE; |
|
65 | + $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE; |
|
66 | 66 | $response = array(); |
67 | 67 | $dbResult = $wpdb->get_results("select config, value from $tableName", ARRAY_A); |
68 | 68 | foreach ($dbResult as $value) { |
@@ -3,12 +3,12 @@ discard block |
||
3 | 3 | |
4 | 4 | use Pagantis\ModuleUtils\Model\Log\LogEntry; |
5 | 5 | |
6 | -require_once dirname(__FILE__) . '/class-wc-pagantis-config.php'; |
|
6 | +require_once dirname(__FILE__).'/class-wc-pagantis-config.php'; |
|
7 | 7 | |
8 | 8 | function pg_areKeysSet() |
9 | 9 | { |
10 | 10 | $settings = pg_get_plugin_settings(); |
11 | - if ($settings['pagantis_public_key'] == '' || $settings['pagantis_private_key'] == '') { |
|
11 | + if ($settings['pagantis_public_key']=='' || $settings['pagantis_private_key']=='') { |
|
12 | 12 | return false; |
13 | 13 | } |
14 | 14 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | { |
20 | 20 | $settings = pg_get_plugin_settings(); |
21 | 21 | |
22 | - if ($settings['simulator'] !== 'yes') { |
|
22 | + if ($settings['simulator']!=='yes') { |
|
23 | 23 | WC_Admin_Settings::add_error(__('Error: PG Simulator is not enabled', 'pagantis')); |
24 | 24 | |
25 | 25 | return false; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $allowedCountries = WC_Pagantis_Config::getAllowedCountriesSerialized(); |
35 | 35 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
36 | 36 | |
37 | - if (! $allowedCountry) { |
|
37 | + if (!$allowedCountry) { |
|
38 | 38 | return false; |
39 | 39 | } |
40 | 40 | |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | $minAmount = WC_Pagantis_Config::getValueOfKey('PAGANTIS_DISPLAY_MIN_AMOUNT'); |
51 | 51 | $maxAmount = WC_Pagantis_Config::getValueOfKey('PAGANTIS_DISPLAY_MAX_AMOUNT'); |
52 | 52 | $totalPrice = $product->get_price(); |
53 | - $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount == '0')); |
|
54 | - if (! $validAmount) { |
|
53 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
54 | + if (!$validAmount) { |
|
55 | 55 | return false; |
56 | 56 | } |
57 | 57 | |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | $minAmount = WC_Pagantis_Config::getValueOfKey('PAGANTIS_DISPLAY_MIN_AMOUNT'); |
84 | 84 | $maxAmount = WC_Pagantis_Config::getValueOfKey('PAGANTIS_DISPLAY_MAX_AMOUNT'); |
85 | 85 | $totalPrice = $product->get_price(); |
86 | - $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount == '0')); |
|
87 | - if ($settings['enabled'] !== 'yes' || pg_areKeysSet() || pg_isSimulatorSettingEnabled() |
|
88 | - || ! pg_IsCountryAllowed() |
|
89 | - || ! pg_IsAmountValid() |
|
86 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
87 | + if ($settings['enabled']!=='yes' || pg_areKeysSet() || pg_isSimulatorSettingEnabled() |
|
88 | + || !pg_IsCountryAllowed() |
|
89 | + || !pg_IsAmountValid() |
|
90 | 90 | ) { |
91 | 91 | return; |
92 | 92 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $metaProduct = get_post_meta($product_id); |
103 | 103 | |
104 | 104 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) |
105 | - && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
105 | + && $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | */ |
125 | 125 | function preparePriceSelector($css_price_selector) |
126 | 126 | { |
127 | - if ($css_price_selector === 'default' || $css_price_selector === '') { |
|
128 | - $css_price_selector === $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
|
129 | - } elseif (! unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
|
127 | + if ($css_price_selector==='default' || $css_price_selector==='') { |
|
128 | + $css_price_selector===$this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
|
129 | + } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
|
130 | 130 | $css_price_selector = serialize(array($css_price_selector)); |
131 | 131 | } |
132 | 132 | |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | function pg_wc_is_screen_correct() |
137 | 137 | { |
138 | 138 | $current_screen = get_current_screen(); |
139 | - if ('shop_order' === $current_screen->id || 'plugins' === $current_screen->id |
|
140 | - || 'woocommerce_page_wc-settings' === $current_screen->id |
|
139 | + if ('shop_order'===$current_screen->id || 'plugins'===$current_screen->id |
|
140 | + || 'woocommerce_page_wc-settings'===$current_screen->id |
|
141 | 141 | ) { |
142 | 142 | return true; |
143 | 143 | } |
@@ -157,12 +157,12 @@ discard block |
||
157 | 157 | function pg_wc_check_db_log_table() |
158 | 158 | { |
159 | 159 | global $wpdb; |
160 | - $tableName = $wpdb->prefix . PAGANTIS_LOGS_TABLE; |
|
161 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") !== $tableName) { |
|
160 | + $tableName = $wpdb->prefix.PAGANTIS_LOGS_TABLE; |
|
161 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!==$tableName) { |
|
162 | 162 | $charset_collate = $wpdb->get_charset_collate(); |
163 | 163 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
164 | 164 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
165 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
165 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
166 | 166 | dbDelta($sql); |
167 | 167 | } |
168 | 168 | |
@@ -180,5 +180,5 @@ discard block |
||
180 | 180 | { |
181 | 181 | $shop_page = wc_get_page_permalink('shop'); |
182 | 182 | |
183 | - return (is_ssl() && 'https' === substr($shop_page, 0, 5)); |
|
183 | + return (is_ssl() && 'https'===substr($shop_page, 0, 5)); |
|
184 | 184 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public static function writeLog($message, $start_time = null, $end_time = null) |
24 | 24 | { |
25 | - if (! class_exists('WC_Logger')) { |
|
25 | + if (!class_exists('WC_Logger')) { |
|
26 | 26 | return; |
27 | 27 | } |
28 | 28 | |
@@ -31,31 +31,31 @@ discard block |
||
31 | 31 | self::$logger = wc_get_logger(); |
32 | 32 | } |
33 | 33 | |
34 | - $isDebugLogEnabled = 'yes' === WC_Admin_Settings::get_option('debug', 'no'); |
|
34 | + $isDebugLogEnabled = 'yes'===WC_Admin_Settings::get_option('debug', 'no'); |
|
35 | 35 | $settings = get_option('woocommerce_pagantis_settings'); |
36 | 36 | |
37 | 37 | if (empty($settings) || isset($settings['debug']) && $isDebugLogEnabled) { |
38 | 38 | return; |
39 | 39 | } |
40 | 40 | |
41 | - if (! is_null($start_time)) { |
|
42 | - $formatted_start_time = date_i18n(get_option('date_format') . ' g:ia', $start_time); |
|
41 | + if (!is_null($start_time)) { |
|
42 | + $formatted_start_time = date_i18n(get_option('date_format').' g:ia', $start_time); |
|
43 | 43 | $end_time = is_null($end_time) ? current_time('timestamp') : $end_time; |
44 | - $formatted_end_time = date_i18n(get_option('date_format') . ' g:ia', $end_time); |
|
44 | + $formatted_end_time = date_i18n(get_option('date_format').' g:ia', $end_time); |
|
45 | 45 | $elapsed_time = round(abs($end_time - $start_time) / 60, 2); |
46 | 46 | |
47 | - $log_entry = "\n" . '====Pagantis Version: ' . PAGANTIS_VERSION . '====' . "\n"; |
|
48 | - $log_entry .= '====Start Log ' . $formatted_start_time . '====' . "\n" . $message . "\n"; |
|
49 | - $log_entry .= '====End Log ' . $formatted_end_time . ' (' . $elapsed_time . ')====' . "\n\n"; |
|
47 | + $log_entry = "\n".'====Pagantis Version: '.PAGANTIS_VERSION.'===='."\n"; |
|
48 | + $log_entry .= '====Start Log '.$formatted_start_time.'===='."\n".$message."\n"; |
|
49 | + $log_entry .= '====End Log '.$formatted_end_time.' ('.$elapsed_time.')===='."\n\n"; |
|
50 | 50 | } else { |
51 | - $log_entry = "\n" . '====Pagantis Version: ' . PAGANTIS_VERSION . '====' . "\n"; |
|
52 | - $log_entry .= '====Start Log====' . "\n" . $message . "\n" . '====End Log====' . "\n\n"; |
|
51 | + $log_entry = "\n".'====Pagantis Version: '.PAGANTIS_VERSION.'===='."\n"; |
|
52 | + $log_entry .= '====Start Log===='."\n".$message."\n".'====End Log===='."\n\n"; |
|
53 | 53 | } |
54 | 54 | if (defined('WP_DEBUG') && WP_DEBUG) { |
55 | 55 | error_log($log_entry); |
56 | 56 | } |
57 | 57 | print_r($log_entry); |
58 | - self::$logger->debug($log_entry, array( 'source' => self::WC_LOG_FILENAME )); |
|
58 | + self::$logger->debug($log_entry, array('source' => self::WC_LOG_FILENAME)); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | } else { |
88 | 88 | $logEntry = $logEntry->info($message); |
89 | 89 | } |
90 | - $tableName = $wpdb->prefix . PAGANTIS_LOGS_TABLE; |
|
90 | + $tableName = $wpdb->prefix.PAGANTIS_LOGS_TABLE; |
|
91 | 91 | $wpdb->insert($tableName, array('log' => $logEntry->toJson())); |
92 | 92 | } |
93 | 93 | } |
@@ -241,17 +241,17 @@ discard block |
||
241 | 241 | ->setAddress($shippingAddress['address_1'] . ' ' . $shippingAddress['address_2']); |
242 | 242 | $orderShippingAddress = new Address(); |
243 | 243 | $orderShippingAddress->setZipCode($shippingAddress['postcode'])->setFullName($shippingAddress['first_name'] |
244 | - . ' ' |
|
244 | + . ' ' |
|
245 | 245 | . $shippingAddress['last_name']) |
246 | 246 | ->setCountryCode($shippingAddress['country'] !== '' |
247 | 247 | ? strtoupper($shippingAddress['country']) : strtoupper($this->language)) |
248 | 248 | ->setCity($shippingAddress['city'])->setAddress($shippingAddress['address_1'] . ' ' |
249 | 249 | . $shippingAddress['address_2']) |
250 | - ->setFixPhone($shippingAddress['phone'])->setMobilePhone($shippingAddress['phone']) |
|
251 | - ->setNationalId($national_id)->setTaxId($tax_id); |
|
250 | + ->setFixPhone($shippingAddress['phone'])->setMobilePhone($shippingAddress['phone']) |
|
251 | + ->setNationalId($national_id)->setTaxId($tax_id); |
|
252 | 252 | $orderBillingAddress = new Address(); |
253 | 253 | $orderBillingAddress->setZipCode($billingAddress['postcode'])->setFullName($billingAddress['first_name'] |
254 | - . ' ' |
|
254 | + . ' ' |
|
255 | 255 | . $billingAddress['last_name']) |
256 | 256 | ->setCountryCode($billingAddress['country'] !== '' |
257 | 257 | ? strtoupper($billingAddress['country']) : strtoupper($this->language)) |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | $orderUser = new User(); |
263 | 263 | $orderUser->setAddress($userAddress)->setFullName($billingAddress['first_name'] . ' ' |
264 | 264 | . $billingAddress['last_name']) |
265 | - ->setBillingAddress($orderBillingAddress)->setEmail($billingAddress['email']) |
|
266 | - ->setFixPhone($billingAddress['phone'])->setMobilePhone($billingAddress['phone']) |
|
267 | - ->setShippingAddress($orderShippingAddress)->setNationalId($national_id)->setTaxId($tax_id); |
|
265 | + ->setBillingAddress($orderBillingAddress)->setEmail($billingAddress['email']) |
|
266 | + ->setFixPhone($billingAddress['phone'])->setMobilePhone($billingAddress['phone']) |
|
267 | + ->setShippingAddress($orderShippingAddress)->setNationalId($national_id)->setTaxId($tax_id); |
|
268 | 268 | |
269 | 269 | $previousOrders = $this->getOrders($order->get_user(), $billingAddress['email']); |
270 | 270 | foreach ($previousOrders as $previousOrder) { |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $orderElement = wc_get_order($previousOrder); |
273 | 273 | $orderCreated = $orderElement->get_date_created(); |
274 | 274 | $orderHistory->setAmount(intval(100 * $orderElement->get_total())) |
275 | - ->setDate(new \DateTime($orderCreated->date('Y-m-d H:i:s'))); |
|
275 | + ->setDate(new \DateTime($orderCreated->date('Y-m-d H:i:s'))); |
|
276 | 276 | $orderUser->addOrderHistory($orderHistory); |
277 | 277 | } |
278 | 278 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | |
322 | 322 | $orderShoppingCart = new ShoppingCart(); |
323 | 323 | $orderShoppingCart->setDetails($details)->setOrderReference($order->get_id()) |
324 | - ->setPromotedAmount($promotedAmount)->setTotalAmount(intval(strval(100 * $order->total))); |
|
324 | + ->setPromotedAmount($promotedAmount)->setTotalAmount(intval(strval(100 * $order->total))); |
|
325 | 325 | $orderConfigurationUrls = new Urls(); |
326 | 326 | $cancelUrl = $this->getKoUrl($order); |
327 | 327 | $callback_arg = array( |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | $callback_url_notif = add_query_arg($callback_arg_notif, home_url('/')); |
341 | 341 | |
342 | 342 | $orderConfigurationUrls->setCancel($cancelUrl)->setKo($callback_url_user) |
343 | - ->setAuthorizedNotificationCallback($callback_url_notif) |
|
344 | - ->setRejectedNotificationCallback(null)->setOk($callback_url_user); |
|
343 | + ->setAuthorizedNotificationCallback($callback_url_notif) |
|
344 | + ->setRejectedNotificationCallback(null)->setOk($callback_url_user); |
|
345 | 345 | $orderChannel = new Channel(); |
346 | 346 | $orderChannel->setAssistedSale(false)->setType(Channel::ONLINE); |
347 | 347 | |
@@ -355,11 +355,11 @@ discard block |
||
355 | 355 | |
356 | 356 | $orderConfiguration = new Configuration(); |
357 | 357 | $orderConfiguration->setChannel($orderChannel)->setUrls($orderConfigurationUrls) |
358 | - ->setPurchaseCountry($purchaseCountry); |
|
358 | + ->setPurchaseCountry($purchaseCountry); |
|
359 | 359 | |
360 | 360 | $orderApiClient = new Order(); |
361 | 361 | $orderApiClient->setConfiguration($orderConfiguration)->setMetadata($metadataOrder) |
362 | - ->setShoppingCart($orderShoppingCart)->setUser($orderUser); |
|
362 | + ->setShoppingCart($orderShoppingCart)->setUser($orderUser); |
|
363 | 363 | |
364 | 364 | if ($this->pagantis_public_key === '' || $this->pagantis_private_key === '') { |
365 | 365 | throw new \Exception('Public and Secret Key not found'); |
@@ -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,19 +54,19 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function __construct() |
56 | 56 | { |
57 | - require_once dirname(__FILE__) . '/../includes/class-wc-pagantis-config.php'; |
|
58 | - require_once dirname(__FILE__) . '/../includes/class-wc-pagantis-logger.php'; |
|
59 | - require_once dirname(__FILE__) . '/../includes/functions.php'; |
|
57 | + require_once dirname(__FILE__).'/../includes/class-wc-pagantis-config.php'; |
|
58 | + require_once dirname(__FILE__).'/../includes/class-wc-pagantis-logger.php'; |
|
59 | + require_once dirname(__FILE__).'/../includes/functions.php'; |
|
60 | 60 | //Mandatory vars for plugin |
61 | 61 | $this->id = PAGANTIS_PLUGIN_ID; |
62 | 62 | $this->has_fields = true; |
63 | 63 | $this->method_title = ucfirst($this->id); |
64 | 64 | //Useful vars |
65 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/'; |
|
65 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/'; |
|
66 | 66 | |
67 | 67 | $this->allowed_currencies = array('EUR'); |
68 | 68 | $this->language = strstr(get_locale(), '_', true); |
69 | - if ($this->language === '') { |
|
69 | + if ($this->language==='') { |
|
70 | 70 | $this->language = 'ES'; |
71 | 71 | } |
72 | 72 | $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
@@ -84,18 +84,18 @@ discard block |
||
84 | 84 | $this->set_payment_urls(); |
85 | 85 | //Hooks |
86 | 86 | add_action( |
87 | - 'woocommerce_update_options_payment_gateways_' . $this->id, |
|
87 | + 'woocommerce_update_options_payment_gateways_'.$this->id, |
|
88 | 88 | array($this, 'process_admin_options') |
89 | 89 | ); //Save plugin options |
90 | 90 | add_action( |
91 | 91 | 'admin_notices', |
92 | 92 | array($this, 'check_plugin_settings') |
93 | - ); //Check config fields |
|
93 | + ); //Check config fields |
|
94 | 94 | add_action( |
95 | - 'woocommerce_receipt_' . $this->id, |
|
95 | + 'woocommerce_receipt_'.$this->id, |
|
96 | 96 | array($this, 'get_wc_order_received_page') |
97 | - ); //Pagantis form |
|
98 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
97 | + ); //Pagantis form |
|
98 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
99 | 99 | add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3); |
100 | 100 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
101 | 101 | //add_action('wp_enqueue_scripts', array($this, 'enqueue_ajax_scripts')); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | public function enqueue_ajax_scripts() |
105 | 105 | { |
106 | - if ($this->enabled !== 'yes' || ! is_checkout() || is_order_received_page() |
|
106 | + if ($this->enabled!=='yes' || !is_checkout() || is_order_received_page() |
|
107 | 107 | || is_wc_endpoint_url('order-pay') |
108 | 108 | ) { |
109 | 109 | return; |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function loadPagantisTranslation($mofile, $domain) |
140 | 140 | { |
141 | - if ('pagantis' === $domain) { |
|
142 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
141 | + if ('pagantis'===$domain) { |
|
142 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | return $mofile; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function init_form_fields() |
154 | 154 | { |
155 | - $this->form_fields = include(plugin_dir_path(__FILE__) . '../includes/settings-pagantis.php'); |
|
155 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /*********** |
@@ -168,13 +168,13 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function check_plugin_settings() |
170 | 170 | { |
171 | - if (! pg_wc_is_screen_correct()) { |
|
171 | + if (!pg_wc_is_screen_correct()) { |
|
172 | 172 | return; |
173 | 173 | } |
174 | 174 | |
175 | - if ($this->settings['enabled'] !== 'yes') { |
|
175 | + if ($this->settings['enabled']!=='yes') { |
|
176 | 176 | WC_Admin_Notices::add_custom_notice( |
177 | - PAGANTIS_PLUGIN_ID . 'first_setup', |
|
177 | + PAGANTIS_PLUGIN_ID.'first_setup', |
|
178 | 178 | sprintf(// translators: 1: URL to WP plugin page. |
179 | 179 | __( |
180 | 180 | 'Activate Pagantis to start offering comfortable payments in installments to your clients. <a class="button button-primary" href="%1$s">Activate Pagantis now!</a>', |
@@ -184,15 +184,15 @@ discard block |
||
184 | 184 | ) |
185 | 185 | ); |
186 | 186 | } |
187 | - if (WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID . 'first_setup') && $this->settings['enabled'] === 'yes') { |
|
188 | - WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID . 'first_setup'); |
|
187 | + if (WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID.'first_setup') && $this->settings['enabled']==='yes') { |
|
188 | + WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID.'first_setup'); |
|
189 | 189 | } |
190 | 190 | |
191 | - if ($this->settings['pagantis_public_key'] === '' xor $this->settings['pagantis_private_key'] === '' |
|
192 | - && $this->settings['enabled'] === 'yes' |
|
191 | + if ($this->settings['pagantis_public_key']==='' xor $this->settings['pagantis_private_key']==='' |
|
192 | + && $this->settings['enabled']==='yes' |
|
193 | 193 | ) { |
194 | 194 | WC_Admin_Notices::add_custom_notice( |
195 | - PAGANTIS_PLUGIN_ID . 'keys_setup', |
|
195 | + PAGANTIS_PLUGIN_ID.'keys_setup', |
|
196 | 196 | sprintf(// translators: 1: URL to WP plugin page. |
197 | 197 | __( |
198 | 198 | 'Set your Pagantis merchant keys to start offering comfortable payments in installments <a class="button button-primary" href="%1$s">Go to keys setup</a></p>', |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | ); |
204 | 204 | } |
205 | 205 | |
206 | - if ($this->settings['pagantis_public_key'] === '' xor $this->settings['pagantis_private_key'] === '' |
|
207 | - || $this->settings['enabled'] === 'yes' |
|
206 | + if ($this->settings['pagantis_public_key']==='' xor $this->settings['pagantis_private_key']==='' |
|
207 | + || $this->settings['enabled']==='yes' |
|
208 | 208 | ) { |
209 | 209 | WC_Admin_Notices::add_custom_notice( |
210 | - PAGANTIS_PLUGIN_ID . 'keys_check', |
|
210 | + PAGANTIS_PLUGIN_ID.'keys_check', |
|
211 | 211 | sprintf(// translators: 1: URL to WP plugin page. |
212 | 212 | __( |
213 | 213 | 'Set your Pagantis merchant Api keys to start offering comfortable payments in installments. <a class="button button-primary" href="%1$s">Go to keys setup</a>', |
@@ -218,11 +218,11 @@ discard block |
||
218 | 218 | ); |
219 | 219 | } |
220 | 220 | |
221 | - if ($this->settings['pagantis_public_key'] !== '' && $this->settings['pagantis_private_key'] !== '' |
|
222 | - || $this->settings['enabled'] === 'no' |
|
221 | + if ($this->settings['pagantis_public_key']!=='' && $this->settings['pagantis_private_key']!=='' |
|
222 | + || $this->settings['enabled']==='no' |
|
223 | 223 | ) { |
224 | 224 | WC_Admin_Notices::add_custom_notice( |
225 | - PAGANTIS_PLUGIN_ID . 'finish_setup', |
|
225 | + PAGANTIS_PLUGIN_ID.'finish_setup', |
|
226 | 226 | sprintf(// translators: 1: URL to WP plugin page. |
227 | 227 | __( |
228 | 228 | 'It seems that your merchant keys are setup but the plugin is not active Activate the Pagantis plugin to start offering comfortable payments in installments to your clients. <a class="button button-primary" href="%1$s">Go to Pagantis settings</a>', |
@@ -232,32 +232,32 @@ discard block |
||
232 | 232 | ) |
233 | 233 | ); |
234 | 234 | } |
235 | - if (WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID . 'keys_check' |
|
236 | - && $this->settings['pagantis_public_key'] !== '' |
|
237 | - && $this->settings['pagantis_private_key'] !== '' |
|
238 | - && $this->settings['enabled'] === 'yes') |
|
235 | + if (WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID.'keys_check' |
|
236 | + && $this->settings['pagantis_public_key']!=='' |
|
237 | + && $this->settings['pagantis_private_key']!=='' |
|
238 | + && $this->settings['enabled']==='yes') |
|
239 | 239 | ) { |
240 | - WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID . 'keys_setup'); |
|
240 | + WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID.'keys_setup'); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
244 | - if (WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID . 'first_setup' |
|
245 | - && $this->settings['pagantis_public_key'] === '' |
|
246 | - && $this->settings['pagantis_private_key'] === '') |
|
244 | + if (WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID.'first_setup' |
|
245 | + && $this->settings['pagantis_public_key']==='' |
|
246 | + && $this->settings['pagantis_private_key']==='') |
|
247 | 247 | ) { |
248 | - WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID . 'keys_setup'); |
|
248 | + WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID.'keys_setup'); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | |
252 | - if (WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID . 'keys_check') xor WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID . 'first_setup') |
|
253 | - && $this->settings['pagantis_public_key'] !== '' |
|
254 | - || $this->settings['pagantis_private_key'] !== '' |
|
252 | + if (WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID.'keys_check') xor WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID.'first_setup') |
|
253 | + && $this->settings['pagantis_public_key']!=='' |
|
254 | + || $this->settings['pagantis_private_key']!=='' |
|
255 | 255 | ) { |
256 | - WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID . 'first_setup'); |
|
257 | - WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID . 'keys_check'); |
|
256 | + WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID.'first_setup'); |
|
257 | + WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID.'keys_check'); |
|
258 | 258 | } |
259 | 259 | |
260 | - if (! in_array(get_woocommerce_currency(), $this->allowed_currencies, true)) { |
|
260 | + if (!in_array(get_woocommerce_currency(), $this->allowed_currencies, true)) { |
|
261 | 261 | WC_Admin_Settings::add_error(__('Error: Pagantis only can be used in Euros.', 'pagantis')); |
262 | 262 | $this->settings['enabled'] = 'no'; |
263 | 263 | } |
@@ -344,19 +344,19 @@ discard block |
||
344 | 344 | public function get_wc_order_received_page($order_id) |
345 | 345 | { |
346 | 346 | try { |
347 | - require_once(__ROOT__ . '/vendor/autoload.php'); |
|
347 | + require_once(__ROOT__.'/vendor/autoload.php'); |
|
348 | 348 | global $woocommerce; |
349 | 349 | $order = wc_get_order($order_id); |
350 | 350 | $order->set_payment_method(ucfirst($this->id)); |
351 | 351 | $order->save(); |
352 | 352 | |
353 | - if (! isset($order)) { |
|
353 | + if (!isset($order)) { |
|
354 | 354 | throw new Exception(__('Order not found', 'pagantis')); |
355 | 355 | } |
356 | 356 | |
357 | 357 | $shippingAddress = $order->get_address('shipping'); |
358 | 358 | $billingAddress = $order->get_address('billing'); |
359 | - if ($shippingAddress['address_1'] === '') { |
|
359 | + if ($shippingAddress['address_1']==='') { |
|
360 | 360 | $shippingAddress = $billingAddress; |
361 | 361 | } |
362 | 362 | |
@@ -364,18 +364,18 @@ discard block |
||
364 | 364 | $tax_id = $this->getTaxId($order); |
365 | 365 | |
366 | 366 | $userAddress = new Address(); |
367 | - $userAddress->setZipCode($shippingAddress['postcode'])->setFullName($shippingAddress['first_name'] . ' ' |
|
367 | + $userAddress->setZipCode($shippingAddress['postcode'])->setFullName($shippingAddress['first_name'].' ' |
|
368 | 368 | . $shippingAddress['last_name']) |
369 | - ->setCountryCode($shippingAddress['country'] !== '' ? strtoupper($shippingAddress['country']) |
|
369 | + ->setCountryCode($shippingAddress['country']!=='' ? strtoupper($shippingAddress['country']) |
|
370 | 370 | : strtoupper($this->language))->setCity($shippingAddress['city']) |
371 | - ->setAddress($shippingAddress['address_1'] . ' ' . $shippingAddress['address_2']); |
|
371 | + ->setAddress($shippingAddress['address_1'].' '.$shippingAddress['address_2']); |
|
372 | 372 | $orderShippingAddress = new Address(); |
373 | 373 | $orderShippingAddress->setZipCode($shippingAddress['postcode'])->setFullName($shippingAddress['first_name'] |
374 | 374 | . ' ' |
375 | 375 | . $shippingAddress['last_name']) |
376 | - ->setCountryCode($shippingAddress['country'] !== '' |
|
376 | + ->setCountryCode($shippingAddress['country']!=='' |
|
377 | 377 | ? strtoupper($shippingAddress['country']) : strtoupper($this->language)) |
378 | - ->setCity($shippingAddress['city'])->setAddress($shippingAddress['address_1'] . ' ' |
|
378 | + ->setCity($shippingAddress['city'])->setAddress($shippingAddress['address_1'].' ' |
|
379 | 379 | . $shippingAddress['address_2']) |
380 | 380 | ->setFixPhone($shippingAddress['phone'])->setMobilePhone($shippingAddress['phone']) |
381 | 381 | ->setNationalId($national_id)->setTaxId($tax_id); |
@@ -383,14 +383,14 @@ discard block |
||
383 | 383 | $orderBillingAddress->setZipCode($billingAddress['postcode'])->setFullName($billingAddress['first_name'] |
384 | 384 | . ' ' |
385 | 385 | . $billingAddress['last_name']) |
386 | - ->setCountryCode($billingAddress['country'] !== '' |
|
386 | + ->setCountryCode($billingAddress['country']!=='' |
|
387 | 387 | ? strtoupper($billingAddress['country']) : strtoupper($this->language)) |
388 | - ->setCity($billingAddress['city'])->setAddress($billingAddress['address_1'] . ' ' |
|
388 | + ->setCity($billingAddress['city'])->setAddress($billingAddress['address_1'].' ' |
|
389 | 389 | . $billingAddress['address_2']) |
390 | 390 | ->setFixPhone($billingAddress['phone'])->setMobilePhone($billingAddress['phone']) |
391 | 391 | ->setNationalId($national_id)->setTaxId($tax_id); |
392 | 392 | $orderUser = new User(); |
393 | - $orderUser->setAddress($userAddress)->setFullName($billingAddress['first_name'] . ' ' |
|
393 | + $orderUser->setAddress($userAddress)->setFullName($billingAddress['first_name'].' ' |
|
394 | 394 | . $billingAddress['last_name']) |
395 | 395 | ->setBillingAddress($orderBillingAddress)->setEmail($billingAddress['email']) |
396 | 396 | ->setFixPhone($billingAddress['phone'])->setMobilePhone($billingAddress['phone']) |
@@ -439,11 +439,11 @@ discard block |
||
439 | 439 | $details->addProduct($product); |
440 | 440 | |
441 | 441 | $promotedProduct = $this->isPromoted($item->get_product_id()); |
442 | - if ($promotedProduct === 'true') { |
|
442 | + if ($promotedProduct==='true') { |
|
443 | 443 | $promotedAmount += $product->getAmount(); |
444 | 444 | $promotedMessage = |
445 | - 'Promoted Item: ' . $wcProduct->get_name() . ' - Price: ' . $item->get_total() . ' - Qty: ' |
|
446 | - . $product->getQuantity() . ' - Item ID: ' . $item['id_product']; |
|
445 | + 'Promoted Item: '.$wcProduct->get_name().' - Price: '.$item->get_total().' - Qty: ' |
|
446 | + . $product->getQuantity().' - Item ID: '.$item['id_product']; |
|
447 | 447 | $promotedMessage = substr($promotedMessage, 0, 999); |
448 | 448 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
449 | 449 | } |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | $orderApiClient->setConfiguration($orderConfiguration)->setMetadata($metadataOrder) |
494 | 494 | ->setShoppingCart($orderShoppingCart)->setUser($orderUser); |
495 | 495 | |
496 | - if ($this->pagantis_public_key === '' || $this->pagantis_private_key === '') { |
|
496 | + if ($this->pagantis_public_key==='' || $this->pagantis_private_key==='') { |
|
497 | 497 | throw new \Exception('Public and Secret Key not found'); |
498 | 498 | } |
499 | 499 | $orderClient = new Client($this->pagantis_public_key, $this->pagantis_private_key); |
@@ -505,9 +505,9 @@ discard block |
||
505 | 505 | throw new OrderNotFoundException(); |
506 | 506 | } |
507 | 507 | |
508 | - if ($url === '') { |
|
508 | + if ($url==='') { |
|
509 | 509 | throw new Exception(__('No ha sido posible obtener una respuesta de Pagantis', 'pagantis')); |
510 | - } elseif ($this->extraConfig['PAGANTIS_FORM_DISPLAY_TYPE'] === '0') { |
|
510 | + } elseif ($this->extraConfig['PAGANTIS_FORM_DISPLAY_TYPE']==='0') { |
|
511 | 511 | wp_redirect($url); |
512 | 512 | exit; |
513 | 513 | } else { |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | wc_get_template('iframe.php', $template_fields, '', $this->template_path); |
519 | 519 | } |
520 | 520 | } catch (\Exception $exception) { |
521 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); |
|
521 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); |
|
522 | 522 | WC_Pagantis_Logger::insert_log_entry_in_wpdb($exception); |
523 | 523 | $checkout_url = get_permalink(wc_get_page_id('checkout')); |
524 | 524 | wp_redirect($checkout_url); |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | public function pagantisNotification() |
533 | 533 | { |
534 | 534 | try { |
535 | - $origin = ($_SERVER['REQUEST_METHOD'] === 'POST') ? 'Notify' : 'Order'; |
|
535 | + $origin = ($_SERVER['REQUEST_METHOD']==='POST') ? 'Notify' : 'Order'; |
|
536 | 536 | |
537 | 537 | include_once('class-pg-notification-handler.php'); |
538 | 538 | $notify = new WC_PG_Notification_Handler(); |
@@ -575,10 +575,10 @@ discard block |
||
575 | 575 | */ |
576 | 576 | public function pagantisCompleteStatus($status, $order_id, $order) |
577 | 577 | { |
578 | - if ($order->get_payment_method() === PAGANTIS_PLUGIN_ID) { |
|
579 | - if ($order->get_status() === 'failed') { |
|
578 | + if ($order->get_payment_method()===PAGANTIS_PLUGIN_ID) { |
|
579 | + if ($order->get_status()==='failed') { |
|
580 | 580 | $status = 'processing'; |
581 | - } elseif ($order->get_status() === 'pending' && $status === 'completed') { |
|
581 | + } elseif ($order->get_status()==='pending' && $status==='completed') { |
|
582 | 582 | $status = 'processing'; |
583 | 583 | } |
584 | 584 | } |
@@ -603,8 +603,8 @@ discard block |
||
603 | 603 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
604 | 604 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
605 | 605 | $totalPrice = (int) $this->get_order_total(); |
606 | - $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount === '0')); |
|
607 | - if ($this->enabled === 'yes' && $this->pagantis_public_key !== '' && $this->pagantis_private_key !== '' |
|
606 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount==='0')); |
|
607 | + if ($this->enabled==='yes' && $this->pagantis_public_key!=='' && $this->pagantis_private_key!=='' |
|
608 | 608 | && $validAmount |
609 | 609 | && $allowedCountry |
610 | 610 | ) { |
@@ -637,8 +637,8 @@ discard block |
||
637 | 637 | $order = new WC_Order($order_id); |
638 | 638 | |
639 | 639 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
640 | - if (strpos($redirectUrl, 'order-pay=') === false) { |
|
641 | - $redirectUrl .= '&order-pay=' . $order_id; |
|
640 | + if (strpos($redirectUrl, 'order-pay=')===false) { |
|
641 | + $redirectUrl .= '&order-pay='.$order_id; |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | return array( |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | 'redirect' => $redirectUrl, |
647 | 647 | ); |
648 | 648 | } catch (Exception $e) { |
649 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); |
|
649 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); |
|
650 | 650 | |
651 | 651 | return array(); |
652 | 652 | } |
@@ -696,10 +696,10 @@ discard block |
||
696 | 696 | private function set_payment_urls() |
697 | 697 | { |
698 | 698 | $this->settings['ok_url'] = |
699 | - ($this->extraConfig['PAGANTIS_URL_OK'] !== '') ? $this->extraConfig['PAGANTIS_URL_OK'] |
|
699 | + ($this->extraConfig['PAGANTIS_URL_OK']!=='') ? $this->extraConfig['PAGANTIS_URL_OK'] |
|
700 | 700 | : $this->generateOkUrl(); |
701 | 701 | $this->settings['ko_url'] = |
702 | - ($this->extraConfig['PAGANTIS_URL_KO'] !== '') ? $this->extraConfig['PAGANTIS_URL_KO'] |
|
702 | + ($this->extraConfig['PAGANTIS_URL_KO']!=='') ? $this->extraConfig['PAGANTIS_URL_KO'] |
|
703 | 703 | : $this->generateKoUrl(); |
704 | 704 | foreach ($this->settings as $setting_key => $setting_value) { |
705 | 705 | $this->$setting_key = $setting_value; |
@@ -733,12 +733,12 @@ discard block |
||
733 | 733 | private function generateUrl($url) |
734 | 734 | { |
735 | 735 | $parsed_url = parse_url($url); |
736 | - if ($parsed_url !== false) { |
|
737 | - $parsed_url['query'] = ! isset($parsed_url['query']) ? '' : $parsed_url['query']; |
|
736 | + if ($parsed_url!==false) { |
|
737 | + $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
|
738 | 738 | parse_str($parsed_url['query'], $arrayParams); |
739 | 739 | foreach ($arrayParams as $keyParam => $valueParam) { |
740 | - if ($valueParam === '') { |
|
741 | - $arrayParams[$keyParam] = '{{' . $keyParam . '}}'; |
|
740 | + if ($valueParam==='') { |
|
741 | + $arrayParams[$keyParam] = '{{'.$keyParam.'}}'; |
|
742 | 742 | } |
743 | 743 | } |
744 | 744 | $parsed_url['query'] = http_build_query($arrayParams); |
@@ -784,13 +784,13 @@ discard block |
||
784 | 784 | */ |
785 | 785 | private function getKeysUrl($order, $url) |
786 | 786 | { |
787 | - $defaultFields = (get_class($order) === 'WC_Order') ? array( |
|
787 | + $defaultFields = (get_class($order)==='WC_Order') ? array( |
|
788 | 788 | 'order-received' => $order->get_id(), |
789 | 789 | 'key' => $order->get_order_key() |
790 | 790 | ) : array(); |
791 | 791 | |
792 | 792 | $parsedUrl = parse_url($url); |
793 | - if ($parsedUrl !== false) { |
|
793 | + if ($parsedUrl!==false) { |
|
794 | 794 | //Replace parameters from url |
795 | 795 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
796 | 796 | |
@@ -858,14 +858,14 @@ discard block |
||
858 | 858 | */ |
859 | 859 | private function get_unparsed_url($parsed_url) |
860 | 860 | { |
861 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
861 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
862 | 862 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
863 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
864 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
865 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
863 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
864 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
865 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
866 | 866 | $path = $parsed_url['path']; |
867 | 867 | |
868 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
868 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
869 | 869 | } |
870 | 870 | |
871 | 871 | /** |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
905 | 905 | )); |
906 | 906 | foreach ($customer_orders as $customer_order) { |
907 | - if (trim($sign_up) === '' |
|
907 | + if (trim($sign_up)==='' |
|
908 | 908 | || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up) |
909 | 909 | ) { |
910 | 910 | $sign_up = substr($customer_order->post_date, 0, 10); |
@@ -928,12 +928,12 @@ discard block |
||
928 | 928 | { |
929 | 929 | global $wpdb; |
930 | 930 | $this->check_if_wc_orders_db_table_exist(); |
931 | - $tableName = $wpdb->prefix . PAGANTIS_WC_ORDERS_TABLE; |
|
931 | + $tableName = $wpdb->prefix.PAGANTIS_WC_ORDERS_TABLE; |
|
932 | 932 | |
933 | 933 | //Check if id exists |
934 | 934 | $resultsSelect = $wpdb->get_results("SELECT * FROM $tableName WHERE id='$wc_order_id'"); |
935 | 935 | $countResults = count($resultsSelect); |
936 | - if ($countResults === 0) { |
|
936 | + if ($countResults===0) { |
|
937 | 937 | $wpdb->insert($tableName, array('id' => $wc_order_id, 'order_id' => $pg_order_id), array('%d', '%s')); |
938 | 938 | } else { |
939 | 939 | $wpdb->update( |
@@ -954,14 +954,14 @@ discard block |
||
954 | 954 | private function check_if_wc_orders_db_table_exist() |
955 | 955 | { |
956 | 956 | global $wpdb; |
957 | - $tableName = $wpdb->prefix . PAGANTIS_WC_ORDERS_TABLE; |
|
957 | + $tableName = $wpdb->prefix.PAGANTIS_WC_ORDERS_TABLE; |
|
958 | 958 | |
959 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") !== $tableName) { |
|
959 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!==$tableName) { |
|
960 | 960 | $charset_collate = $wpdb->get_charset_collate(); |
961 | 961 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
962 | 962 | UNIQUE KEY id (id)) $charset_collate"; |
963 | 963 | |
964 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
964 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
965 | 965 | dbDelta($sql); |
966 | 966 | } |
967 | 967 | } |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | { |
977 | 977 | foreach ((array) $order->get_meta_data() as $mdObject) { |
978 | 978 | $data = $mdObject->get_data(); |
979 | - if ($data['key'] === 'vat_number') { |
|
979 | + if ($data['key']==='vat_number') { |
|
980 | 980 | return $data['value']; |
981 | 981 | } |
982 | 982 | } |
@@ -993,7 +993,7 @@ discard block |
||
993 | 993 | { |
994 | 994 | foreach ((array) $order->get_meta_data() as $mdObject) { |
995 | 995 | $data = $mdObject->get_data(); |
996 | - if ($data['key'] === 'billing_cfpiva') { |
|
996 | + if ($data['key']==='billing_cfpiva') { |
|
997 | 997 | return $data['value']; |
998 | 998 | } |
999 | 999 | } |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | $metaProduct = get_post_meta($product_id); |
1038 | 1038 | |
1039 | 1039 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) |
1040 | - && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
1040 | + && $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | /** |
@@ -1050,7 +1050,7 @@ discard block |
||
1050 | 1050 | $promotedAmount = 0; |
1051 | 1051 | foreach ($items as $key => $item) { |
1052 | 1052 | $promotedProduct = $this->isPromoted($item['product_id']); |
1053 | - if ($promotedProduct === 'true') { |
|
1053 | + if ($promotedProduct==='true') { |
|
1054 | 1054 | $promotedAmount += $item['line_total'] + $item['line_tax']; |
1055 | 1055 | } |
1056 | 1056 | } |
@@ -22,58 +22,58 @@ discard block |
||
22 | 22 | class WC_PG_Notification_Handler extends WC_Pagantis_Gateway |
23 | 23 | { |
24 | 24 | /** |
25 | - * Concurrency table name |
|
26 | - */ |
|
25 | + * Concurrency table name |
|
26 | + */ |
|
27 | 27 | const CONCURRENCY_TABLE = 'pagantis_concurrency'; |
28 | 28 | |
29 | 29 | /** |
30 | - * Seconds to expire a locked request |
|
31 | - */ |
|
30 | + * Seconds to expire a locked request |
|
31 | + */ |
|
32 | 32 | const CONCURRENCY_TIMEOUT = 5; |
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Pagantis Order Number |
36 | 36 | * |
37 | - * @var mixed $pagantisOrder |
|
38 | - */ |
|
37 | + * @var mixed $pagantisOrder |
|
38 | + */ |
|
39 | 39 | protected $pagantisOrder; |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Origin of Order |
43 | 43 | * |
44 | - * @var $string $origin |
|
45 | - */ |
|
44 | + * @var $string $origin |
|
45 | + */ |
|
46 | 46 | public $origin; |
47 | 47 | |
48 | 48 | /** |
49 | 49 | * WC_Order object |
50 | 50 | * |
51 | - * @var $string |
|
52 | - */ |
|
51 | + * @var $string |
|
52 | + */ |
|
53 | 53 | public $order; |
54 | 54 | |
55 | 55 | /** |
56 | - * @var mixed $woocommerceOrderId |
|
57 | - */ |
|
56 | + * @var mixed $woocommerceOrderId |
|
57 | + */ |
|
58 | 58 | protected $woocommerceOrderId = ''; |
59 | 59 | |
60 | 60 | /** |
61 | - * @var mixed $cfg |
|
62 | - */ |
|
61 | + * @var mixed $cfg |
|
62 | + */ |
|
63 | 63 | protected $cfg; |
64 | 64 | |
65 | 65 | /** |
66 | - * @var Client $orderClient |
|
66 | + * @var Client $orderClient |
|
67 | 67 | */ |
68 | 68 | protected $orderClient; |
69 | 69 | |
70 | 70 | /** |
71 | - * @var WC_Order $woocommerceOrder |
|
71 | + * @var WC_Order $woocommerceOrder |
|
72 | 72 | */ |
73 | 73 | protected $woocommerceOrder; |
74 | 74 | |
75 | 75 | /** |
76 | - * @var mixed $pagantisOrderId |
|
76 | + * @var mixed $pagantisOrderId |
|
77 | 77 | */ |
78 | 78 | protected $pagantisOrderId = ''; |
79 | 79 | |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | |
227 | 227 | if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM |
228 | 228 | $logMessage = 'WARNING checkMerchantOrderStatus.' . |
229 | - ' Merchant order id:'.$this->woocommerceOrder->get_id(). |
|
230 | - ' Merchant order status:'.$this->woocommerceOrder->get_status(). |
|
231 | - ' Pagantis order id:'.$this->pagantisOrder->getStatus(). |
|
232 | - ' Pagantis order status:'.$this->pagantisOrder->getId(); |
|
229 | + ' Merchant order id:'.$this->woocommerceOrder->get_id(). |
|
230 | + ' Merchant order status:'.$this->woocommerceOrder->get_status(). |
|
231 | + ' Pagantis order id:'.$this->pagantisOrder->getStatus(). |
|
232 | + ' Pagantis order status:'.$this->pagantisOrder->getId(); |
|
233 | 233 | |
234 | 234 | WC_Pagantis_Logger::insert_log_entry_in_wpdb(null, $logMessage); |
235 | 235 | $this->woocommerceOrder->add_order_note($logMessage); |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * UTILS FUNCTIONS |
288 | 288 | */ |
289 | 289 | /** |
290 | - * STEP 1 CC - Check concurrency |
|
290 | + * STEP 1 CC - Check concurrency |
|
291 | 291 | */ |
292 | 292 | /** |
293 | 293 | * Check if orders table exists |
@@ -327,16 +327,16 @@ discard block |
||
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
330 | - * STEP 2 GMO - Get Merchant Order |
|
330 | + * STEP 2 GMO - Get Merchant Order |
|
331 | 331 | */ |
332 | 332 | /** |
333 | - * STEP 3 GPOI - Get Pagantis OrderId |
|
333 | + * STEP 3 GPOI - Get Pagantis OrderId |
|
334 | 334 | */ |
335 | 335 | /** |
336 | - * STEP 4 GPO - Get Pagantis Order |
|
336 | + * STEP 4 GPO - Get Pagantis Order |
|
337 | 337 | */ |
338 | 338 | /** |
339 | - * STEP 5 COS - Check Order Status |
|
339 | + * STEP 5 COS - Check Order Status |
|
340 | 340 | */ |
341 | 341 | |
342 | 342 | /** |
@@ -367,13 +367,13 @@ discard block |
||
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
370 | - * STEP 6 CMOS - Check Merchant Order Status |
|
370 | + * STEP 6 CMOS - Check Merchant Order Status |
|
371 | 371 | */ |
372 | 372 | /** |
373 | - * STEP 7 VA - Validate Amount |
|
373 | + * STEP 7 VA - Validate Amount |
|
374 | 374 | */ |
375 | 375 | /** |
376 | - * STEP 8 PMO - Process Merchant Order |
|
376 | + * STEP 8 PMO - Process Merchant Order |
|
377 | 377 | */ |
378 | 378 | /** |
379 | 379 | * @throws \Exception |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
429 | - * STEP 9 CPO - Confirmation Pagantis Order |
|
430 | - */ |
|
429 | + * STEP 9 CPO - Confirmation Pagantis Order |
|
430 | + */ |
|
431 | 431 | private function rollbackMerchantOrder() |
432 | 432 | { |
433 | 433 | $this->woocommerceOrder->update_status('pending', __('Pending payment', 'woocommerce')); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function processInformation() |
87 | 87 | { |
88 | - require_once dirname(__FILE__) . '/../includes/class-wc-pagantis-logger.php'; |
|
89 | - require_once dirname(__FILE__) . '/../includes/functions.php'; |
|
88 | + require_once dirname(__FILE__).'/../includes/class-wc-pagantis-logger.php'; |
|
89 | + require_once dirname(__FILE__).'/../includes/functions.php'; |
|
90 | 90 | try { |
91 | 91 | require_once(__ROOT__.'/vendor/autoload.php'); |
92 | 92 | try { |
93 | - if ($_SERVER['REQUEST_METHOD'] === 'GET' && $_GET['origin'] === 'notification') { |
|
93 | + if ($_SERVER['REQUEST_METHOD']==='GET' && $_GET['origin']==='notification') { |
|
94 | 94 | return $this->buildResponse(); |
95 | 95 | } |
96 | 96 | $this->checkConcurrency(); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | private function checkConcurrency() |
139 | 139 | { |
140 | 140 | $this->woocommerceOrderId = $_GET['order-received']; |
141 | - if ($this->woocommerceOrderId === '') { |
|
141 | + if ($this->woocommerceOrderId==='') { |
|
142 | 142 | throw new QuoteNotFoundException(); |
143 | 143 | } |
144 | 144 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $queryResult = $wpdb->get_row("select order_id from $tableName where id='".$this->woocommerceOrderId."'"); |
171 | 171 | $this->pagantisOrderId = $queryResult->order_id; |
172 | 172 | |
173 | - if ($this->pagantisOrderId === '') { |
|
173 | + if ($this->pagantisOrderId==='') { |
|
174 | 174 | throw new NoIdentificationException(); |
175 | 175 | } |
176 | 176 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $status = '-'; |
205 | 205 | } |
206 | 206 | |
207 | - if ($status === Order::STATUS_CONFIRMED) { |
|
207 | + if ($status===Order::STATUS_CONFIRMED) { |
|
208 | 208 | return true; |
209 | 209 | } |
210 | 210 | throw new WrongStatusException($status); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | ); |
226 | 226 | |
227 | 227 | if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM |
228 | - $logMessage = 'WARNING checkMerchantOrderStatus.' . |
|
228 | + $logMessage = 'WARNING checkMerchantOrderStatus.'. |
|
229 | 229 | ' Merchant order id:'.$this->woocommerceOrder->get_id(). |
230 | 230 | ' Merchant order status:'.$this->woocommerceOrder->get_status(). |
231 | 231 | ' Pagantis order id:'.$this->pagantisOrder->getStatus(). |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | { |
248 | 248 | $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
249 | 249 | $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total())); |
250 | - if ($pagantisAmount != $wcAmount) { |
|
250 | + if ($pagantisAmount!=$wcAmount) { |
|
251 | 251 | throw new AmountMismatchException($pagantisAmount, $wcAmount); |
252 | 252 | } |
253 | 253 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId); |
272 | 272 | } catch (\Exception $e) { |
273 | 273 | $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId); |
274 | - if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) { |
|
274 | + if ($this->pagantisOrder->getStatus()!==Order::STATUS_CONFIRMED) { |
|
275 | 275 | throw new UnknownException($e->getMessage()); |
276 | 276 | } else { |
277 | 277 | $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process'; |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | global $wpdb; |
298 | 298 | $tableName = $wpdb->prefix.PAGANTIS_WC_ORDERS_TABLE; |
299 | 299 | |
300 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
300 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
301 | 301 | $charset_collate = $wpdb->get_charset_collate(); |
302 | 302 | $sql = "CREATE TABLE $tableName (id int, order_id varchar(50), wc_order_id varchar(50), |
303 | 303 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | global $wpdb; |
316 | 316 | $tableName = $wpdb->prefix.PAGANTIS_LOGS_TABLE; |
317 | 317 | |
318 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
318 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
319 | 319 | $charset_collate = $wpdb->get_charset_collate(); |
320 | 320 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
321 | 321 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -386,12 +386,12 @@ discard block |
||
386 | 386 | $metadataOrder = $this->pagantisOrder->getMetadata(); |
387 | 387 | $metadataInfo = null; |
388 | 388 | foreach ($metadataOrder as $metadataKey => $metadataValue) { |
389 | - if ($metadataKey === 'promotedProduct') { |
|
389 | + if ($metadataKey==='promotedProduct') { |
|
390 | 390 | $metadataInfo .= "/Producto promocionado = $metadataValue"; |
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
394 | - if ($metadataInfo != null) { |
|
394 | + if ($metadataInfo!=null) { |
|
395 | 395 | $this->woocommerceOrder->add_order_note($metadataInfo); |
396 | 396 | } |
397 | 397 | |
@@ -462,13 +462,13 @@ discard block |
||
462 | 462 | { |
463 | 463 | global $wpdb; |
464 | 464 | $tableName = $wpdb->prefix.PAGANTIS_CONCURRENCY_TABLE; |
465 | - if ($orderId === null) { |
|
465 | + if ($orderId===null) { |
|
466 | 466 | $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT.' SECOND)'; |
467 | 467 | } else { |
468 | 468 | $query = "DELETE FROM $tableName WHERE order_id = $orderId"; |
469 | 469 | } |
470 | 470 | $resultDelete = $wpdb->query($query); |
471 | - if ($resultDelete === false) { |
|
471 | + if ($resultDelete===false) { |
|
472 | 472 | throw new ConcurrencyException(); |
473 | 473 | } |
474 | 474 | } |
@@ -483,11 +483,11 @@ discard block |
||
483 | 483 | global $wpdb; |
484 | 484 | $tableName = $wpdb->prefix.PAGANTIS_CONCURRENCY_TABLE; |
485 | 485 | $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId)); |
486 | - if ($insertResult === false) { |
|
487 | - if ($this->getOrigin() === 'Notify') { |
|
486 | + if ($insertResult===false) { |
|
487 | + if ($this->getOrigin()==='Notify') { |
|
488 | 488 | throw new ConcurrencyException(); |
489 | 489 | } else { |
490 | - $query = sprintf( |
|
490 | + $query = sprintf( |
|
491 | 491 | 'SELECT TIMESTAMPDIFF(SECOND,NOW()-INTERVAL %s SECOND, createdAt) as rest FROM %s WHERE %s', |
492 | 492 | self::CONCURRENCY_TIMEOUT, |
493 | 493 | $tableName, |
@@ -495,8 +495,8 @@ discard block |
||
495 | 495 | ); |
496 | 496 | $resultSeconds = $wpdb->get_row($query); |
497 | 497 | $restSeconds = isset($resultSeconds) ? ($resultSeconds->rest) : 0; |
498 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
499 | - sleep($secondsToExpire+1); |
|
498 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
499 | + sleep($secondsToExpire + 1); |
|
500 | 500 | |
501 | 501 | $logMessage = sprintf( |
502 | 502 | 'User waiting %s seconds, default seconds %s, bd time to expire %s seconds', |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | { |
520 | 520 | $this->unblockConcurrency($this->woocommerceOrderId); |
521 | 521 | |
522 | - if ($exception === null) { |
|
522 | + if ($exception===null) { |
|
523 | 523 | $jsonResponse = new JsonSuccessResponse(); |
524 | 524 | } else { |
525 | 525 | $jsonResponse = new JsonExceptionResponse(); |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | $jsonResponse->setMerchantOrderId($this->woocommerceOrderId); |
530 | 530 | $jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
531 | 531 | |
532 | - if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
|
532 | + if ($_SERVER['REQUEST_METHOD']==='POST') { |
|
533 | 533 | $jsonResponse->printResponse(); |
534 | 534 | } else { |
535 | 535 | return $jsonResponse; |