@@ -38,28 +38,28 @@ discard block |
||
38 | 38 | const ORDERS_TABLE = 'posts'; |
39 | 39 | |
40 | 40 | public $defaultConfigs = array( |
41 | - 'PAGANTIS_TITLE'=>'Pago en cuotas', |
|
42 | - 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'sdk.simulator.types.PRODUCT_PAGE', |
|
43 | - 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'=>'sdk.simulator.types.CHECKOUT_PAGE', |
|
44 | - 'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'sdk.simulator.skins.BLUE', |
|
45 | - 'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons', |
|
46 | - 'PAGANTIS_SIMULATOR_START_INSTALLMENTS'=>3, |
|
47 | - 'PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'=>12, |
|
48 | - 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'=>'default', |
|
49 | - 'PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'=>'sdk.simulator.positions.INNER', |
|
50 | - 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'=>'a:3:{i:0;s:48:"div.summary *:not(del)>.woocommerce-Price-amount";i:1;s:54:"div.entry-summary *:not(del)>.woocommerce-Price-amount";i:2;s:36:"*:not(del)>.woocommerce-Price-amount";}', |
|
51 | - 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'=>'a:2:{i:0;s:22:"div.quantity input.qty";i:1;s:18:"div.quantity>input";}', |
|
52 | - 'PAGANTIS_FORM_DISPLAY_TYPE'=>0, |
|
53 | - 'PAGANTIS_DISPLAY_MIN_AMOUNT'=>1, |
|
54 | - 'PAGANTIS_DISPLAY_MAX_AMOUNT'=>0, |
|
55 | - 'PAGANTIS_URL_OK'=>'', |
|
56 | - 'PAGANTIS_URL_KO'=>'', |
|
57 | - 'PAGANTIS_ALLOWED_COUNTRIES' => 'a:3:{i:0;s:2:"es";i:1;s:2:"it";i:2;s:2:"fr";}', |
|
58 | - 'PAGANTIS_PROMOTION_EXTRA' => '<p>Finance this product <span class="pg-no-interest">without interest!</span></p>', |
|
59 | - 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR' => '.', |
|
60 | - 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR' => ',', |
|
61 | - 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION' => 'default', |
|
62 | - 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION' => 'default' |
|
41 | + 'PAGANTIS_TITLE'=>'Pago en cuotas', |
|
42 | + 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'sdk.simulator.types.PRODUCT_PAGE', |
|
43 | + 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'=>'sdk.simulator.types.CHECKOUT_PAGE', |
|
44 | + 'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'sdk.simulator.skins.BLUE', |
|
45 | + 'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons', |
|
46 | + 'PAGANTIS_SIMULATOR_START_INSTALLMENTS'=>3, |
|
47 | + 'PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'=>12, |
|
48 | + 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'=>'default', |
|
49 | + 'PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'=>'sdk.simulator.positions.INNER', |
|
50 | + 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'=>'a:3:{i:0;s:48:"div.summary *:not(del)>.woocommerce-Price-amount";i:1;s:54:"div.entry-summary *:not(del)>.woocommerce-Price-amount";i:2;s:36:"*:not(del)>.woocommerce-Price-amount";}', |
|
51 | + 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'=>'a:2:{i:0;s:22:"div.quantity input.qty";i:1;s:18:"div.quantity>input";}', |
|
52 | + 'PAGANTIS_FORM_DISPLAY_TYPE'=>0, |
|
53 | + 'PAGANTIS_DISPLAY_MIN_AMOUNT'=>1, |
|
54 | + 'PAGANTIS_DISPLAY_MAX_AMOUNT'=>0, |
|
55 | + 'PAGANTIS_URL_OK'=>'', |
|
56 | + 'PAGANTIS_URL_KO'=>'', |
|
57 | + 'PAGANTIS_ALLOWED_COUNTRIES' => 'a:3:{i:0;s:2:"es";i:1;s:2:"it";i:2;s:2:"fr";}', |
|
58 | + 'PAGANTIS_PROMOTION_EXTRA' => '<p>Finance this product <span class="pg-no-interest">without interest!</span></p>', |
|
59 | + 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR' => '.', |
|
60 | + 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR' => ',', |
|
61 | + 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION' => 'default', |
|
62 | + 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION' => 'default' |
|
63 | 63 | ); |
64 | 64 | |
65 | 65 | /** @var array $extraConfig */ |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | if ($file == plugin_basename(__FILE__)) { |
427 | 427 | $links[] = '<a href="'.GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
428 | 428 | $links[] = '<a href="'.PAGANTIS_DOC_URL.'" target="_blank">'. |
429 | - __('API documentation', 'pagantis').'</a>'; |
|
429 | + __('API documentation', 'pagantis').'</a>'; |
|
430 | 430 | $links[] = '<a href="'.SUPPORT_EML.'">'.__('Support', 'pagantis').'</a>'; |
431 | 431 | |
432 | 432 | return $links; |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | register_activation_hook(__FILE__, array($this, 'pagantisActivation')); |
91 | 91 | add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl')); |
92 | 92 | add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave')); |
93 | - add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate')); |
|
94 | - add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave')); |
|
93 | + add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate')); |
|
94 | + add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave')); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | { |
118 | 118 | $post_id = $product->get_id(); |
119 | 119 | $pagantis_promoted_value = $_REQUEST['pagantis_promoted']; |
120 | - if ($pagantis_promoted_value == 'on') { |
|
120 | + if ($pagantis_promoted_value=='on') { |
|
121 | 121 | $pagantis_promoted_value = 'yes'; |
122 | 122 | } else { |
123 | 123 | $pagantis_promoted_value = 'no'; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | public function pagantisPromotedVarSave($post_id) |
152 | 152 | { |
153 | 153 | $pagantis_promoted_value = $_POST['pagantis_promoted']; |
154 | - if ($pagantis_promoted_value == null) { |
|
154 | + if ($pagantis_promoted_value==null) { |
|
155 | 155 | $pagantis_promoted_value = 'no'; |
156 | 156 | } |
157 | 157 | update_post_meta($post_id, 'custom_product_pagantis_promoted', esc_attr($pagantis_promoted_value)); |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function loadPagantisTranslation($mofile, $domain) |
166 | 166 | { |
167 | - if ('pagantis' === $domain) { |
|
168 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
167 | + if ('pagantis'===$domain) { |
|
168 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
169 | 169 | } |
170 | 170 | return $mofile; |
171 | 171 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | global $wpdb; |
179 | 179 | |
180 | 180 | $tableName = $wpdb->prefix.PAGANTIS_CONCURRENCY_TABLE; |
181 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
181 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
182 | 182 | $charset_collate = $wpdb->get_charset_collate(); |
183 | 183 | $sql = "CREATE TABLE $tableName ( order_id int NOT NULL, |
184 | 184 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate"; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE; |
190 | 190 | |
191 | 191 | //Check if table exists |
192 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; |
|
192 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; |
|
193 | 193 | if ($tableExists) { |
194 | 194 | $charset_collate = $wpdb->get_charset_collate(); |
195 | 195 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | //Updated value field to adapt to new length < v8.0.1 |
205 | 205 | $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'"; |
206 | 206 | $results = $wpdb->get_results($query, ARRAY_A); |
207 | - if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') { |
|
207 | + if ($results['0']['COLUMN_TYPE']=='varchar(100)') { |
|
208 | 208 | $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)"; |
209 | 209 | $wpdb->query($sql); |
210 | 210 | } |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
215 | 215 | $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A); |
216 | 216 | foreach ($dbCurrentConfig as $item) { |
217 | - if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
217 | + if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
218 | 218 | $css_price_selector = $this->preparePriceSelector($item['value']); |
219 | - if ($item['value'] != $css_price_selector) { |
|
219 | + if ($item['value']!=$css_price_selector) { |
|
220 | 220 | $wpdb->update( |
221 | 221 | $tableName, |
222 | 222 | array('value' => stripslashes($css_price_selector)), |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | array('%s') |
226 | 226 | ); |
227 | 227 | } |
228 | - } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
228 | + } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
229 | 229 | $css_quantity_selector = $this->prepareQuantitySelector($item['value']); |
230 | - if ($item['value'] != $css_quantity_selector) { |
|
230 | + if ($item['value']!=$css_quantity_selector) { |
|
231 | 231 | $wpdb->update( |
232 | 232 | $tableName, |
233 | 233 | array('value' => stripslashes($css_quantity_selector)), |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE; |
245 | 245 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
246 | 246 | $results = $wpdb->get_results($query, ARRAY_A); |
247 | - if (count($results) == 0) { |
|
247 | + if (count($results)==0) { |
|
248 | 248 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value' => '.'), array('%s', '%s')); |
249 | 249 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value' => ','), array('%s', '%s')); |
250 | 250 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE; |
254 | 254 | $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'"; |
255 | 255 | $results = $wpdb->get_results($query, ARRAY_A); |
256 | - if (count($results) == 0) { |
|
256 | + if (count($results)==0) { |
|
257 | 257 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value' => '0'), array('%s', '%s')); |
258 | 258 | } |
259 | 259 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE; |
262 | 262 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'"; |
263 | 263 | $results = $wpdb->get_results($query, ARRAY_A); |
264 | - if (count($results) == 0) { |
|
264 | + if (count($results)==0) { |
|
265 | 265 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value' => 'default'), array('%s', '%s')); |
266 | 266 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value' => 'default'), array('%s', '%s')); |
267 | 267 | } |
@@ -270,17 +270,17 @@ discard block |
||
270 | 270 | $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE; |
271 | 271 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'"; |
272 | 272 | $results = $wpdb->get_results($query, ARRAY_A); |
273 | - if (count($results) == 0) { |
|
273 | + if (count($results)==0) { |
|
274 | 274 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', 'value' => 'sdk.simulator.types.CHECKOUT_PAGE'), array('%s', '%s')); |
275 | 275 | $wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), array('%s'), array('%s')); |
276 | 276 | } |
277 | 277 | |
278 | 278 | //Adapting to variable selector < v8.3.6 |
279 | - $variableSelector="div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
279 | + $variableSelector = "div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
280 | 280 | $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE; |
281 | 281 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'"; |
282 | 282 | $results = $wpdb->get_results($query, ARRAY_A); |
283 | - if (count($results) == 0) { |
|
283 | + if (count($results)==0) { |
|
284 | 284 | $wpdb->update($tableName, array('value' => $variableSelector), array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION'), array('%s'), array('%s')); |
285 | 285 | } |
286 | 286 | |
@@ -328,9 +328,9 @@ discard block |
||
328 | 328 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
329 | 329 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
330 | 330 | $totalPrice = $product->get_price(); |
331 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
332 | - if ($cfg['enabled'] !== 'yes' || $cfg['pagantis_public_key'] == '' || $cfg['pagantis_private_key'] == '' || |
|
333 | - $cfg['simulator'] !== 'yes' || !$allowedCountry || !$validAmount) { |
|
331 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
332 | + if ($cfg['enabled']!=='yes' || $cfg['pagantis_public_key']=='' || $cfg['pagantis_private_key']=='' || |
|
333 | + $cfg['simulator']!=='yes' || !$allowedCountry || !$validAmount) { |
|
334 | 334 | return; |
335 | 335 | } |
336 | 336 | $post_id = $product->get_id(); |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | */ |
369 | 369 | public function addPagantisGateway($methods) |
370 | 370 | { |
371 | - if (! class_exists('WC_Payment_Gateway')) { |
|
371 | + if (!class_exists('WC_Payment_Gateway')) { |
|
372 | 372 | return $methods; |
373 | 373 | } |
374 | 374 | |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | */ |
424 | 424 | public function pagantisRowMeta($links, $file) |
425 | 425 | { |
426 | - if ($file == plugin_basename(__FILE__)) { |
|
426 | + if ($file==plugin_basename(__FILE__)) { |
|
427 | 427 | $links[] = '<a href="'.GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
428 | 428 | $links[] = '<a href="'.PAGANTIS_DOC_URL.'" target="_blank">'. |
429 | 429 | __('API documentation', 'pagantis').'</a>'; |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | $tableName = $wpdb->prefix.PAGANTIS_LOGS_TABLE; |
452 | 452 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
453 | 453 | $results = $wpdb->get_results($query); |
454 | - if (isset($results) && $privateKey == $secretKey) { |
|
454 | + if (isset($results) && $privateKey==$secretKey) { |
|
455 | 455 | foreach ($results as $key => $result) { |
456 | 456 | $response[$key]['timestamp'] = $result->createdAt; |
457 | 457 | $response[$key]['log'] = json_decode($result->log); |
@@ -478,12 +478,12 @@ discard block |
||
478 | 478 | |
479 | 479 | $filters = ($data->get_params()); |
480 | 480 | $secretKey = $filters['secret']; |
481 | - $cfg = get_option('woocommerce_pagantis_settings'); |
|
481 | + $cfg = get_option('woocommerce_pagantis_settings'); |
|
482 | 482 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
483 | - if ($privateKey != $secretKey) { |
|
483 | + if ($privateKey!=$secretKey) { |
|
484 | 484 | $response['status'] = 401; |
485 | 485 | $response['result'] = 'Unauthorized'; |
486 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
486 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
487 | 487 | if (count($_POST)) { |
488 | 488 | foreach ($_POST as $config => $value) { |
489 | 489 | if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc"; |
544 | 544 | $results = $wpdb->get_results($query); |
545 | 545 | |
546 | - if (isset($results) && $privateKey == $secretKey) { |
|
546 | + if (isset($results) && $privateKey==$secretKey) { |
|
547 | 547 | foreach ($results as $result) { |
548 | 548 | $key = $result->ID; |
549 | 549 | $response['message'][$key]['timestamp'] = $result->post_date; |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | */ |
628 | 628 | private function prepareQuantitySelector($css_quantity_selector) |
629 | 629 | { |
630 | - if ($css_quantity_selector == 'default' || $css_quantity_selector == '') { |
|
630 | + if ($css_quantity_selector=='default' || $css_quantity_selector=='') { |
|
631 | 631 | $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
632 | 632 | } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
633 | 633 | $css_quantity_selector = serialize(array($css_quantity_selector)); |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | */ |
644 | 644 | private function preparePriceSelector($css_price_selector) |
645 | 645 | { |
646 | - if ($css_price_selector == 'default' || $css_price_selector == '') { |
|
646 | + if ($css_price_selector=='default' || $css_price_selector=='') { |
|
647 | 647 | $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
648 | 648 | } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
649 | 649 | $css_price_selector = serialize(array($css_price_selector)); |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | { |
662 | 662 | $metaProduct = get_post_meta($product_id); |
663 | 663 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && |
664 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
664 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
665 | 665 | } |
666 | 666 | } |
667 | 667 |
@@ -299,9 +299,9 @@ |
||
299 | 299 | if ($promotedProduct == 'true') { |
300 | 300 | $promotedAmount+=$product->getAmount(); |
301 | 301 | $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
302 | - ' - Price: ' . $item->get_total() . |
|
303 | - ' - Qty: ' . $product->getQuantity() . |
|
304 | - ' - Item ID: ' . $item['id_product']; |
|
302 | + ' - Price: ' . $item->get_total() . |
|
303 | + ' - Qty: ' . $product->getQuantity() . |
|
304 | + ' - Item ID: ' . $item['id_product']; |
|
305 | 305 | $promotedMessage = substr($promotedMessage, 0, 999); |
306 | 306 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
307 | 307 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $value = WcPagantisExtraConfig::getExtraConfigValue('PAGANTIS_TITLE'); |
49 | 49 | WCPagantisLogger::writeLog($value); |
50 | 50 | //Useful vars |
51 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/'; |
|
51 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/'; |
|
52 | 52 | $this->allowed_currencies = array("EUR"); |
53 | 53 | $this->language = strstr(get_locale(), '_', true); |
54 | 54 | if ($this->language=='') { |
@@ -57,31 +57,31 @@ discard block |
||
57 | 57 | $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
58 | 58 | |
59 | 59 | //Panel form fields |
60 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options |
|
60 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options |
|
61 | 61 | $this->init_settings(); |
62 | 62 | |
63 | 63 | $this->extraConfig = $this->getExtraConfig(); |
64 | 64 | $this->title = __($this->extraConfig['PAGANTIS_TITLE'], 'pagantis'); |
65 | 65 | $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis."; |
66 | 66 | |
67 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl(); |
|
68 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl(); |
|
67 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
68 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
69 | 69 | foreach ($this->settings as $setting_key => $setting_value) { |
70 | 70 | $this->$setting_key = $setting_value; |
71 | 71 | } |
72 | 72 | |
73 | 73 | //Hooks |
74 | - add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options |
|
75 | - add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields |
|
76 | - add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
77 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
78 | - add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3); |
|
74 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options |
|
75 | + add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields |
|
76 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
77 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
78 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3); |
|
79 | 79 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
80 | 80 | } |
81 | 81 | |
82 | 82 | public function enqueue_scripts() |
83 | 83 | { |
84 | - if ($this->enabled !== 'yes' || ! is_checkout() || is_order_received_page() || is_wc_endpoint_url('order-pay')) { |
|
84 | + if ($this->enabled!=='yes' || !is_checkout() || is_order_received_page() || is_wc_endpoint_url('order-pay')) { |
|
85 | 85 | return; |
86 | 86 | } |
87 | 87 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function loadPagantisTranslation($mofile, $domain) |
114 | 114 | { |
115 | - if ('pagantis' === $domain) { |
|
116 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
115 | + if ('pagantis'===$domain) { |
|
116 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
117 | 117 | } |
118 | 118 | return $mofile; |
119 | 119 | } |
@@ -145,24 +145,24 @@ discard block |
||
145 | 145 | public function pagantisCheckFields() |
146 | 146 | { |
147 | 147 | $error_string = ''; |
148 | - if ($this->settings['enabled'] !== 'yes') { |
|
148 | + if ($this->settings['enabled']!=='yes') { |
|
149 | 149 | return; |
150 | 150 | } elseif (!version_compare(phpversion(), '5.3.0', '>=')) { |
151 | - $error_string = __(' is not compatible with your php and/or curl version', 'pagantis'); |
|
151 | + $error_string = __(' is not compatible with your php and/or curl version', 'pagantis'); |
|
152 | 152 | $this->settings['enabled'] = 'no'; |
153 | 153 | } elseif ($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="") { |
154 | 154 | $error_string = __(' is not configured correctly, the fields Public Key and Secret Key are mandatory for use this plugin', 'pagantis'); |
155 | 155 | $this->settings['enabled'] = 'no'; |
156 | 156 | } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) { |
157 | - $error_string = __(' only can be used in Euros', 'pagantis'); |
|
157 | + $error_string = __(' only can be used in Euros', 'pagantis'); |
|
158 | 158 | $this->settings['enabled'] = 'no'; |
159 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']<'2' |
|
160 | - || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']>'12') { |
|
159 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] < '2' |
|
160 | + || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] > '12') { |
|
161 | 161 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis'); |
162 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']<'2' |
|
163 | - || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']>'12') { |
|
162 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] < '2' |
|
163 | + || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] > '12') { |
|
164 | 164 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis'); |
165 | - } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']<0) { |
|
165 | + } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] < 0) { |
|
166 | 166 | $error_string = __(' can not have a minimum amount less than 0', 'pagantis'); |
167 | 167 | } |
168 | 168 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | $shippingAddress = $order->get_address('shipping'); |
198 | 198 | $billingAddress = $order->get_address('billing'); |
199 | - if ($shippingAddress['address_1'] == '') { |
|
199 | + if ($shippingAddress['address_1']=='') { |
|
200 | 200 | $shippingAddress = $billingAddress; |
201 | 201 | } |
202 | 202 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | ->setNationalId($national_id) |
224 | 224 | ->setTaxId($tax_id) |
225 | 225 | ; |
226 | - $orderBillingAddress = new Address(); |
|
226 | + $orderBillingAddress = new Address(); |
|
227 | 227 | $orderBillingAddress |
228 | 228 | ->setZipCode($billingAddress['postcode']) |
229 | 229 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
@@ -296,12 +296,12 @@ discard block |
||
296 | 296 | $details->addProduct($product); |
297 | 297 | |
298 | 298 | $promotedProduct = $this->isPromoted($item->get_product_id()); |
299 | - if ($promotedProduct == 'true') { |
|
300 | - $promotedAmount+=$product->getAmount(); |
|
301 | - $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
|
302 | - ' - Price: ' . $item->get_total() . |
|
303 | - ' - Qty: ' . $product->getQuantity() . |
|
304 | - ' - Item ID: ' . $item['id_product']; |
|
299 | + if ($promotedProduct=='true') { |
|
300 | + $promotedAmount += $product->getAmount(); |
|
301 | + $promotedMessage = 'Promoted Item: '.$wcProduct->get_name(). |
|
302 | + ' - Price: '.$item->get_total(). |
|
303 | + ' - Qty: '.$product->getQuantity(). |
|
304 | + ' - Item ID: '.$item['id_product']; |
|
305 | 305 | $promotedMessage = substr($promotedMessage, 0, 999); |
306 | 306 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
307 | 307 | } |
@@ -345,9 +345,7 @@ discard block |
||
345 | 345 | |
346 | 346 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
347 | 347 | $purchaseCountry = |
348 | - in_array(strtolower($this->language), $allowedCountries) ? $this->language : |
|
349 | - in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : |
|
350 | - in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null; |
|
348 | + in_array(strtolower($this->language), $allowedCountries) ? $this->language : in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null; |
|
351 | 349 | |
352 | 350 | $orderConfiguration = new Configuration(); |
353 | 351 | $orderConfiguration |
@@ -389,7 +387,7 @@ discard block |
||
389 | 387 | wc_get_template('iframe.php', $template_fields, '', $this->template_path); |
390 | 388 | } |
391 | 389 | } catch (\Exception $exception) { |
392 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); |
|
390 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); |
|
393 | 391 | $this->insertLog($exception); |
394 | 392 | $checkout_url = get_permalink(wc_get_page_id('checkout')); |
395 | 393 | wp_redirect($checkout_url); |
@@ -403,7 +401,7 @@ discard block |
||
403 | 401 | public function pagantisNotification() |
404 | 402 | { |
405 | 403 | try { |
406 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
404 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
407 | 405 | |
408 | 406 | include_once('notifyController.php'); |
409 | 407 | $notify = new WcPagantisNotify(); |
@@ -442,10 +440,10 @@ discard block |
||
442 | 440 | */ |
443 | 441 | public function pagantisCompleteStatus($status, $order_id, $order) |
444 | 442 | { |
445 | - if ($order->get_payment_method() == self::METHOD_ID) { |
|
446 | - if ($order->get_status() == 'failed') { |
|
443 | + if ($order->get_payment_method()==self::METHOD_ID) { |
|
444 | + if ($order->get_status()=='failed') { |
|
447 | 445 | $status = 'processing'; |
448 | - } elseif ($order->get_status() == 'pending' && $status=='completed') { |
|
446 | + } elseif ($order->get_status()=='pending' && $status=='completed') { |
|
449 | 447 | $status = 'processing'; |
450 | 448 | } |
451 | 449 | } |
@@ -470,8 +468,8 @@ discard block |
||
470 | 468 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
471 | 469 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
472 | 470 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
473 | - $totalPrice = (int)$this->get_order_total(); |
|
474 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
471 | + $totalPrice = (int) $this->get_order_total(); |
|
472 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
475 | 473 | if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' && |
476 | 474 | $validAmount && $allowedCountry) { |
477 | 475 | return true; |
@@ -501,7 +499,7 @@ discard block |
||
501 | 499 | |
502 | 500 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
503 | 501 | if (strpos($redirectUrl, 'order-pay=')===false) { |
504 | - $redirectUrl.="&order-pay=".$order_id; |
|
502 | + $redirectUrl .= "&order-pay=".$order_id; |
|
505 | 503 | } |
506 | 504 | |
507 | 505 | return array( |
@@ -509,7 +507,7 @@ discard block |
||
509 | 507 | 'redirect' => $redirectUrl |
510 | 508 | ); |
511 | 509 | } catch (Exception $e) { |
512 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); |
|
510 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); |
|
513 | 511 | return array(); |
514 | 512 | } |
515 | 513 | } |
@@ -575,7 +573,7 @@ discard block |
||
575 | 573 | private function generateUrl($url) |
576 | 574 | { |
577 | 575 | $parsed_url = parse_url($url); |
578 | - if ($parsed_url !== false) { |
|
576 | + if ($parsed_url!==false) { |
|
579 | 577 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
580 | 578 | parse_str($parsed_url['query'], $arrayParams); |
581 | 579 | foreach ($arrayParams as $keyParam => $valueParam) { |
@@ -623,11 +621,10 @@ discard block |
||
623 | 621 | private function getKeysUrl($order, $url) |
624 | 622 | { |
625 | 623 | $defaultFields = (get_class($order)=='WC_Order') ? |
626 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : |
|
627 | - array(); |
|
624 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array(); |
|
628 | 625 | |
629 | 626 | $parsedUrl = parse_url($url); |
630 | - if ($parsedUrl !== false) { |
|
627 | + if ($parsedUrl!==false) { |
|
631 | 628 | //Replace parameters from url |
632 | 629 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
633 | 630 | |
@@ -672,7 +669,7 @@ discard block |
||
672 | 669 | foreach ($arrayParams as $keyParam => $valueParam) { |
673 | 670 | preg_match('#\{{.*?}\}#', $valueParam, $match); |
674 | 671 | if (count($match)) { |
675 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]); |
|
672 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]); |
|
676 | 673 | $arrayParams[$keyParam] = $defaultFields[$key]; |
677 | 674 | } |
678 | 675 | } |
@@ -687,13 +684,13 @@ discard block |
||
687 | 684 | */ |
688 | 685 | private function unparseUrl($parsed_url) |
689 | 686 | { |
690 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
687 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
691 | 688 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
692 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
693 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
694 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
689 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
690 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
691 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
695 | 692 | $path = $parsed_url['path']; |
696 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
693 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
697 | 694 | } |
698 | 695 | |
699 | 696 | /** |
@@ -715,20 +712,20 @@ discard block |
||
715 | 712 | $is_guest = "false"; |
716 | 713 | $sign_up = substr($current_user->user_registered, 0, 10); |
717 | 714 | $customer_orders = get_posts(array( |
718 | - 'numberposts' => - 1, |
|
715 | + 'numberposts' => -1, |
|
719 | 716 | 'meta_key' => '_customer_user', |
720 | 717 | 'meta_value' => $current_user->ID, |
721 | - 'post_type' => array( 'shop_order' ), |
|
722 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded' ), |
|
718 | + 'post_type' => array('shop_order'), |
|
719 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
|
723 | 720 | )); |
724 | 721 | } else { |
725 | 722 | $is_guest = "true"; |
726 | 723 | $customer_orders = get_posts(array( |
727 | - 'numberposts' => - 1, |
|
724 | + 'numberposts' => -1, |
|
728 | 725 | 'meta_key' => '_billing_email', |
729 | 726 | 'meta_value' => $billingEmail, |
730 | - 'post_type' => array( 'shop_order' ), |
|
731 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded'), |
|
727 | + 'post_type' => array('shop_order'), |
|
728 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
|
732 | 729 | )); |
733 | 730 | foreach ($customer_orders as $customer_order) { |
734 | 731 | if (trim($sign_up)=='' || |
@@ -757,7 +754,7 @@ discard block |
||
757 | 754 | //Check if id exists |
758 | 755 | $resultsSelect = $wpdb->get_results("select * from $tableName where id='$orderId'"); |
759 | 756 | $countResults = count($resultsSelect); |
760 | - if ($countResults == 0) { |
|
757 | + if ($countResults==0) { |
|
761 | 758 | $wpdb->insert( |
762 | 759 | $tableName, |
763 | 760 | array('id' => $orderId, 'order_id' => $pagantisOrderId), |
@@ -782,7 +779,7 @@ discard block |
||
782 | 779 | global $wpdb; |
783 | 780 | $tableName = $wpdb->prefix.PAGANTIS_WC_ORDERS_TABLE; |
784 | 781 | |
785 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
782 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
786 | 783 | $charset_collate = $wpdb->get_charset_collate(); |
787 | 784 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
788 | 785 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -815,9 +812,9 @@ discard block |
||
815 | 812 | */ |
816 | 813 | private function getNationalId($order) |
817 | 814 | { |
818 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
815 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
819 | 816 | $data = $mdObject->get_data(); |
820 | - if ($data['key'] == 'vat_number') { |
|
817 | + if ($data['key']=='vat_number') { |
|
821 | 818 | return $data['value']; |
822 | 819 | } |
823 | 820 | } |
@@ -832,9 +829,9 @@ discard block |
||
832 | 829 | */ |
833 | 830 | private function getTaxId($order) |
834 | 831 | { |
835 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
832 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
836 | 833 | $data = $mdObject->get_data(); |
837 | - if ($data['key'] == 'billing_cfpiva') { |
|
834 | + if ($data['key']=='billing_cfpiva') { |
|
838 | 835 | return $data['value']; |
839 | 836 | } |
840 | 837 | } |
@@ -864,7 +861,7 @@ discard block |
||
864 | 861 | { |
865 | 862 | global $wpdb; |
866 | 863 | $tableName = $wpdb->prefix.PAGANTIS_LOGS_TABLE; |
867 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
864 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
868 | 865 | $charset_collate = $wpdb->get_charset_collate(); |
869 | 866 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
870 | 867 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -883,7 +880,7 @@ discard block |
||
883 | 880 | { |
884 | 881 | $metaProduct = get_post_meta($product_id); |
885 | 882 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && |
886 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
883 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
887 | 884 | } |
888 | 885 | |
889 | 886 | /** |
@@ -896,8 +893,8 @@ discard block |
||
896 | 893 | $promotedAmount = 0; |
897 | 894 | foreach ($items as $key => $item) { |
898 | 895 | $promotedProduct = $this->isPromoted($item['product_id']); |
899 | - if ($promotedProduct == 'true') { |
|
900 | - $promotedAmount+=$item['line_total'] + $item['line_tax']; |
|
896 | + if ($promotedProduct=='true') { |
|
897 | + $promotedAmount += $item['line_total'] + $item['line_tax']; |
|
901 | 898 | } |
902 | 899 | } |
903 | 900 |
@@ -198,10 +198,10 @@ |
||
198 | 198 | |
199 | 199 | if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM |
200 | 200 | $logMessage = "WARNING checkMerchantOrderStatus." . |
201 | - " Merchant order id:".$this->woocommerceOrder->get_id(). |
|
202 | - " Merchant order status:".$this->woocommerceOrder->get_status(). |
|
203 | - " Pagantis order id:".$this->pagantisOrder->getStatus(). |
|
204 | - " Pagantis order status:".$this->pagantisOrder->getId(); |
|
201 | + " Merchant order id:".$this->woocommerceOrder->get_id(). |
|
202 | + " Merchant order status:".$this->woocommerceOrder->get_status(). |
|
203 | + " Pagantis order id:".$this->pagantisOrder->getStatus(). |
|
204 | + " Pagantis order status:".$this->pagantisOrder->getId(); |
|
205 | 205 | |
206 | 206 | $this->insertLog(null, $logMessage); |
207 | 207 | $this->woocommerceOrder->add_order_note($logMessage); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | try { |
63 | 63 | require_once(__ROOT__.'/vendor/autoload.php'); |
64 | 64 | try { |
65 | - if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_GET['origin'] == 'notification') { |
|
65 | + if ($_SERVER['REQUEST_METHOD']=='GET' && $_GET['origin']=='notification') { |
|
66 | 66 | return $this->buildResponse(); |
67 | 67 | } |
68 | 68 | $this->checkConcurrency(); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | private function checkConcurrency() |
111 | 111 | { |
112 | 112 | $this->woocommerceOrderId = $_GET['order-received']; |
113 | - if ($this->woocommerceOrderId == '') { |
|
113 | + if ($this->woocommerceOrderId=='') { |
|
114 | 114 | throw new QuoteNotFoundException(); |
115 | 115 | } |
116 | 116 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $queryResult = $wpdb->get_row("select order_id from $tableName where id='".$this->woocommerceOrderId."'"); |
143 | 143 | $this->pagantisOrderId = $queryResult->order_id; |
144 | 144 | |
145 | - if ($this->pagantisOrderId == '') { |
|
145 | + if ($this->pagantisOrderId=='') { |
|
146 | 146 | throw new NoIdentificationException(); |
147 | 147 | } |
148 | 148 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | $status = '-'; |
177 | 177 | } |
178 | 178 | |
179 | - if ($status === Order::STATUS_CONFIRMED) { |
|
179 | + if ($status===Order::STATUS_CONFIRMED) { |
|
180 | 180 | return true; |
181 | 181 | } |
182 | 182 | throw new WrongStatusException($status); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | ); |
198 | 198 | |
199 | 199 | if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM |
200 | - $logMessage = "WARNING checkMerchantOrderStatus." . |
|
200 | + $logMessage = "WARNING checkMerchantOrderStatus.". |
|
201 | 201 | " Merchant order id:".$this->woocommerceOrder->get_id(). |
202 | 202 | " Merchant order status:".$this->woocommerceOrder->get_status(). |
203 | 203 | " Pagantis order id:".$this->pagantisOrder->getStatus(). |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | { |
220 | 220 | $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
221 | 221 | $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total())); |
222 | - if ($pagantisAmount != $wcAmount) { |
|
222 | + if ($pagantisAmount!=$wcAmount) { |
|
223 | 223 | throw new AmountMismatchException($pagantisAmount, $wcAmount); |
224 | 224 | } |
225 | 225 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId); |
244 | 244 | } catch (\Exception $e) { |
245 | 245 | $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId); |
246 | - if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) { |
|
246 | + if ($this->pagantisOrder->getStatus()!==Order::STATUS_CONFIRMED) { |
|
247 | 247 | throw new UnknownException($e->getMessage()); |
248 | 248 | } else { |
249 | 249 | $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process'; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | global $wpdb; |
268 | 268 | $tableName = $wpdb->prefix.PAGANTIS_WC_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"; |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | global $wpdb; |
286 | 286 | $tableName = $wpdb->prefix.PAGANTIS_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"; |
@@ -342,12 +342,12 @@ discard block |
||
342 | 342 | $metadataOrder = $this->pagantisOrder->getMetadata(); |
343 | 343 | $metadataInfo = null; |
344 | 344 | foreach ($metadataOrder as $metadataKey => $metadataValue) { |
345 | - if ($metadataKey == 'promotedProduct') { |
|
346 | - $metadataInfo.= "/Producto promocionado = $metadataValue"; |
|
345 | + if ($metadataKey=='promotedProduct') { |
|
346 | + $metadataInfo .= "/Producto promocionado = $metadataValue"; |
|
347 | 347 | } |
348 | 348 | } |
349 | 349 | |
350 | - if ($metadataInfo != null) { |
|
350 | + if ($metadataInfo!=null) { |
|
351 | 351 | $this->woocommerceOrder->add_order_note($metadataInfo); |
352 | 352 | } |
353 | 353 | |
@@ -416,13 +416,13 @@ discard block |
||
416 | 416 | { |
417 | 417 | global $wpdb; |
418 | 418 | $tableName = $wpdb->prefix.PAGANTIS_CONCURRENCY_TABLE; |
419 | - if ($orderId == null) { |
|
419 | + if ($orderId==null) { |
|
420 | 420 | $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT." SECOND)"; |
421 | 421 | } else { |
422 | 422 | $query = "DELETE FROM $tableName WHERE order_id = $orderId"; |
423 | 423 | } |
424 | 424 | $resultDelete = $wpdb->query($query); |
425 | - if ($resultDelete === false) { |
|
425 | + if ($resultDelete===false) { |
|
426 | 426 | throw new ConcurrencyException(); |
427 | 427 | } |
428 | 428 | } |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | global $wpdb; |
438 | 438 | $tableName = $wpdb->prefix.PAGANTIS_CONCURRENCY_TABLE; |
439 | 439 | $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId)); |
440 | - if ($insertResult === false) { |
|
441 | - if ($this->getOrigin() == 'Notify') { |
|
440 | + if ($insertResult===false) { |
|
441 | + if ($this->getOrigin()=='Notify') { |
|
442 | 442 | throw new ConcurrencyException(); |
443 | 443 | } else { |
444 | 444 | $query = sprintf( |
@@ -449,8 +449,8 @@ discard block |
||
449 | 449 | ); |
450 | 450 | $resultSeconds = $wpdb->get_row($query); |
451 | 451 | $restSeconds = isset($resultSeconds) ? ($resultSeconds->rest) : 0; |
452 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
453 | - sleep($secondsToExpire+1); |
|
452 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
453 | + sleep($secondsToExpire + 1); |
|
454 | 454 | |
455 | 455 | $logMessage = sprintf( |
456 | 456 | "User waiting %s seconds, default seconds %s, bd time to expire %s seconds", |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | { |
475 | 475 | $this->unblockConcurrency($this->woocommerceOrderId); |
476 | 476 | |
477 | - if ($exception == null) { |
|
477 | + if ($exception==null) { |
|
478 | 478 | $jsonResponse = new JsonSuccessResponse(); |
479 | 479 | } else { |
480 | 480 | $jsonResponse = new JsonExceptionResponse(); |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | $jsonResponse->setMerchantOrderId($this->woocommerceOrderId); |
485 | 485 | $jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
486 | 486 | |
487 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
487 | + if ($_SERVER['REQUEST_METHOD']=='POST') { |
|
488 | 488 | $jsonResponse->printResponse(); |
489 | 489 | } else { |
490 | 490 | return $jsonResponse; |
@@ -34,5 +34,5 @@ |
||
34 | 34 | 'label' => __('Enable logging', 'pagantis'), |
35 | 35 | 'default' => 'no', |
36 | 36 | /* translators: %s: URL */ |
37 | - 'description' => sprintf(__('Log Pagantis events to troubleshoot.', 'inside %s Note: this may log personal information. We recommend using this for debugging purposes only and deleting the logs when finished.', 'woocommerce'), '<code>' . WC_Log_Handler_File::get_log_file_path('pagantis') . '</code>')), |
|
37 | + 'description' => sprintf(__('Log Pagantis events to troubleshoot.', 'inside %s Note: this may log personal information. We recommend using this for debugging purposes only and deleting the logs when finished.', 'woocommerce'), '<code>'.WC_Log_Handler_File::get_log_file_path('pagantis').'</code>')), |
|
38 | 38 | ); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public static function writeLog($message, $start_time = null, $end_time = null) |
23 | 23 | { |
24 | - if (! class_exists('WC_Logger')) { |
|
24 | + if (!class_exists('WC_Logger')) { |
|
25 | 25 | return; |
26 | 26 | } |
27 | 27 | |
@@ -32,28 +32,28 @@ discard block |
||
32 | 32 | |
33 | 33 | $settings = get_option('woocommerce_stripe_settings'); |
34 | 34 | |
35 | - if (empty($settings) || isset($settings['logging']) && 'yes' !== $settings['logging']) { |
|
35 | + if (empty($settings) || isset($settings['logging']) && 'yes'!==$settings['logging']) { |
|
36 | 36 | return; |
37 | 37 | } |
38 | 38 | |
39 | - if (! is_null($start_time)) { |
|
40 | - $formatted_start_time = date_i18n(get_option('date_format') . ' g:ia', $start_time); |
|
39 | + if (!is_null($start_time)) { |
|
40 | + $formatted_start_time = date_i18n(get_option('date_format').' g:ia', $start_time); |
|
41 | 41 | $end_time = is_null($end_time) ? current_time('timestamp') : $end_time; |
42 | - $formatted_end_time = date_i18n(get_option('date_format') . ' g:ia', $end_time); |
|
42 | + $formatted_end_time = date_i18n(get_option('date_format').' g:ia', $end_time); |
|
43 | 43 | $elapsed_time = round(abs($end_time - $start_time) / 60, 2); |
44 | 44 | |
45 | - $log_entry = "\n" . '====Pagantis Version: ' . PAGANTIS_VERSION . '====' . "\n"; |
|
46 | - $log_entry .= '====Start Log ' . $formatted_start_time . '====' . "\n" . $message . "\n"; |
|
47 | - $log_entry .= '====End Log ' . $formatted_end_time . ' (' . $elapsed_time . ')====' . "\n\n"; |
|
45 | + $log_entry = "\n".'====Pagantis Version: '.PAGANTIS_VERSION.'===='."\n"; |
|
46 | + $log_entry .= '====Start Log '.$formatted_start_time.'===='."\n".$message."\n"; |
|
47 | + $log_entry .= '====End Log '.$formatted_end_time.' ('.$elapsed_time.')===='."\n\n"; |
|
48 | 48 | } else { |
49 | - $log_entry = "\n" . '====Pagantis Version: ' . PAGANTIS_VERSION . '====' . "\n"; |
|
50 | - $log_entry .= '====Start Log====' . "\n" . $message . "\n" . '====End Log====' . "\n\n"; |
|
49 | + $log_entry = "\n".'====Pagantis Version: '.PAGANTIS_VERSION.'===='."\n"; |
|
50 | + $log_entry .= '====Start Log===='."\n".$message."\n".'====End Log===='."\n\n"; |
|
51 | 51 | } |
52 | 52 | if (defined('WP_DEBUG') && WP_DEBUG) { |
53 | 53 | error_log($log_entry); |
54 | 54 | } |
55 | 55 | print_r($log_entry); |
56 | - self::$logger->debug($log_entry, array( 'source' => self::WC_LOG_FILENAME )); |
|
56 | + self::$logger->debug($log_entry, array('source' => self::WC_LOG_FILENAME)); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | } |
@@ -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 | } |