@@ -192,10 +192,10 @@ |
||
| 192 | 192 | |
| 193 | 193 | if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM
|
| 194 | 194 | $logMessage = "WARNING checkMerchantOrderStatus." . |
| 195 | - " Merchant order id:".$this->woocommerceOrder->get_id(). |
|
| 196 | - " Merchant order status:".$this->woocommerceOrder->get_status(). |
|
| 197 | - " Pagantis order id:".$this->pagantisOrder->getStatus(). |
|
| 198 | - " Pagantis order status:".$this->pagantisOrder->getId(); |
|
| 195 | + " Merchant order id:".$this->woocommerceOrder->get_id(). |
|
| 196 | + " Merchant order status:".$this->woocommerceOrder->get_status(). |
|
| 197 | + " Pagantis order id:".$this->pagantisOrder->getStatus(). |
|
| 198 | + " Pagantis order status:".$this->pagantisOrder->getId(); |
|
| 199 | 199 | |
| 200 | 200 | $this->insertLog(null, $logMessage); |
| 201 | 201 | $this->woocommerceOrder->add_order_note($logMessage); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | try {
|
| 66 | 66 | require_once(__ROOT__.'/vendor/autoload.php'); |
| 67 | 67 | try {
|
| 68 | - if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_GET['origin'] == 'notification') {
|
|
| 68 | + if ($_SERVER['REQUEST_METHOD']=='GET' && $_GET['origin']=='notification') {
|
|
| 69 | 69 | return $this->buildResponse(); |
| 70 | 70 | } |
| 71 | 71 | $this->checkConcurrency(); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | private function checkConcurrency() |
| 115 | 115 | {
|
| 116 | 116 | $this->woocommerceOrderId = $_GET['order-received']; |
| 117 | - if ($this->woocommerceOrderId == '') {
|
|
| 117 | + if ($this->woocommerceOrderId=='') {
|
|
| 118 | 118 | throw new QuoteNotFoundException(); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | private function getProductType() |
| 129 | 129 | {
|
| 130 | - if ($_GET['product'] == '') {
|
|
| 130 | + if ($_GET['product']=='') {
|
|
| 131 | 131 | $this->setProduct(WcPagantisGateway::METHOD_ID); |
| 132 | 132 | } else {
|
| 133 | 133 | $this->setProduct($_GET['product']); |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | $queryResult = $wpdb->get_row("select order_id from $tableName where id='".$this->woocommerceOrderId."'");
|
| 159 | 159 | $this->pagantisOrderId = $queryResult->order_id; |
| 160 | 160 | |
| 161 | - if ($this->pagantisOrderId == '') {
|
|
| 161 | + if ($this->pagantisOrderId=='') {
|
|
| 162 | 162 | throw new NoIdentificationException(); |
| 163 | 163 | } |
| 164 | 164 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | private function getPagantisOrder() |
| 170 | 170 | {
|
| 171 | 171 | try {
|
| 172 | - $this->cfg = get_option('woocommerce_pagantis_settings'); $this->cfg = get_option('woocommerce_pagantis_settings');
|
|
| 172 | + $this->cfg = get_option('woocommerce_pagantis_settings'); $this->cfg = get_option('woocommerce_pagantis_settings');
|
|
| 173 | 173 | if ($this->isProduct4x()) {
|
| 174 | 174 | $publicKey = $this->cfg['pagantis_public_key_4x']; |
| 175 | 175 | $secretKey = $this->cfg['pagantis_private_key_4x']; |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | $status = '-'; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - if ($status === Order::STATUS_CONFIRMED) {
|
|
| 203 | + if ($status===Order::STATUS_CONFIRMED) {
|
|
| 204 | 204 | return true; |
| 205 | 205 | } |
| 206 | 206 | throw new WrongStatusException($status); |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | ); |
| 222 | 222 | |
| 223 | 223 | if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM
|
| 224 | - $logMessage = "WARNING checkMerchantOrderStatus." . |
|
| 224 | + $logMessage = "WARNING checkMerchantOrderStatus.". |
|
| 225 | 225 | " Merchant order id:".$this->woocommerceOrder->get_id(). |
| 226 | 226 | " Merchant order status:".$this->woocommerceOrder->get_status(). |
| 227 | 227 | " Pagantis order id:".$this->pagantisOrder->getStatus(). |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | {
|
| 244 | 244 | $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
| 245 | 245 | $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total())); |
| 246 | - if ($pagantisAmount != $wcAmount) {
|
|
| 246 | + if ($pagantisAmount!=$wcAmount) {
|
|
| 247 | 247 | throw new AmountMismatchException($pagantisAmount, $wcAmount); |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId); |
| 268 | 268 | } catch (\Exception $e) {
|
| 269 | 269 | $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId); |
| 270 | - if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) {
|
|
| 270 | + if ($this->pagantisOrder->getStatus()!==Order::STATUS_CONFIRMED) {
|
|
| 271 | 271 | throw new UnknownException($e->getMessage()); |
| 272 | 272 | } else {
|
| 273 | 273 | $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process'; |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | global $wpdb; |
| 292 | 292 | $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
| 293 | 293 | |
| 294 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 294 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 295 | 295 | $charset_collate = $wpdb->get_charset_collate(); |
| 296 | 296 | $sql = "CREATE TABLE $tableName (id int, order_id varchar(50), wc_order_id varchar(50), |
| 297 | 297 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | global $wpdb; |
| 310 | 310 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
| 311 | 311 | |
| 312 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 312 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 313 | 313 | $charset_collate = $wpdb->get_charset_collate(); |
| 314 | 314 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
| 315 | 315 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -366,12 +366,12 @@ discard block |
||
| 366 | 366 | $metadataOrder = $this->pagantisOrder->getMetadata(); |
| 367 | 367 | $metadataInfo = null; |
| 368 | 368 | foreach ($metadataOrder as $metadataKey => $metadataValue) {
|
| 369 | - if ($metadataKey == 'promotedProduct') {
|
|
| 370 | - $metadataInfo.= "/Producto promocionado = $metadataValue"; |
|
| 369 | + if ($metadataKey=='promotedProduct') {
|
|
| 370 | + $metadataInfo .= "/Producto promocionado = $metadataValue"; |
|
| 371 | 371 | } |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - if ($metadataInfo != null) {
|
|
| 374 | + if ($metadataInfo!=null) {
|
|
| 375 | 375 | $this->woocommerceOrder->add_order_note($metadataInfo); |
| 376 | 376 | } |
| 377 | 377 | |
@@ -440,13 +440,13 @@ discard block |
||
| 440 | 440 | {
|
| 441 | 441 | global $wpdb; |
| 442 | 442 | $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE; |
| 443 | - if ($orderId == null) {
|
|
| 443 | + if ($orderId==null) {
|
|
| 444 | 444 | $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT." SECOND)"; |
| 445 | 445 | } else {
|
| 446 | 446 | $query = "DELETE FROM $tableName WHERE order_id = $orderId"; |
| 447 | 447 | } |
| 448 | 448 | $resultDelete = $wpdb->query($query); |
| 449 | - if ($resultDelete === false) {
|
|
| 449 | + if ($resultDelete===false) {
|
|
| 450 | 450 | throw new ConcurrencyException(); |
| 451 | 451 | } |
| 452 | 452 | } |
@@ -461,8 +461,8 @@ discard block |
||
| 461 | 461 | global $wpdb; |
| 462 | 462 | $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE; |
| 463 | 463 | $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId));
|
| 464 | - if ($insertResult === false) {
|
|
| 465 | - if ($this->getOrigin() == 'Notify') {
|
|
| 464 | + if ($insertResult===false) {
|
|
| 465 | + if ($this->getOrigin()=='Notify') {
|
|
| 466 | 466 | throw new ConcurrencyException(); |
| 467 | 467 | } else {
|
| 468 | 468 | $query = sprintf( |
@@ -473,8 +473,8 @@ discard block |
||
| 473 | 473 | ); |
| 474 | 474 | $resultSeconds = $wpdb->get_row($query); |
| 475 | 475 | $restSeconds = isset($resultSeconds) ? ($resultSeconds->rest) : 0; |
| 476 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
| 477 | - sleep($secondsToExpire+1); |
|
| 476 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
| 477 | + sleep($secondsToExpire + 1); |
|
| 478 | 478 | |
| 479 | 479 | $logMessage = sprintf( |
| 480 | 480 | "User waiting %s seconds, default seconds %s, bd time to expire %s seconds", |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | {
|
| 500 | 500 | $this->unblockConcurrency($this->woocommerceOrderId); |
| 501 | 501 | |
| 502 | - if ($exception == null) {
|
|
| 502 | + if ($exception==null) {
|
|
| 503 | 503 | $jsonResponse = new JsonSuccessResponse(); |
| 504 | 504 | } else {
|
| 505 | 505 | $jsonResponse = new JsonExceptionResponse(); |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | $jsonResponse->setMerchantOrderId($this->woocommerceOrderId); |
| 510 | 510 | $jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
| 511 | 511 | |
| 512 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
| 512 | + if ($_SERVER['REQUEST_METHOD']=='POST') {
|
|
| 513 | 513 | $jsonResponse->printResponse(); |
| 514 | 514 | } else {
|
| 515 | 515 | return $jsonResponse; |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | */ |
| 542 | 542 | private function isProduct4x() |
| 543 | 543 | {
|
| 544 | - return ($this->product === Ucfirst(WcPagantis4xGateway::METHOD_ID)); |
|
| 544 | + return ($this->product===Ucfirst(WcPagantis4xGateway::METHOD_ID)); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | /** |
@@ -282,9 +282,9 @@ |
||
| 282 | 282 | if ($promotedProduct == 'true') {
|
| 283 | 283 | $promotedAmount+=$product->getAmount(); |
| 284 | 284 | $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
| 285 | - ' - Price: ' . $item->get_total() . |
|
| 286 | - ' - Qty: ' . $product->getQuantity() . |
|
| 287 | - ' - Item ID: ' . $item['id_product']; |
|
| 285 | + ' - Price: ' . $item->get_total() . |
|
| 286 | + ' - Qty: ' . $product->getQuantity() . |
|
| 287 | + ' - Item ID: ' . $item['id_product']; |
|
| 288 | 288 | $promotedMessage = substr($promotedMessage, 0, 999); |
| 289 | 289 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage);
|
| 290 | 290 | } |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | $this->method_title = ucfirst($this->id); |
| 55 | 55 | |
| 56 | 56 | //Useful vars |
| 57 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/'; |
|
| 57 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/'; |
|
| 58 | 58 | $this->allowed_currencies = array("EUR");
|
| 59 | - $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Pagantis.php'; |
|
| 59 | + $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)).'/WC_Pagantis.php'; |
|
| 60 | 60 | $this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false);
|
| 61 | 61 | $this->language = strstr(get_locale(), '_', true); |
| 62 | 62 | if ($this->language=='') {
|
@@ -65,25 +65,25 @@ discard block |
||
| 65 | 65 | $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
| 66 | 66 | |
| 67 | 67 | //Panel form fields |
| 68 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options |
|
| 68 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options |
|
| 69 | 69 | $this->init_settings(); |
| 70 | 70 | |
| 71 | 71 | $this->extraConfig = $this->getExtraConfig(); |
| 72 | 72 | $this->title = __($this->extraConfig['PAGANTIS_TITLE'], 'pagantis'); |
| 73 | 73 | $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis."; |
| 74 | 74 | |
| 75 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl(); |
|
| 76 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl(); |
|
| 75 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
| 76 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
| 77 | 77 | foreach ($this->settings as $setting_key => $setting_value) {
|
| 78 | 78 | $this->$setting_key = $setting_value; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | //Hooks |
| 82 | - add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options
|
|
| 83 | - add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields
|
|
| 84 | - add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form
|
|
| 85 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification
|
|
| 86 | - add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3);
|
|
| 82 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options
|
|
| 83 | + add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields
|
|
| 84 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form
|
|
| 85 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification
|
|
| 86 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3);
|
|
| 87 | 87 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2);
|
| 88 | 88 | } |
| 89 | 89 | |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function loadPagantisTranslation($mofile, $domain) |
| 97 | 97 | {
|
| 98 | - if ('pagantis' === $domain) {
|
|
| 99 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 98 | + if ('pagantis'===$domain) {
|
|
| 99 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 100 | 100 | } |
| 101 | 101 | return $mofile; |
| 102 | 102 | } |
@@ -128,24 +128,24 @@ discard block |
||
| 128 | 128 | public function pagantisCheckFields() |
| 129 | 129 | {
|
| 130 | 130 | $error_string = ''; |
| 131 | - if ($this->settings['enabled'] !== 'yes') {
|
|
| 131 | + if ($this->settings['enabled']!=='yes') {
|
|
| 132 | 132 | return; |
| 133 | 133 | } elseif (!version_compare(phpversion(), '5.3.0', '>=')) {
|
| 134 | - $error_string = __(' is not compatible with your php and/or curl version', 'pagantis');
|
|
| 134 | + $error_string = __(' is not compatible with your php and/or curl version', 'pagantis');
|
|
| 135 | 135 | $this->settings['enabled'] = 'no'; |
| 136 | 136 | } elseif ($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="") {
|
| 137 | 137 | $error_string = __(' is not configured correctly, the fields Public Key and Secret Key are mandatory for use this plugin', 'pagantis');
|
| 138 | 138 | $this->settings['enabled'] = 'no'; |
| 139 | 139 | } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) {
|
| 140 | - $error_string = __(' only can be used in Euros', 'pagantis');
|
|
| 140 | + $error_string = __(' only can be used in Euros', 'pagantis');
|
|
| 141 | 141 | $this->settings['enabled'] = 'no'; |
| 142 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']<'2' |
|
| 143 | - || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']>'12') {
|
|
| 142 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] < '2' |
|
| 143 | + || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] > '12') {
|
|
| 144 | 144 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis');
|
| 145 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']<'2' |
|
| 146 | - || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']>'12') {
|
|
| 145 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] < '2' |
|
| 146 | + || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] > '12') {
|
|
| 147 | 147 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis');
|
| 148 | - } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']<0) {
|
|
| 148 | + } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] < 0) {
|
|
| 149 | 149 | $error_string = __(' can not have a minimum amount less than 0', 'pagantis');
|
| 150 | 150 | } |
| 151 | 151 | |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | $shippingAddress = $order->get_address('shipping');
|
| 181 | 181 | $billingAddress = $order->get_address('billing');
|
| 182 | - if ($shippingAddress['address_1'] == '') {
|
|
| 182 | + if ($shippingAddress['address_1']=='') {
|
|
| 183 | 183 | $shippingAddress = $billingAddress; |
| 184 | 184 | } |
| 185 | 185 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | ->setNationalId($national_id) |
| 207 | 207 | ->setTaxId($tax_id) |
| 208 | 208 | ; |
| 209 | - $orderBillingAddress = new Address(); |
|
| 209 | + $orderBillingAddress = new Address(); |
|
| 210 | 210 | $orderBillingAddress |
| 211 | 211 | ->setZipCode($billingAddress['postcode']) |
| 212 | 212 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
@@ -277,12 +277,12 @@ discard block |
||
| 277 | 277 | $details->addProduct($product); |
| 278 | 278 | |
| 279 | 279 | $promotedProduct = $this->isPromoted($item->get_product_id()); |
| 280 | - if ($promotedProduct == 'true') {
|
|
| 281 | - $promotedAmount+=$product->getAmount(); |
|
| 282 | - $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
|
| 283 | - ' - Price: ' . $item->get_total() . |
|
| 284 | - ' - Qty: ' . $product->getQuantity() . |
|
| 285 | - ' - Item ID: ' . $item['id_product']; |
|
| 280 | + if ($promotedProduct=='true') {
|
|
| 281 | + $promotedAmount += $product->getAmount(); |
|
| 282 | + $promotedMessage = 'Promoted Item: '.$wcProduct->get_name(). |
|
| 283 | + ' - Price: '.$item->get_total(). |
|
| 284 | + ' - Qty: '.$product->getQuantity(). |
|
| 285 | + ' - Item ID: '.$item['id_product']; |
|
| 286 | 286 | $promotedMessage = substr($promotedMessage, 0, 999); |
| 287 | 287 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage);
|
| 288 | 288 | } |
@@ -326,9 +326,7 @@ discard block |
||
| 326 | 326 | |
| 327 | 327 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
| 328 | 328 | $purchaseCountry = |
| 329 | - in_array(strtolower($this->language), $allowedCountries) ? $this->language : |
|
| 330 | - in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : |
|
| 331 | - in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null; |
|
| 329 | + 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; |
|
| 332 | 330 | |
| 333 | 331 | $orderConfiguration = new Configuration(); |
| 334 | 332 | $orderConfiguration |
@@ -370,7 +368,7 @@ discard block |
||
| 370 | 368 | wc_get_template('iframe.php', $template_fields, '', $this->template_path);
|
| 371 | 369 | } |
| 372 | 370 | } catch (\Exception $exception) {
|
| 373 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error');
|
|
| 371 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error');
|
|
| 374 | 372 | $this->insertLog($exception); |
| 375 | 373 | $checkout_url = get_permalink(wc_get_page_id('checkout'));
|
| 376 | 374 | wp_redirect($checkout_url); |
@@ -384,7 +382,7 @@ discard block |
||
| 384 | 382 | public function pagantisNotification() |
| 385 | 383 | {
|
| 386 | 384 | try {
|
| 387 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
| 385 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
| 388 | 386 | |
| 389 | 387 | include_once('notifyController.php');
|
| 390 | 388 | $notify = new WcPagantisNotify(); |
@@ -423,10 +421,10 @@ discard block |
||
| 423 | 421 | */ |
| 424 | 422 | public function pagantisCompleteStatus($status, $order_id, $order) |
| 425 | 423 | {
|
| 426 | - if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) {
|
|
| 427 | - if ($order->get_status() == 'failed') {
|
|
| 424 | + if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) {
|
|
| 425 | + if ($order->get_status()=='failed') {
|
|
| 428 | 426 | $status = 'processing'; |
| 429 | - } elseif ($order->get_status() == 'pending' && $status=='completed') {
|
|
| 427 | + } elseif ($order->get_status()=='pending' && $status=='completed') {
|
|
| 430 | 428 | $status = 'processing'; |
| 431 | 429 | } |
| 432 | 430 | } |
@@ -451,8 +449,8 @@ discard block |
||
| 451 | 449 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
| 452 | 450 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
| 453 | 451 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
| 454 | - $totalPrice = (int)$this->get_order_total(); |
|
| 455 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
| 452 | + $totalPrice = (int) $this->get_order_total(); |
|
| 453 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
| 456 | 454 | if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' && |
| 457 | 455 | $validAmount && $allowedCountry) {
|
| 458 | 456 | return true; |
@@ -482,7 +480,7 @@ discard block |
||
| 482 | 480 | |
| 483 | 481 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
| 484 | 482 | if (strpos($redirectUrl, 'order-pay=')===false) {
|
| 485 | - $redirectUrl.="&order-pay=".$order_id; |
|
| 483 | + $redirectUrl .= "&order-pay=".$order_id; |
|
| 486 | 484 | } |
| 487 | 485 | |
| 488 | 486 | return array( |
@@ -491,7 +489,7 @@ discard block |
||
| 491 | 489 | ); |
| 492 | 490 | |
| 493 | 491 | } catch (Exception $e) {
|
| 494 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error');
|
|
| 492 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error');
|
|
| 495 | 493 | return array(); |
| 496 | 494 | } |
| 497 | 495 | } |
@@ -557,7 +555,7 @@ discard block |
||
| 557 | 555 | private function generateUrl($url) |
| 558 | 556 | {
|
| 559 | 557 | $parsed_url = parse_url($url); |
| 560 | - if ($parsed_url !== false) {
|
|
| 558 | + if ($parsed_url!==false) {
|
|
| 561 | 559 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
| 562 | 560 | parse_str($parsed_url['query'], $arrayParams); |
| 563 | 561 | foreach ($arrayParams as $keyParam => $valueParam) {
|
@@ -605,11 +603,10 @@ discard block |
||
| 605 | 603 | private function getKeysUrl($order, $url) |
| 606 | 604 | {
|
| 607 | 605 | $defaultFields = (get_class($order)=='WC_Order') ? |
| 608 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) :
|
|
| 609 | - array(); |
|
| 606 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array();
|
|
| 610 | 607 | |
| 611 | 608 | $parsedUrl = parse_url($url); |
| 612 | - if ($parsedUrl !== false) {
|
|
| 609 | + if ($parsedUrl!==false) {
|
|
| 613 | 610 | //Replace parameters from url |
| 614 | 611 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
| 615 | 612 | |
@@ -654,7 +651,7 @@ discard block |
||
| 654 | 651 | foreach ($arrayParams as $keyParam => $valueParam) {
|
| 655 | 652 | preg_match('#\{{.*?}\}#', $valueParam, $match);
|
| 656 | 653 | if (count($match)) {
|
| 657 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]);
|
|
| 654 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]);
|
|
| 658 | 655 | $arrayParams[$keyParam] = $defaultFields[$key]; |
| 659 | 656 | } |
| 660 | 657 | } |
@@ -669,13 +666,13 @@ discard block |
||
| 669 | 666 | */ |
| 670 | 667 | private function unparseUrl($parsed_url) |
| 671 | 668 | {
|
| 672 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
| 669 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
| 673 | 670 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
| 674 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
| 675 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
| 676 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
| 671 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
| 672 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
| 673 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
| 677 | 674 | $path = $parsed_url['path']; |
| 678 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
| 675 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
| 679 | 676 | } |
| 680 | 677 | |
| 681 | 678 | /** |
@@ -697,20 +694,20 @@ discard block |
||
| 697 | 694 | $is_guest = "false"; |
| 698 | 695 | $sign_up = substr($current_user->user_registered, 0, 10); |
| 699 | 696 | $customer_orders = get_posts(array( |
| 700 | - 'numberposts' => - 1, |
|
| 697 | + 'numberposts' => -1, |
|
| 701 | 698 | 'meta_key' => '_customer_user', |
| 702 | 699 | 'meta_value' => $current_user->ID, |
| 703 | - 'post_type' => array( 'shop_order' ), |
|
| 704 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded' ), |
|
| 700 | + 'post_type' => array('shop_order'),
|
|
| 701 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
|
|
| 705 | 702 | )); |
| 706 | 703 | } else {
|
| 707 | 704 | $is_guest = "true"; |
| 708 | 705 | $customer_orders = get_posts(array( |
| 709 | - 'numberposts' => - 1, |
|
| 706 | + 'numberposts' => -1, |
|
| 710 | 707 | 'meta_key' => '_billing_email', |
| 711 | 708 | 'meta_value' => $billingEmail, |
| 712 | - 'post_type' => array( 'shop_order' ), |
|
| 713 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded'), |
|
| 709 | + 'post_type' => array('shop_order'),
|
|
| 710 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
|
|
| 714 | 711 | )); |
| 715 | 712 | foreach ($customer_orders as $customer_order) {
|
| 716 | 713 | if (trim($sign_up)=='' || |
@@ -739,7 +736,7 @@ discard block |
||
| 739 | 736 | //Check if id exists |
| 740 | 737 | $resultsSelect = $wpdb->get_results("select * from $tableName where id='$orderId'");
|
| 741 | 738 | $countResults = count($resultsSelect); |
| 742 | - if ($countResults == 0) {
|
|
| 739 | + if ($countResults==0) {
|
|
| 743 | 740 | $wpdb->insert( |
| 744 | 741 | $tableName, |
| 745 | 742 | array('id' => $orderId, 'order_id' => $pagantisOrderId),
|
@@ -764,7 +761,7 @@ discard block |
||
| 764 | 761 | global $wpdb; |
| 765 | 762 | $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
| 766 | 763 | |
| 767 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 764 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 768 | 765 | $charset_collate = $wpdb->get_charset_collate(); |
| 769 | 766 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
| 770 | 767 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -797,9 +794,9 @@ discard block |
||
| 797 | 794 | */ |
| 798 | 795 | private function getNationalId($order) |
| 799 | 796 | {
|
| 800 | - foreach ((array)$order->get_meta_data() as $mdObject) {
|
|
| 797 | + foreach ((array) $order->get_meta_data() as $mdObject) {
|
|
| 801 | 798 | $data = $mdObject->get_data(); |
| 802 | - if ($data['key'] == 'vat_number') {
|
|
| 799 | + if ($data['key']=='vat_number') {
|
|
| 803 | 800 | return $data['value']; |
| 804 | 801 | } |
| 805 | 802 | } |
@@ -814,9 +811,9 @@ discard block |
||
| 814 | 811 | */ |
| 815 | 812 | private function getTaxId($order) |
| 816 | 813 | {
|
| 817 | - foreach ((array)$order->get_meta_data() as $mdObject) {
|
|
| 814 | + foreach ((array) $order->get_meta_data() as $mdObject) {
|
|
| 818 | 815 | $data = $mdObject->get_data(); |
| 819 | - if ($data['key'] == 'billing_cfpiva') {
|
|
| 816 | + if ($data['key']=='billing_cfpiva') {
|
|
| 820 | 817 | return $data['value']; |
| 821 | 818 | } |
| 822 | 819 | } |
@@ -846,7 +843,7 @@ discard block |
||
| 846 | 843 | {
|
| 847 | 844 | global $wpdb; |
| 848 | 845 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
| 849 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 846 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 850 | 847 | $charset_collate = $wpdb->get_charset_collate(); |
| 851 | 848 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
| 852 | 849 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -865,7 +862,7 @@ discard block |
||
| 865 | 862 | {
|
| 866 | 863 | $metaProduct = get_post_meta($product_id); |
| 867 | 864 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) &&
|
| 868 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
| 865 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
| 869 | 866 | } |
| 870 | 867 | |
| 871 | 868 | /** |
@@ -878,8 +875,8 @@ discard block |
||
| 878 | 875 | $promotedAmount = 0; |
| 879 | 876 | foreach ($items as $key => $item) {
|
| 880 | 877 | $promotedProduct = $this->isPromoted($item['product_id']); |
| 881 | - if ($promotedProduct == 'true') {
|
|
| 882 | - $promotedAmount+=$item['line_total'] + $item['line_tax']; |
|
| 878 | + if ($promotedProduct=='true') {
|
|
| 879 | + $promotedAmount += $item['line_total'] + $item['line_tax']; |
|
| 883 | 880 | } |
| 884 | 881 | } |
| 885 | 882 | |
@@ -3,11 +3,11 @@ discard block |
||
| 3 | 3 | <div class="pagantisSimulator"></div> |
| 4 | 4 | <script> |
| 5 | 5 | window.WCsimulatorId = null; |
| 6 | - window.product = "<?php echo $product;?>"; |
|
| 6 | + window.product = "<?php echo $product; ?>"; |
|
| 7 | 7 | |
| 8 | 8 | function loadSimulator() |
| 9 | 9 | { |
| 10 | - var product = "<?php echo $product;?>" |
|
| 10 | + var product = "<?php echo $product; ?>" |
|
| 11 | 11 | if(typeof pgSDK == 'undefined') |
| 12 | 12 | { |
| 13 | 13 | return false; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | selector: '.pagantisSimulator', |
| 43 | 43 | totalAmount: '<?php echo $total; ?>', |
| 44 | 44 | totalPromotedAmount: '<?php echo $promoted_amount; ?>', |
| 45 | - skin : <?php echo $pagantisSimulatorSkin;?>, |
|
| 45 | + skin : <?php echo $pagantisSimulatorSkin; ?>, |
|
| 46 | 46 | locale: locale, |
| 47 | 47 | country: country |
| 48 | 48 | }); |
@@ -4,12 +4,12 @@ |
||
| 4 | 4 | { |
| 5 | 5 | if (window.WCSimulatorId != '') |
| 6 | 6 | { |
| 7 | - var updateSelector = '<?php echo $variationSelector;?>'; |
|
| 7 | + var updateSelector = '<?php echo $variationSelector; ?>'; |
|
| 8 | 8 | if (updateSelector === 'default') { |
| 9 | 9 | updateSelector = 'div.woocommerce-variation-price span.price span.woocommerce-Price-amount'; |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | - var productType = '<?php echo $productType;?>'; |
|
| 12 | + var productType = '<?php echo $productType; ?>'; |
|
| 13 | 13 | |
| 14 | 14 | if (productType!=='variable') |
| 15 | 15 | { |
@@ -3,11 +3,11 @@ discard block |
||
| 3 | 3 | <div class="pagantisSimulator4x"></div> |
| 4 | 4 | <script> |
| 5 | 5 | window.WCsimulatorId = null; |
| 6 | - window.product = "<?php echo $product;?>"; |
|
| 6 | + window.product = "<?php echo $product; ?>"; |
|
| 7 | 7 | |
| 8 | 8 | function loadSimulator4x() |
| 9 | 9 | { |
| 10 | - var product = "<?php echo $product;?>" |
|
| 10 | + var product = "<?php echo $product; ?>" |
|
| 11 | 11 | if(typeof pgSDK == 'undefined') |
| 12 | 12 | { |
| 13 | 13 | return false; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | selector: '.pagantisSimulator4x', |
| 43 | 43 | totalAmount: '<?php echo $total; ?>', |
| 44 | 44 | totalPromotedAmount: '<?php echo $promoted_amount; ?>', |
| 45 | - skin : <?php echo $pagantisSimulatorSkin;?>, |
|
| 45 | + skin : <?php echo $pagantisSimulatorSkin; ?>, |
|
| 46 | 46 | locale: locale, |
| 47 | 47 | country: country |
| 48 | 48 | }); |
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | function isPgLogsTableCreated() |
| 8 | 8 | { |
| 9 | 9 | global $wpdb; |
| 10 | - $tableName = $wpdb->prefix . PG_LOGS_TABLE_NAME; |
|
| 11 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) { |
|
| 10 | + $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
|
| 11 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")==$tableName) { |
|
| 12 | 12 | return true; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | global $wpdb; |
| 22 | 22 | $charset_collate = $wpdb->get_charset_collate(); |
| 23 | - $LogsTableName = $wpdb->prefix . PG_LOGS_TABLE_NAME; |
|
| 23 | + $LogsTableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
|
| 24 | 24 | $sqlQuery = "CREATE TABLE $LogsTableName ( |
| 25 | 25 | id int NOT NULL AUTO_INCREMENT, |
| 26 | 26 | log text NOT NULL, |
| 27 | 27 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, |
| 28 | 28 | UNIQUE KEY id (id)) |
| 29 | 29 | $charset_collate"; |
| 30 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 30 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 31 | 31 | dbDelta($sqlQuery); |
| 32 | 32 | } |
| 33 | 33 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | function insertLogEntry($exception = null, $message = null) |
| 39 | 39 | { |
| 40 | 40 | global $wpdb; |
| 41 | - if ( ! isPgLogsTableCreated()) { |
|
| 41 | + if (!isPgLogsTableCreated()) { |
|
| 42 | 42 | createPgLogsTable(); |
| 43 | 43 | } |
| 44 | 44 | $logEntry = new Pagantis\ModuleUtils\Model\Log\LogEntry(); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | } else { |
| 48 | 48 | $logEntry = $logEntry->info($message); |
| 49 | 49 | } |
| 50 | - $tableName = $wpdb->prefix . PG_LOGS_TABLE_NAME; |
|
| 50 | + $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
|
| 51 | 51 | $wpdb->insert($tableName, array('log' => $logEntry->toJson())); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $pgDecimalSeparator = getPgSimulatorDecimalSeparatorConfig(); |
| 60 | 60 | $wc_decimal_sep = get_option('woocommerce_price_decimal_sep'); |
| 61 | - if (stripslashes($wc_decimal_sep) == stripslashes($pgDecimalSeparator)) { |
|
| 61 | + if (stripslashes($wc_decimal_sep)==stripslashes($pgDecimalSeparator)) { |
|
| 62 | 62 | return true; |
| 63 | 63 | } else { |
| 64 | 64 | return false; |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | { |
| 74 | 74 | $pgThousandSeparator = getPgSimulatorThousandsSeparator(); |
| 75 | 75 | $wc_price_thousand = get_option('woocommerce_price_thousand_sep'); |
| 76 | - if (stripslashes($wc_price_thousand) == stripslashes($pgThousandSeparator)) { |
|
| 76 | + if (stripslashes($wc_price_thousand)==stripslashes($pgThousandSeparator)) { |
|
| 77 | 77 | return true; |
| 78 | 78 | } else { |
| 79 | 79 | return false; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | function getPgSimulatorThousandsSeparator() |
| 87 | 87 | { |
| 88 | 88 | global $wpdb; |
| 89 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 89 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 90 | 90 | $query = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
| 91 | 91 | $result = $wpdb->get_row($query, ARRAY_A); |
| 92 | 92 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | function getPgSimulatorDecimalSeparatorConfig() |
| 100 | 100 | { |
| 101 | 101 | global $wpdb; |
| 102 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 102 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 103 | 103 | $query = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'"; |
| 104 | 104 | $result = $wpdb->get_row($query, ARRAY_A); |
| 105 | 105 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | if (areThousandsSeparatorEqual()) { |
| 113 | 113 | return; |
| 114 | 114 | } |
| 115 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 115 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 116 | 116 | $thousandSeparator = get_option('woocommerce_price_thousand_sep'); |
| 117 | 117 | $wpdb->update($tableName, array('value' => $thousandSeparator), array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'), |
| 118 | 118 | array('%s'), array('%s')); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | if (areDecimalSeparatorEqual()) { |
| 125 | 125 | return; |
| 126 | 126 | } |
| 127 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 127 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 128 | 128 | $decimalSeparator = get_option('woocommerce_price_decimal_sep'); |
| 129 | 129 | $wpdb->update($tableName, array('value' => $decimalSeparator), array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'), |
| 130 | 130 | array('%s'), array('%s')); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | function isSimulatorTypeValid($simulatorType, $validSimulatorTypes) |
| 141 | 141 | { |
| 142 | - if ( ! in_array($simulatorType, $validSimulatorTypes)) { |
|
| 142 | + if (!in_array($simulatorType, $validSimulatorTypes)) { |
|
| 143 | 143 | return false; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | function areMerchantKeysSet() |
| 167 | 167 | { |
| 168 | 168 | $settings = get_option('woocommerce_pagantis_settings'); |
| 169 | - $publicKey = ! empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : ''; |
|
| 170 | - $privateKey = ! empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : ''; |
|
| 169 | + $publicKey = !empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : ''; |
|
| 170 | + $privateKey = !empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : ''; |
|
| 171 | 171 | if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) { |
| 172 | 172 | return false; |
| 173 | 173 | } |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | function areMerchantKeysSet4x() |
| 179 | 179 | { |
| 180 | 180 | $settings = get_option('woocommerce_pagantis_settings'); |
| 181 | - $publicKey = ! empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : ''; |
|
| 182 | - $privateKey = ! empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : ''; |
|
| 181 | + $publicKey = !empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : ''; |
|
| 182 | + $privateKey = !empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : ''; |
|
| 183 | 183 | if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) { |
| 184 | 184 | return false; |
| 185 | 185 | } |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | function isSimulatorEnabled() |
| 191 | 191 | { |
| 192 | 192 | $settings = get_option('woocommerce_pagantis_settings'); |
| 193 | - if (( ! empty($settings['simulator']) && 'yes' === $settings['simulator']) ? true : false) { |
|
| 193 | + if ((!empty($settings['simulator']) && 'yes'===$settings['simulator']) ? true : false) { |
|
| 194 | 194 | return true; |
| 195 | 195 | } |
| 196 | 196 | |
@@ -200,13 +200,13 @@ discard block |
||
| 200 | 200 | function isPluginEnabled() |
| 201 | 201 | { |
| 202 | 202 | $settings = get_option('woocommerce_pagantis_settings'); |
| 203 | - return (!empty($settings['enabled']) && 'yes' === $settings['enabled']); |
|
| 203 | + return (!empty($settings['enabled']) && 'yes'===$settings['enabled']); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | function isPluginEnabled4x() |
| 207 | 207 | { |
| 208 | 208 | $settings = get_option('woocommerce_pagantis_settings'); |
| 209 | - return (!empty($settings['enabled_4x']) && 'yes' === $settings['enabled_4x']); |
|
| 209 | + return (!empty($settings['enabled_4x']) && 'yes'===$settings['enabled_4x']); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | { |
| 215 | 215 | $locale = strtolower(strstr(get_locale(), '_', true)); |
| 216 | 216 | $allowedCountries = maybe_unserialize(getConfigValue('PAGANTIS_ALLOWED_COUNTRIES')); |
| 217 | - if ( ! in_array(strtolower($locale), $allowedCountries)) { |
|
| 217 | + if (!in_array(strtolower($locale), $allowedCountries)) { |
|
| 218 | 218 | return false; |
| 219 | 219 | } |
| 220 | 220 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | global $product; |
| 232 | 232 | if (method_exists($product, 'get_price')) { |
| 233 | 233 | $productPrice = $product->get_price(); |
| 234 | - $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0')); |
|
| 234 | + $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0')); |
|
| 235 | 235 | if ($validAmount) { |
| 236 | 236 | return true; |
| 237 | 237 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | global $product; |
| 251 | 251 | if (method_exists($product, 'get_price')) { |
| 252 | 252 | $productPrice = $product->get_price(); |
| 253 | - $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0')); |
|
| 253 | + $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0')); |
|
| 254 | 254 | if ($validAmount) { |
| 255 | 255 | return true; |
| 256 | 256 | } |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | function getConfigValue($configKey) |
| 271 | 271 | { |
| 272 | 272 | global $wpdb; |
| 273 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 273 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 274 | 274 | $value = $wpdb->get_var($wpdb->prepare("SELECT value FROM $tableName WHERE config= %s ", $configKey)); |
| 275 | 275 | |
| 276 | 276 | return $value; |
@@ -245,9 +245,9 @@ discard block |
||
| 245 | 245 | if ($promotedProduct == 'true') { |
| 246 | 246 | $promotedAmount+=$product->getAmount(); |
| 247 | 247 | $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
| 248 | - ' - Price: ' . $item->get_total() . |
|
| 249 | - ' - Qty: ' . $product->getQuantity() . |
|
| 250 | - ' - Item ID: ' . $item['id_product']; |
|
| 248 | + ' - Price: ' . $item->get_total() . |
|
| 249 | + ' - Qty: ' . $product->getQuantity() . |
|
| 250 | + ' - Item ID: ' . $item['id_product']; |
|
| 251 | 251 | $promotedMessage = substr($promotedMessage, 0, 999); |
| 252 | 252 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
| 253 | 253 | } |
@@ -263,9 +263,9 @@ discard block |
||
| 263 | 263 | $orderConfigurationUrls = new Urls(); |
| 264 | 264 | $cancelUrl = $this->getKoUrl($order); |
| 265 | 265 | $callback_arg = array('wc-api'=>'wcpagantisgateway', |
| 266 | - 'key'=>$order->get_order_key(), |
|
| 267 | - 'order-received'=>$order->get_id(), |
|
| 268 | - 'origin' => '' |
|
| 266 | + 'key'=>$order->get_order_key(), |
|
| 267 | + 'order-received'=>$order->get_id(), |
|
| 268 | + 'origin' => '' |
|
| 269 | 269 | ); |
| 270 | 270 | |
| 271 | 271 | $callback_arg_user = $callback_arg; |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | $this->method_title = ucfirst($this->id); |
| 55 | 55 | |
| 56 | 56 | //Useful vars |
| 57 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/'; |
|
| 57 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/'; |
|
| 58 | 58 | $this->allowed_currencies = array("EUR"); |
| 59 | - $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Pagantis.php'; |
|
| 59 | + $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)).'/WC_Pagantis.php'; |
|
| 60 | 60 | $this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false); |
| 61 | 61 | $this->language = strstr(get_locale(), '_', true); |
| 62 | 62 | if ($this->language=='') { |
@@ -65,24 +65,24 @@ discard block |
||
| 65 | 65 | $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
| 66 | 66 | |
| 67 | 67 | //Panel form fields |
| 68 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options |
|
| 68 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options |
|
| 69 | 69 | $this->init_settings(); |
| 70 | 70 | |
| 71 | 71 | $this->extraConfig = $this->getExtraConfig(); |
| 72 | 72 | $this->title = __($this->extraConfig['PAGANTIS_TITLE_4x'], 'pagantis'); |
| 73 | 73 | $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis."; |
| 74 | 74 | |
| 75 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl(); |
|
| 76 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl(); |
|
| 75 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
| 76 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
| 77 | 77 | foreach ($this->settings as $setting_key => $setting_value) { |
| 78 | 78 | $this->$setting_key = $setting_value; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | //Hooks |
| 82 | - add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options |
|
| 83 | - add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
| 84 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
| 85 | - add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3); |
|
| 82 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options |
|
| 83 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
| 84 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
| 85 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3); |
|
| 86 | 86 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function loadPagantisTranslation($mofile, $domain) |
| 96 | 96 | { |
| 97 | - if ('pagantis' === $domain) { |
|
| 98 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 97 | + if ('pagantis'===$domain) { |
|
| 98 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 99 | 99 | } |
| 100 | 100 | return $mofile; |
| 101 | 101 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | $shippingAddress = $order->get_address('shipping'); |
| 144 | 144 | $billingAddress = $order->get_address('billing'); |
| 145 | - if ($shippingAddress['address_1'] == '') { |
|
| 145 | + if ($shippingAddress['address_1']=='') { |
|
| 146 | 146 | $shippingAddress = $billingAddress; |
| 147 | 147 | } |
| 148 | 148 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | ->setNationalId($national_id) |
| 170 | 170 | ->setTaxId($tax_id) |
| 171 | 171 | ; |
| 172 | - $orderBillingAddress = new Address(); |
|
| 172 | + $orderBillingAddress = new Address(); |
|
| 173 | 173 | $orderBillingAddress |
| 174 | 174 | ->setZipCode($billingAddress['postcode']) |
| 175 | 175 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
@@ -242,12 +242,12 @@ discard block |
||
| 242 | 242 | $details->addProduct($product); |
| 243 | 243 | |
| 244 | 244 | $promotedProduct = $this->isPromoted($item->get_product_id()); |
| 245 | - if ($promotedProduct == 'true') { |
|
| 246 | - $promotedAmount+=$product->getAmount(); |
|
| 247 | - $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
|
| 248 | - ' - Price: ' . $item->get_total() . |
|
| 249 | - ' - Qty: ' . $product->getQuantity() . |
|
| 250 | - ' - Item ID: ' . $item['id_product']; |
|
| 245 | + if ($promotedProduct=='true') { |
|
| 246 | + $promotedAmount += $product->getAmount(); |
|
| 247 | + $promotedMessage = 'Promoted Item: '.$wcProduct->get_name(). |
|
| 248 | + ' - Price: '.$item->get_total(). |
|
| 249 | + ' - Qty: '.$product->getQuantity(). |
|
| 250 | + ' - Item ID: '.$item['id_product']; |
|
| 251 | 251 | $promotedMessage = substr($promotedMessage, 0, 999); |
| 252 | 252 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
| 253 | 253 | } |
@@ -293,9 +293,7 @@ discard block |
||
| 293 | 293 | |
| 294 | 294 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
| 295 | 295 | $purchaseCountry = |
| 296 | - in_array(strtolower($this->language), $allowedCountries) ? $this->language : |
|
| 297 | - in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : |
|
| 298 | - in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null; |
|
| 296 | + 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; |
|
| 299 | 297 | |
| 300 | 298 | $orderConfiguration = new Configuration(); |
| 301 | 299 | $orderConfiguration |
@@ -339,7 +337,7 @@ discard block |
||
| 339 | 337 | wc_get_template('iframe.php', $template_fields, '', $this->template_path); |
| 340 | 338 | } |
| 341 | 339 | } catch (\Exception $exception) { |
| 342 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); |
|
| 340 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); |
|
| 343 | 341 | $this->insertLog($exception); |
| 344 | 342 | $checkout_url = get_permalink(wc_get_page_id('checkout')); |
| 345 | 343 | wp_redirect($checkout_url); |
@@ -353,7 +351,7 @@ discard block |
||
| 353 | 351 | public function pagantisNotification() |
| 354 | 352 | { |
| 355 | 353 | try { |
| 356 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
| 354 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
| 357 | 355 | |
| 358 | 356 | include_once('notifyController.php'); |
| 359 | 357 | $notify = new WcPagantisNotify(); |
@@ -392,10 +390,10 @@ discard block |
||
| 392 | 390 | */ |
| 393 | 391 | public function pagantisCompleteStatus($status, $order_id, $order) |
| 394 | 392 | { |
| 395 | - if ($order->get_payment_method() == WcPagantis4xGateway::METHOD_ID) { |
|
| 396 | - if ($order->get_status() == 'failed') { |
|
| 393 | + if ($order->get_payment_method()==WcPagantis4xGateway::METHOD_ID) { |
|
| 394 | + if ($order->get_status()=='failed') { |
|
| 397 | 395 | $status = 'processing'; |
| 398 | - } elseif ($order->get_status() == 'pending' && $status=='completed') { |
|
| 396 | + } elseif ($order->get_status()=='pending' && $status=='completed') { |
|
| 399 | 397 | $status = 'processing'; |
| 400 | 398 | } |
| 401 | 399 | } |
@@ -421,8 +419,8 @@ discard block |
||
| 421 | 419 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
| 422 | 420 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT_4x']; |
| 423 | 421 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT_4x']; |
| 424 | - $totalPrice = (int)$this->get_order_total(); |
|
| 425 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
| 422 | + $totalPrice = (int) $this->get_order_total(); |
|
| 423 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
| 426 | 424 | if ($cfg['enabled_4x']==='yes' && $cfg['pagantis_public_key_4x']!='' && $cfg['pagantis_private_key_4x']!='' && |
| 427 | 425 | $validAmount && $allowedCountry) { |
| 428 | 426 | return true; |
@@ -452,7 +450,7 @@ discard block |
||
| 452 | 450 | |
| 453 | 451 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
| 454 | 452 | if (strpos($redirectUrl, 'order-pay=')===false) { |
| 455 | - $redirectUrl.="&order-pay=".$order_id; |
|
| 453 | + $redirectUrl .= "&order-pay=".$order_id; |
|
| 456 | 454 | } |
| 457 | 455 | |
| 458 | 456 | return array( |
@@ -461,7 +459,7 @@ discard block |
||
| 461 | 459 | ); |
| 462 | 460 | |
| 463 | 461 | } catch (Exception $e) { |
| 464 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); |
|
| 462 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); |
|
| 465 | 463 | return array(); |
| 466 | 464 | } |
| 467 | 465 | } |
@@ -531,7 +529,7 @@ discard block |
||
| 531 | 529 | private function generateUrl($url) |
| 532 | 530 | { |
| 533 | 531 | $parsed_url = parse_url($url); |
| 534 | - if ($parsed_url !== false) { |
|
| 532 | + if ($parsed_url!==false) { |
|
| 535 | 533 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
| 536 | 534 | parse_str($parsed_url['query'], $arrayParams); |
| 537 | 535 | foreach ($arrayParams as $keyParam => $valueParam) { |
@@ -579,11 +577,10 @@ discard block |
||
| 579 | 577 | private function getKeysUrl($order, $url) |
| 580 | 578 | { |
| 581 | 579 | $defaultFields = (get_class($order)=='WC_Order') ? |
| 582 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : |
|
| 583 | - array(); |
|
| 580 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array(); |
|
| 584 | 581 | |
| 585 | 582 | $parsedUrl = parse_url($url); |
| 586 | - if ($parsedUrl !== false) { |
|
| 583 | + if ($parsedUrl!==false) { |
|
| 587 | 584 | //Replace parameters from url |
| 588 | 585 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
| 589 | 586 | |
@@ -628,7 +625,7 @@ discard block |
||
| 628 | 625 | foreach ($arrayParams as $keyParam => $valueParam) { |
| 629 | 626 | preg_match('#\{{.*?}\}#', $valueParam, $match); |
| 630 | 627 | if (count($match)) { |
| 631 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]); |
|
| 628 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]); |
|
| 632 | 629 | $arrayParams[$keyParam] = $defaultFields[$key]; |
| 633 | 630 | } |
| 634 | 631 | } |
@@ -643,13 +640,13 @@ discard block |
||
| 643 | 640 | */ |
| 644 | 641 | private function unparseUrl($parsed_url) |
| 645 | 642 | { |
| 646 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
| 643 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
| 647 | 644 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
| 648 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
| 649 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
| 650 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
| 645 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
| 646 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
| 647 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
| 651 | 648 | $path = $parsed_url['path']; |
| 652 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
| 649 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
| 653 | 650 | } |
| 654 | 651 | |
| 655 | 652 | /** |
@@ -671,20 +668,20 @@ discard block |
||
| 671 | 668 | $is_guest = "false"; |
| 672 | 669 | $sign_up = substr($current_user->user_registered, 0, 10); |
| 673 | 670 | $customer_orders = get_posts(array( |
| 674 | - 'numberposts' => - 1, |
|
| 671 | + 'numberposts' => -1, |
|
| 675 | 672 | 'meta_key' => '_customer_user', |
| 676 | 673 | 'meta_value' => $current_user->ID, |
| 677 | - 'post_type' => array( 'shop_order' ), |
|
| 678 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded' ), |
|
| 674 | + 'post_type' => array('shop_order'), |
|
| 675 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
|
| 679 | 676 | )); |
| 680 | 677 | } else { |
| 681 | 678 | $is_guest = "true"; |
| 682 | 679 | $customer_orders = get_posts(array( |
| 683 | - 'numberposts' => - 1, |
|
| 680 | + 'numberposts' => -1, |
|
| 684 | 681 | 'meta_key' => '_billing_email', |
| 685 | 682 | 'meta_value' => $billingEmail, |
| 686 | - 'post_type' => array( 'shop_order' ), |
|
| 687 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded'), |
|
| 683 | + 'post_type' => array('shop_order'), |
|
| 684 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
|
| 688 | 685 | )); |
| 689 | 686 | foreach ($customer_orders as $customer_order) { |
| 690 | 687 | if (trim($sign_up)=='' || |
@@ -713,7 +710,7 @@ discard block |
||
| 713 | 710 | //Check if id exists |
| 714 | 711 | $resultsSelect = $wpdb->get_results("select * from $tableName where id='$orderId'"); |
| 715 | 712 | $countResults = count($resultsSelect); |
| 716 | - if ($countResults == 0) { |
|
| 713 | + if ($countResults==0) { |
|
| 717 | 714 | $wpdb->insert( |
| 718 | 715 | $tableName, |
| 719 | 716 | array('id' => $orderId, 'order_id' => $pagantisOrderId), |
@@ -738,7 +735,7 @@ discard block |
||
| 738 | 735 | global $wpdb; |
| 739 | 736 | $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
| 740 | 737 | |
| 741 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
| 738 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
| 742 | 739 | $charset_collate = $wpdb->get_charset_collate(); |
| 743 | 740 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
| 744 | 741 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -771,9 +768,9 @@ discard block |
||
| 771 | 768 | */ |
| 772 | 769 | private function getNationalId($order) |
| 773 | 770 | { |
| 774 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
| 771 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
| 775 | 772 | $data = $mdObject->get_data(); |
| 776 | - if ($data['key'] == 'vat_number') { |
|
| 773 | + if ($data['key']=='vat_number') { |
|
| 777 | 774 | return $data['value']; |
| 778 | 775 | } |
| 779 | 776 | } |
@@ -788,9 +785,9 @@ discard block |
||
| 788 | 785 | */ |
| 789 | 786 | private function getTaxId($order) |
| 790 | 787 | { |
| 791 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
| 788 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
| 792 | 789 | $data = $mdObject->get_data(); |
| 793 | - if ($data['key'] == 'billing_cfpiva') { |
|
| 790 | + if ($data['key']=='billing_cfpiva') { |
|
| 794 | 791 | return $data['value']; |
| 795 | 792 | } |
| 796 | 793 | } |
@@ -820,7 +817,7 @@ discard block |
||
| 820 | 817 | { |
| 821 | 818 | global $wpdb; |
| 822 | 819 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
| 823 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
| 820 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
| 824 | 821 | $charset_collate = $wpdb->get_charset_collate(); |
| 825 | 822 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
| 826 | 823 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -839,7 +836,7 @@ discard block |
||
| 839 | 836 | { |
| 840 | 837 | $metaProduct = get_post_meta($product_id); |
| 841 | 838 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && |
| 842 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
| 839 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
| 843 | 840 | } |
| 844 | 841 | |
| 845 | 842 | /** |
@@ -852,8 +849,8 @@ discard block |
||
| 852 | 849 | $promotedAmount = 0; |
| 853 | 850 | foreach ($items as $key => $item) { |
| 854 | 851 | $promotedProduct = $this->isPromoted($item['product_id']); |
| 855 | - if ($promotedProduct == 'true') { |
|
| 856 | - $promotedAmount+=$item['line_total'] + $item['line_tax']; |
|
| 852 | + if ($promotedProduct=='true') { |
|
| 853 | + $promotedAmount += $item['line_total'] + $item['line_tax']; |
|
| 857 | 854 | } |
| 858 | 855 | } |
| 859 | 856 | |
@@ -337,12 +337,12 @@ discard block |
||
| 337 | 337 | updateThousandsSeparatorDbConfig(); |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - //Adapting product price selector < v8.6.7 |
|
| 340 | + //Adapting product price selector < v8.6.7 |
|
| 341 | 341 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 342 | 342 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
| 343 | 343 | $results = $wpdb->get_results($query, ARRAY_A); |
| 344 | 344 | if (count($results) == 0) { |
| 345 | - $wpdb->update($tableName, array('value' => 'a:4:{i:0;s:52:"div.summary *:not(del)>.woocommerce-Price-amount bdi";i:1;s:48:"div.summary *:not(del)>.woocommerce-Price-amount";i:2;s:54:"div.entry-summary *:not(del)>.woocommerce-Price-amount";i:3;s:36:"*:not(del)>.woocommerce-Price-amount";}'), array('config' => 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'), array('%s'), array('%s')); |
|
| 345 | + $wpdb->update($tableName, array('value' => 'a:4:{i:0;s:52:"div.summary *:not(del)>.woocommerce-Price-amount bdi";i:1;s:48:"div.summary *:not(del)>.woocommerce-Price-amount";i:2;s:54:"div.entry-summary *:not(del)>.woocommerce-Price-amount";i:3;s:36:"*:not(del)>.woocommerce-Price-amount";}'), array('config' => 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'), array('%s'), array('%s')); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | if ($file == plugin_basename(__FILE__)) { |
| 624 | 624 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
| 625 | 625 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
| 626 | - __('API documentation', 'pagantis').'</a>'; |
|
| 626 | + __('API documentation', 'pagantis').'</a>'; |
|
| 627 | 627 | $links[] = '<a href="'.WcPagantis::SUPPORT_EML.'">'.__('Support', 'pagantis').'</a>'; |
| 628 | 628 | |
| 629 | 629 | return $links; |
@@ -18,17 +18,17 @@ discard block |
||
| 18 | 18 | exit; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | -if (! defined('PG_WC_MAIN_FILE')) { |
|
| 21 | +if (!defined('PG_WC_MAIN_FILE')) { |
|
| 22 | 22 | define('PG_WC_MAIN_FILE', __FILE__); |
| 23 | 23 | } |
| 24 | -if (! defined('PG_CONFIG_TABLE_NAME')) { |
|
| 24 | +if (!defined('PG_CONFIG_TABLE_NAME')) { |
|
| 25 | 25 | define('PG_CONFIG_TABLE_NAME', 'pagantis_config'); |
| 26 | 26 | } |
| 27 | -if (! defined('PG_LOGS_TABLE_NAME')) { |
|
| 27 | +if (!defined('PG_LOGS_TABLE_NAME')) { |
|
| 28 | 28 | define('PG_LOGS_TABLE_NAME', 'pagantis_logs'); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | -if (! defined('PG_ABSPATH')) { |
|
| 31 | +if (!defined('PG_ABSPATH')) { |
|
| 32 | 32 | define('PG_ABSPATH', trailingslashit(dirname(PG_WC_MAIN_FILE))); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | public function __construct() |
| 90 | 90 | { |
| 91 | 91 | require_once(plugin_dir_path(__FILE__).'/vendor/autoload.php'); |
| 92 | - require_once(PG_ABSPATH . '/includes/pg-functions.php'); |
|
| 92 | + require_once(PG_ABSPATH.'/includes/pg-functions.php'); |
|
| 93 | 93 | $this->template_path = plugin_dir_path(__FILE__).'/templates/'; |
| 94 | 94 | |
| 95 | 95 | $this->pagantisActivation(); |
@@ -105,15 +105,15 @@ discard block |
||
| 105 | 105 | add_action('init', array($this, 'checkWcPriceSettings'), 10); |
| 106 | 106 | add_action('woocommerce_after_template_part', array($this, 'pagantisAddSimulatorHtmlDiv'), 10); |
| 107 | 107 | add_action('woocommerce_single_product_summary', array($this, 'pagantisInitProductSimulator'), 20); |
| 108 | - add_action('woocommerce_single_variation', array($this,'pagantisAddProductSnippetForVariations'), 30); |
|
| 108 | + add_action('woocommerce_single_variation', array($this, 'pagantisAddProductSnippetForVariations'), 30); |
|
| 109 | 109 | add_action('wp_enqueue_scripts', 'add_pagantis_widget_js'); |
| 110 | 110 | add_action('rest_api_init', array($this, 'pagantisRegisterEndpoint')); //Endpoint |
| 111 | 111 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
| 112 | 112 | register_activation_hook(__FILE__, array($this, 'pagantisActivation')); |
| 113 | 113 | add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl')); |
| 114 | 114 | add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave')); |
| 115 | - add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate')); |
|
| 116 | - add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave')); |
|
| 115 | + add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate')); |
|
| 116 | + add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave')); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | { |
| 140 | 140 | $post_id = $product->get_id(); |
| 141 | 141 | $pagantis_promoted_value = $_REQUEST['pagantis_promoted']; |
| 142 | - if ($pagantis_promoted_value === 'on') { |
|
| 142 | + if ($pagantis_promoted_value==='on') { |
|
| 143 | 143 | $pagantis_promoted_value = 'yes'; |
| 144 | 144 | } else { |
| 145 | 145 | $pagantis_promoted_value = 'no'; |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | public function pagantisPromotedVarSave($post_id) |
| 174 | 174 | { |
| 175 | 175 | $pagantis_promoted_value = $_POST['pagantis_promoted']; |
| 176 | - if ($pagantis_promoted_value !== 'yes') { |
|
| 176 | + if ($pagantis_promoted_value!=='yes') { |
|
| 177 | 177 | $pagantis_promoted_value = 'no'; |
| 178 | 178 | } |
| 179 | 179 | |
@@ -187,8 +187,8 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | public function loadPagantisTranslation($mofile, $domain) |
| 189 | 189 | { |
| 190 | - if ('pagantis' === $domain) { |
|
| 191 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 190 | + if ('pagantis'===$domain) { |
|
| 191 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 192 | 192 | } |
| 193 | 193 | return $mofile; |
| 194 | 194 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | global $wpdb; |
| 202 | 202 | |
| 203 | 203 | $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE; |
| 204 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
| 204 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
| 205 | 205 | $charset_collate = $wpdb->get_charset_collate(); |
| 206 | 206 | $sql = "CREATE TABLE $tableName ( order_id int NOT NULL, |
| 207 | 207 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate"; |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 213 | 213 | |
| 214 | 214 | //Check if table exists |
| 215 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; |
|
| 215 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; |
|
| 216 | 216 | if ($tableExists) { |
| 217 | 217 | $charset_collate = $wpdb->get_charset_collate(); |
| 218 | 218 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | //Updated value field to adapt to new length < v8.0.1 |
| 228 | 228 | $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'"; |
| 229 | 229 | $results = $wpdb->get_results($query, ARRAY_A); |
| 230 | - if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') { |
|
| 230 | + if ($results['0']['COLUMN_TYPE']=='varchar(100)') { |
|
| 231 | 231 | $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)"; |
| 232 | 232 | $wpdb->query($sql); |
| 233 | 233 | } |
@@ -237,9 +237,9 @@ discard block |
||
| 237 | 237 | or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
| 238 | 238 | $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A); |
| 239 | 239 | foreach ($dbCurrentConfig as $item) { |
| 240 | - if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
| 240 | + if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
| 241 | 241 | $css_price_selector = $this->preparePriceSelector($item['value']); |
| 242 | - if ($item['value'] != $css_price_selector) { |
|
| 242 | + if ($item['value']!=$css_price_selector) { |
|
| 243 | 243 | $wpdb->update( |
| 244 | 244 | $tableName, |
| 245 | 245 | array('value' => stripslashes($css_price_selector)), |
@@ -248,9 +248,9 @@ discard block |
||
| 248 | 248 | array('%s') |
| 249 | 249 | ); |
| 250 | 250 | } |
| 251 | - } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
| 251 | + } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
| 252 | 252 | $css_quantity_selector = $this->prepareQuantitySelector($item['value']); |
| 253 | - if ($item['value'] != $css_quantity_selector) { |
|
| 253 | + if ($item['value']!=$css_quantity_selector) { |
|
| 254 | 254 | $wpdb->update( |
| 255 | 255 | $tableName, |
| 256 | 256 | array('value' => stripslashes($css_quantity_selector)), |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 268 | 268 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
| 269 | 269 | $results = $wpdb->get_results($query, ARRAY_A); |
| 270 | - if (count($results) == 0) { |
|
| 270 | + if (count($results)==0) { |
|
| 271 | 271 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value' => '.'), array('%s', '%s')); |
| 272 | 272 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value' => ','), array('%s', '%s')); |
| 273 | 273 | } |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 277 | 277 | $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'"; |
| 278 | 278 | $results = $wpdb->get_results($query, ARRAY_A); |
| 279 | - if (count($results) == 0) { |
|
| 279 | + if (count($results)==0) { |
|
| 280 | 280 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value' => '0'), array('%s', '%s')); |
| 281 | 281 | } |
| 282 | 282 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 285 | 285 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'"; |
| 286 | 286 | $results = $wpdb->get_results($query, ARRAY_A); |
| 287 | - if (count($results) == 0) { |
|
| 287 | + if (count($results)==0) { |
|
| 288 | 288 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value' => 'default'), array('%s', '%s')); |
| 289 | 289 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value' => 'default'), array('%s', '%s')); |
| 290 | 290 | } |
@@ -294,17 +294,17 @@ discard block |
||
| 294 | 294 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 295 | 295 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'"; |
| 296 | 296 | $results = $wpdb->get_results($query, ARRAY_A); |
| 297 | - if (count($results) == 0) { |
|
| 297 | + if (count($results)==0) { |
|
| 298 | 298 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', 'value' => 'sdk.simulator.types.CHECKOUT_PAGE'), array('%s', '%s')); |
| 299 | 299 | $wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), array('%s'), array('%s')); |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | //Adapting to variable selector < v8.3.6 |
| 303 | - $variableSelector="div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
| 303 | + $variableSelector = "div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
| 304 | 304 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 305 | 305 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'"; |
| 306 | 306 | $results = $wpdb->get_results($query, ARRAY_A); |
| 307 | - if (count($results) == 0) { |
|
| 307 | + if (count($results)==0) { |
|
| 308 | 308 | $wpdb->update($tableName, array('value' => $variableSelector), array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION'), array('%s'), array('%s')); |
| 309 | 309 | } |
| 310 | 310 | |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 313 | 313 | $query = "select * from $tableName where config='PAGANTIS_TITLE_4x'"; |
| 314 | 314 | $results = $wpdb->get_results($query, ARRAY_A); |
| 315 | - if (count($results) == 0) { |
|
| 315 | + if (count($results)==0) { |
|
| 316 | 316 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_TITLE_4x', 'value' => 'Until 4 installments, without fees'), array('%s', '%s')); |
| 317 | 317 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MIN_AMOUNT_4x', 'value' => 1), array('%s', '%s')); |
| 318 | 318 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT_4x', 'value' => 800), array('%s', '%s')); |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 326 | 326 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X'"; |
| 327 | 327 | $results = $wpdb->get_results($query, ARRAY_A); |
| 328 | - if (count($results) == 0) { |
|
| 328 | + if (count($results)==0) { |
|
| 329 | 329 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X', 'value' => 'default'), array('%s', '%s')); |
| 330 | 330 | } |
| 331 | 331 | |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 342 | 342 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
| 343 | 343 | $results = $wpdb->get_results($query, ARRAY_A); |
| 344 | - if (count($results) == 0) { |
|
| 344 | + if (count($results)==0) { |
|
| 345 | 345 | $wpdb->update($tableName, array('value' => 'a:4:{i:0;s:52:"div.summary *:not(del)>.woocommerce-Price-amount bdi";i:1;s:48:"div.summary *:not(del)>.woocommerce-Price-amount";i:2;s:54:"div.entry-summary *:not(del)>.woocommerce-Price-amount";i:3;s:36:"*:not(del)>.woocommerce-Price-amount";}'), array('config' => 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'), array('%s'), array('%s')); |
| 346 | 346 | } |
| 347 | 347 | |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | $isAtcTplPresent = isTemplatePresent( |
| 436 | 436 | $template_name, |
| 437 | 437 | array('single-product/add-to-cart/variation-add-to-cart-button.php', |
| 438 | - 'single-product/add-to-cart/variation.php','single-product/add-to-cart/simple.php') |
|
| 438 | + 'single-product/add-to-cart/variation.php', 'single-product/add-to-cart/simple.php') |
|
| 439 | 439 | ); |
| 440 | 440 | |
| 441 | 441 | $html = apply_filters('pagantis_simulator_selector_html', '<div class="mainPagantisSimulator"></div><div class="pagantisSimulator"></div>'); |
@@ -447,10 +447,10 @@ discard block |
||
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | $pagantisSimulator4x = 'enabled'; |
| 450 | - if (!isPluginEnabled4x() || !areMerchantKeysSet4x() || !isCountryShopContextValid() || !isProductAmountValid4x()) { |
|
| 450 | + if (!isPluginEnabled4x() || !areMerchantKeysSet4x() || !isCountryShopContextValid() || !isProductAmountValid4x()) { |
|
| 451 | 451 | $pagantisSimulator4x = 'disabled'; |
| 452 | 452 | } |
| 453 | - if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') { |
|
| 453 | + if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') { |
|
| 454 | 454 | return; |
| 455 | 455 | } |
| 456 | 456 | |
@@ -507,12 +507,12 @@ discard block |
||
| 507 | 507 | $pagantisSimulator4x = 'disabled'; |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') { |
|
| 510 | + if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') { |
|
| 511 | 511 | return; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | $totalPrice = $product->get_price(); |
| 515 | - $formattedInstallments = number_format($totalPrice/4, 2); |
|
| 515 | + $formattedInstallments = number_format($totalPrice / 4, 2); |
|
| 516 | 516 | $simulatorMessage = sprintf(__('or 4 installments of %s€, without fees, with ', 'pagantis'), $formattedInstallments); |
| 517 | 517 | $post_id = $product->get_id(); |
| 518 | 518 | $logo = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | */ |
| 556 | 556 | public function addPagantisGateway($methods) |
| 557 | 557 | { |
| 558 | - if (! class_exists('WC_Payment_Gateway')) { |
|
| 558 | + if (!class_exists('WC_Payment_Gateway')) { |
|
| 559 | 559 | return $methods; |
| 560 | 560 | } |
| 561 | 561 | |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | */ |
| 621 | 621 | public function pagantisRowMeta($links, $file) |
| 622 | 622 | { |
| 623 | - if ($file == plugin_basename(__FILE__)) { |
|
| 623 | + if ($file==plugin_basename(__FILE__)) { |
|
| 624 | 624 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
| 625 | 625 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
| 626 | 626 | __('API documentation', 'pagantis').'</a>'; |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
| 650 | 650 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
| 651 | 651 | $results = $wpdb->get_results($query); |
| 652 | - if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) { |
|
| 652 | + if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) { |
|
| 653 | 653 | foreach ($results as $key => $result) { |
| 654 | 654 | $response[$key]['timestamp'] = $result->createdAt; |
| 655 | 655 | $response[$key]['log'] = json_decode($result->log); |
@@ -676,13 +676,13 @@ discard block |
||
| 676 | 676 | |
| 677 | 677 | $filters = ($data->get_params()); |
| 678 | 678 | $secretKey = $filters['secret']; |
| 679 | - $cfg = get_option('woocommerce_pagantis_settings'); |
|
| 679 | + $cfg = get_option('woocommerce_pagantis_settings'); |
|
| 680 | 680 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
| 681 | 681 | $privateKey4x = isset($cfg['pagantis_private_key_4x']) ? $cfg['pagantis_private_key_4x'] : null; |
| 682 | - if ($privateKey != $secretKey && $privateKey4x != $secretKey) { |
|
| 682 | + if ($privateKey!=$secretKey && $privateKey4x!=$secretKey) { |
|
| 683 | 683 | $response['status'] = 401; |
| 684 | 684 | $response['result'] = 'Unauthorized'; |
| 685 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 685 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
| 686 | 686 | if (count($_POST)) { |
| 687 | 687 | foreach ($_POST as $config => $value) { |
| 688 | 688 | if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc"; |
| 744 | 744 | $results = $wpdb->get_results($query); |
| 745 | 745 | |
| 746 | - if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) { |
|
| 746 | + if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) { |
|
| 747 | 747 | foreach ($results as $result) { |
| 748 | 748 | $key = $result->ID; |
| 749 | 749 | $response['message'][$key]['timestamp'] = $result->post_date; |
@@ -766,10 +766,10 @@ discard block |
||
| 766 | 766 | * |
| 767 | 767 | * @return void |
| 768 | 768 | */ |
| 769 | - public function permissionsCheck( $request ) |
|
| 769 | + public function permissionsCheck($request) |
|
| 770 | 770 | { |
| 771 | - if ( ! is_user_logged_in() ) { |
|
| 772 | - return new WP_Error( 'rest_not_logged_in', 'You are not currently logged in.', array( 'status' => 401 ) ); |
|
| 771 | + if (!is_user_logged_in()) { |
|
| 772 | + return new WP_Error('rest_not_logged_in', 'You are not currently logged in.', array('status' => 401)); |
|
| 773 | 773 | } |
| 774 | 774 | return true; |
| 775 | 775 | } |
@@ -854,7 +854,7 @@ discard block |
||
| 854 | 854 | */ |
| 855 | 855 | private function prepareQuantitySelector($css_quantity_selector) |
| 856 | 856 | { |
| 857 | - if ($css_quantity_selector == 'default' || $css_quantity_selector == '') { |
|
| 857 | + if ($css_quantity_selector=='default' || $css_quantity_selector=='') { |
|
| 858 | 858 | $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
| 859 | 859 | } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
| 860 | 860 | $css_quantity_selector = serialize(array($css_quantity_selector)); |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | */ |
| 871 | 871 | private function preparePriceSelector($css_price_selector) |
| 872 | 872 | { |
| 873 | - if ($css_price_selector == 'default' || $css_price_selector == '') { |
|
| 873 | + if ($css_price_selector=='default' || $css_price_selector=='') { |
|
| 874 | 874 | $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
| 875 | 875 | } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
| 876 | 876 | $css_price_selector = serialize(array($css_price_selector)); |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | { |
| 889 | 889 | $metaProduct = get_post_meta($product_id); |
| 890 | 890 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && |
| 891 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
| 891 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
| 892 | 892 | } |
| 893 | 893 | |
| 894 | 894 | /** |