@@ -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); |
@@ -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.self::ORDERS_TABLE; |
| 269 | 269 | |
| 270 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 270 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 271 | 271 | $charset_collate = $wpdb->get_charset_collate(); |
| 272 | 272 | $sql = "CREATE TABLE $tableName (id int, order_id varchar(50), wc_order_id varchar(50), |
| 273 | 273 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | global $wpdb; |
| 286 | 286 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
| 287 | 287 | |
| 288 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 288 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 289 | 289 | $charset_collate = $wpdb->get_charset_collate(); |
| 290 | 290 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
| 291 | 291 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -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.self::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.self::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", |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | {
|
| 476 | 476 | $this->unblockConcurrency($this->woocommerceOrderId); |
| 477 | 477 | |
| 478 | - if ($exception == null) {
|
|
| 478 | + if ($exception==null) {
|
|
| 479 | 479 | $jsonResponse = new JsonSuccessResponse(); |
| 480 | 480 | } else {
|
| 481 | 481 | $jsonResponse = new JsonExceptionResponse(); |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | $jsonResponse->setMerchantOrderId($this->woocommerceOrderId); |
| 486 | 486 | $jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
| 487 | 487 | |
| 488 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
| 488 | + if ($_SERVER['REQUEST_METHOD']=='POST') {
|
|
| 489 | 489 | $jsonResponse->printResponse(); |
| 490 | 490 | } else {
|
| 491 | 491 | return $jsonResponse; |
@@ -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,33 +54,33 @@ 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 | $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
| 63 | 63 | |
| 64 | 64 | //Panel form fields |
| 65 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options |
|
| 65 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options |
|
| 66 | 66 | $this->init_settings(); |
| 67 | 67 | |
| 68 | 68 | $this->extraConfig = $this->getExtraConfig(); |
| 69 | 69 | $this->title = __($this->extraConfig['PAGANTIS_TITLE'], 'pagantis'); |
| 70 | 70 | $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis."; |
| 71 | 71 | |
| 72 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl(); |
|
| 73 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl(); |
|
| 72 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
| 73 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
| 74 | 74 | foreach ($this->settings as $setting_key => $setting_value) {
|
| 75 | 75 | $this->$setting_key = $setting_value; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | //Hooks |
| 79 | - add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options
|
|
| 80 | - add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields
|
|
| 81 | - add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form
|
|
| 82 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification
|
|
| 83 | - add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3);
|
|
| 79 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options
|
|
| 80 | + add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields
|
|
| 81 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form
|
|
| 82 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification
|
|
| 83 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3);
|
|
| 84 | 84 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2);
|
| 85 | 85 | } |
| 86 | 86 | |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function loadPagantisTranslation($mofile, $domain) |
| 94 | 94 | {
|
| 95 | - if ('pagantis' === $domain) {
|
|
| 96 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 95 | + if ('pagantis'===$domain) {
|
|
| 96 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 97 | 97 | } |
| 98 | 98 | return $mofile; |
| 99 | 99 | } |
@@ -125,24 +125,24 @@ discard block |
||
| 125 | 125 | public function pagantisCheckFields() |
| 126 | 126 | {
|
| 127 | 127 | $error_string = ''; |
| 128 | - if ($this->settings['enabled'] !== 'yes') {
|
|
| 128 | + if ($this->settings['enabled']!=='yes') {
|
|
| 129 | 129 | return; |
| 130 | 130 | } elseif (!version_compare(phpversion(), '5.3.0', '>=')) {
|
| 131 | - $error_string = __(' is not compatible with your php and/or curl version', 'pagantis');
|
|
| 131 | + $error_string = __(' is not compatible with your php and/or curl version', 'pagantis');
|
|
| 132 | 132 | $this->settings['enabled'] = 'no'; |
| 133 | 133 | } elseif ($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="") {
|
| 134 | 134 | $error_string = __(' is not configured correctly, the fields Public Key and Secret Key are mandatory for use this plugin', 'pagantis');
|
| 135 | 135 | $this->settings['enabled'] = 'no'; |
| 136 | 136 | } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) {
|
| 137 | - $error_string = __(' only can be used in Euros', 'pagantis');
|
|
| 137 | + $error_string = __(' only can be used in Euros', 'pagantis');
|
|
| 138 | 138 | $this->settings['enabled'] = 'no'; |
| 139 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']<'2' |
|
| 140 | - || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']>'12') {
|
|
| 139 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] < '2' |
|
| 140 | + || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] > '12') {
|
|
| 141 | 141 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis');
|
| 142 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']<'2' |
|
| 143 | - || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']>'12') {
|
|
| 142 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] < '2' |
|
| 143 | + || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] > '12') {
|
|
| 144 | 144 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis');
|
| 145 | - } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']<0) {
|
|
| 145 | + } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] < 0) {
|
|
| 146 | 146 | $error_string = __(' can not have a minimum amount less than 0', 'pagantis');
|
| 147 | 147 | } |
| 148 | 148 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | $shippingAddress = $order->get_address('shipping');
|
| 178 | 178 | $billingAddress = $order->get_address('billing');
|
| 179 | - if ($shippingAddress['address_1'] == '') {
|
|
| 179 | + if ($shippingAddress['address_1']=='') {
|
|
| 180 | 180 | $shippingAddress = $billingAddress; |
| 181 | 181 | } |
| 182 | 182 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | ->setNationalId($national_id) |
| 204 | 204 | ->setTaxId($tax_id) |
| 205 | 205 | ; |
| 206 | - $orderBillingAddress = new Address(); |
|
| 206 | + $orderBillingAddress = new Address(); |
|
| 207 | 207 | $orderBillingAddress |
| 208 | 208 | ->setZipCode($billingAddress['postcode']) |
| 209 | 209 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
@@ -274,12 +274,12 @@ discard block |
||
| 274 | 274 | $details->addProduct($product); |
| 275 | 275 | |
| 276 | 276 | $promotedProduct = $this->isPromoted($item->get_product_id()); |
| 277 | - if ($promotedProduct == 'true') {
|
|
| 278 | - $promotedAmount+=$product->getAmount(); |
|
| 279 | - $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
|
| 280 | - ' - Price: ' . $item->get_total() . |
|
| 281 | - ' - Qty: ' . $product->getQuantity() . |
|
| 282 | - ' - Item ID: ' . $item['id_product']; |
|
| 277 | + if ($promotedProduct=='true') {
|
|
| 278 | + $promotedAmount += $product->getAmount(); |
|
| 279 | + $promotedMessage = 'Promoted Item: '.$wcProduct->get_name(). |
|
| 280 | + ' - Price: '.$item->get_total(). |
|
| 281 | + ' - Qty: '.$product->getQuantity(). |
|
| 282 | + ' - Item ID: '.$item['id_product']; |
|
| 283 | 283 | $promotedMessage = substr($promotedMessage, 0, 999); |
| 284 | 284 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage);
|
| 285 | 285 | } |
@@ -323,9 +323,7 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
| 325 | 325 | $purchaseCountry = |
| 326 | - in_array(strtolower($this->language), $allowedCountries) ? $this->language : |
|
| 327 | - in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : |
|
| 328 | - in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null; |
|
| 326 | + 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; |
|
| 329 | 327 | |
| 330 | 328 | $orderConfiguration = new Configuration(); |
| 331 | 329 | $orderConfiguration |
@@ -367,7 +365,7 @@ discard block |
||
| 367 | 365 | wc_get_template('iframe.php', $template_fields, '', $this->template_path);
|
| 368 | 366 | } |
| 369 | 367 | } catch (\Exception $exception) {
|
| 370 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error');
|
|
| 368 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error');
|
|
| 371 | 369 | $this->insertLog($exception); |
| 372 | 370 | $checkout_url = get_permalink(wc_get_page_id('checkout'));
|
| 373 | 371 | wp_redirect($checkout_url); |
@@ -381,7 +379,7 @@ discard block |
||
| 381 | 379 | public function pagantisNotification() |
| 382 | 380 | {
|
| 383 | 381 | try {
|
| 384 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
| 382 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
| 385 | 383 | |
| 386 | 384 | include_once('notifyController.php');
|
| 387 | 385 | $notify = new WcPagantisNotify(); |
@@ -420,10 +418,10 @@ discard block |
||
| 420 | 418 | */ |
| 421 | 419 | public function pagantisCompleteStatus($status, $order_id, $order) |
| 422 | 420 | {
|
| 423 | - if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) {
|
|
| 424 | - if ($order->get_status() == 'failed') {
|
|
| 421 | + if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) {
|
|
| 422 | + if ($order->get_status()=='failed') {
|
|
| 425 | 423 | $status = 'processing'; |
| 426 | - } elseif ($order->get_status() == 'pending' && $status=='completed') {
|
|
| 424 | + } elseif ($order->get_status()=='pending' && $status=='completed') {
|
|
| 427 | 425 | $status = 'processing'; |
| 428 | 426 | } |
| 429 | 427 | } |
@@ -448,8 +446,8 @@ discard block |
||
| 448 | 446 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
| 449 | 447 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
| 450 | 448 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
| 451 | - $totalPrice = (int)$this->get_order_total(); |
|
| 452 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
| 449 | + $totalPrice = (int) $this->get_order_total(); |
|
| 450 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
| 453 | 451 | if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' && |
| 454 | 452 | $validAmount && $allowedCountry) {
|
| 455 | 453 | return true; |
@@ -479,7 +477,7 @@ discard block |
||
| 479 | 477 | |
| 480 | 478 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
| 481 | 479 | if (strpos($redirectUrl, 'order-pay=')===false) {
|
| 482 | - $redirectUrl.="&order-pay=".$order_id; |
|
| 480 | + $redirectUrl .= "&order-pay=".$order_id; |
|
| 483 | 481 | } |
| 484 | 482 | |
| 485 | 483 | return array( |
@@ -488,7 +486,7 @@ discard block |
||
| 488 | 486 | ); |
| 489 | 487 | |
| 490 | 488 | } catch (Exception $e) {
|
| 491 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error');
|
|
| 489 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error');
|
|
| 492 | 490 | return array(); |
| 493 | 491 | } |
| 494 | 492 | } |
@@ -553,7 +551,7 @@ discard block |
||
| 553 | 551 | private function generateUrl($url) |
| 554 | 552 | {
|
| 555 | 553 | $parsed_url = parse_url($url); |
| 556 | - if ($parsed_url !== false) {
|
|
| 554 | + if ($parsed_url!==false) {
|
|
| 557 | 555 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
| 558 | 556 | parse_str($parsed_url['query'], $arrayParams); |
| 559 | 557 | foreach ($arrayParams as $keyParam => $valueParam) {
|
@@ -601,11 +599,10 @@ discard block |
||
| 601 | 599 | private function getKeysUrl($order, $url) |
| 602 | 600 | {
|
| 603 | 601 | $defaultFields = (get_class($order)=='WC_Order') ? |
| 604 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) :
|
|
| 605 | - array(); |
|
| 602 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array();
|
|
| 606 | 603 | |
| 607 | 604 | $parsedUrl = parse_url($url); |
| 608 | - if ($parsedUrl !== false) {
|
|
| 605 | + if ($parsedUrl!==false) {
|
|
| 609 | 606 | //Replace parameters from url |
| 610 | 607 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
| 611 | 608 | |
@@ -650,7 +647,7 @@ discard block |
||
| 650 | 647 | foreach ($arrayParams as $keyParam => $valueParam) {
|
| 651 | 648 | preg_match('#\{{.*?}\}#', $valueParam, $match);
|
| 652 | 649 | if (count($match)) {
|
| 653 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]);
|
|
| 650 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]);
|
|
| 654 | 651 | $arrayParams[$keyParam] = $defaultFields[$key]; |
| 655 | 652 | } |
| 656 | 653 | } |
@@ -665,13 +662,13 @@ discard block |
||
| 665 | 662 | */ |
| 666 | 663 | private function unparseUrl($parsed_url) |
| 667 | 664 | {
|
| 668 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
| 665 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
| 669 | 666 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
| 670 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
| 671 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
| 672 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
| 667 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
| 668 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
| 669 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
| 673 | 670 | $path = $parsed_url['path']; |
| 674 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
| 671 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
| 675 | 672 | } |
| 676 | 673 | |
| 677 | 674 | /** |
@@ -693,20 +690,20 @@ discard block |
||
| 693 | 690 | $is_guest = "false"; |
| 694 | 691 | $sign_up = substr($current_user->user_registered, 0, 10); |
| 695 | 692 | $customer_orders = get_posts(array( |
| 696 | - 'numberposts' => - 1, |
|
| 693 | + 'numberposts' => -1, |
|
| 697 | 694 | 'meta_key' => '_customer_user', |
| 698 | 695 | 'meta_value' => $current_user->ID, |
| 699 | - 'post_type' => array( 'shop_order' ), |
|
| 700 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded' ), |
|
| 696 | + 'post_type' => array('shop_order'),
|
|
| 697 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
|
|
| 701 | 698 | )); |
| 702 | 699 | } else {
|
| 703 | 700 | $is_guest = "true"; |
| 704 | 701 | $customer_orders = get_posts(array( |
| 705 | - 'numberposts' => - 1, |
|
| 702 | + 'numberposts' => -1, |
|
| 706 | 703 | 'meta_key' => '_billing_email', |
| 707 | 704 | 'meta_value' => $billingEmail, |
| 708 | - 'post_type' => array( 'shop_order' ), |
|
| 709 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded'), |
|
| 705 | + 'post_type' => array('shop_order'),
|
|
| 706 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
|
|
| 710 | 707 | )); |
| 711 | 708 | foreach ($customer_orders as $customer_order) {
|
| 712 | 709 | if (trim($sign_up)=='' || |
@@ -735,7 +732,7 @@ discard block |
||
| 735 | 732 | //Check if id exists |
| 736 | 733 | $resultsSelect = $wpdb->get_results("select * from $tableName where id='$orderId'");
|
| 737 | 734 | $countResults = count($resultsSelect); |
| 738 | - if ($countResults == 0) {
|
|
| 735 | + if ($countResults==0) {
|
|
| 739 | 736 | $wpdb->insert( |
| 740 | 737 | $tableName, |
| 741 | 738 | array('id' => $orderId, 'order_id' => $pagantisOrderId),
|
@@ -760,7 +757,7 @@ discard block |
||
| 760 | 757 | global $wpdb; |
| 761 | 758 | $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
| 762 | 759 | |
| 763 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 760 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 764 | 761 | $charset_collate = $wpdb->get_charset_collate(); |
| 765 | 762 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
| 766 | 763 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -793,9 +790,9 @@ discard block |
||
| 793 | 790 | */ |
| 794 | 791 | private function getNationalId($order) |
| 795 | 792 | {
|
| 796 | - foreach ((array)$order->get_meta_data() as $mdObject) {
|
|
| 793 | + foreach ((array) $order->get_meta_data() as $mdObject) {
|
|
| 797 | 794 | $data = $mdObject->get_data(); |
| 798 | - if ($data['key'] == 'vat_number') {
|
|
| 795 | + if ($data['key']=='vat_number') {
|
|
| 799 | 796 | return $data['value']; |
| 800 | 797 | } |
| 801 | 798 | } |
@@ -810,9 +807,9 @@ discard block |
||
| 810 | 807 | */ |
| 811 | 808 | private function getTaxId($order) |
| 812 | 809 | {
|
| 813 | - foreach ((array)$order->get_meta_data() as $mdObject) {
|
|
| 810 | + foreach ((array) $order->get_meta_data() as $mdObject) {
|
|
| 814 | 811 | $data = $mdObject->get_data(); |
| 815 | - if ($data['key'] == 'billing_cfpiva') {
|
|
| 812 | + if ($data['key']=='billing_cfpiva') {
|
|
| 816 | 813 | return $data['value']; |
| 817 | 814 | } |
| 818 | 815 | } |
@@ -842,7 +839,7 @@ discard block |
||
| 842 | 839 | {
|
| 843 | 840 | global $wpdb; |
| 844 | 841 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
| 845 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 842 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 846 | 843 | $charset_collate = $wpdb->get_charset_collate(); |
| 847 | 844 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
| 848 | 845 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -861,7 +858,7 @@ discard block |
||
| 861 | 858 | {
|
| 862 | 859 | $metaProduct = get_post_meta($product_id); |
| 863 | 860 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) &&
|
| 864 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
| 861 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
| 865 | 862 | } |
| 866 | 863 | |
| 867 | 864 | /** |
@@ -874,8 +871,8 @@ discard block |
||
| 874 | 871 | $promotedAmount = 0; |
| 875 | 872 | foreach ($items as $key => $item) {
|
| 876 | 873 | $promotedProduct = $this->isPromoted($item['product_id']); |
| 877 | - if ($promotedProduct == 'true') {
|
|
| 878 | - $promotedAmount+=$item['line_total'] + $item['line_tax']; |
|
| 874 | + if ($promotedProduct=='true') {
|
|
| 875 | + $promotedAmount += $item['line_total'] + $item['line_tax']; |
|
| 879 | 876 | } |
| 880 | 877 | } |
| 881 | 878 | |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | selector: '.pagantisSimulator', |
| 38 | 38 | totalAmount: '<?php echo $total; ?>', |
| 39 | 39 | totalPromotedAmount: '<?php echo $promoted_amount; ?>', |
| 40 | - skin : <?php echo $pagantisSimulatorSkin;?>, |
|
| 40 | + skin : <?php echo $pagantisSimulatorSkin; ?>, |
|
| 41 | 41 | locale: locale, |
| 42 | 42 | country: country |
| 43 | 43 | }); |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <script> |
| 2 | 2 | function findPriceSelector() |
| 3 | 3 | { |
| 4 | - var priceSelectors = <?php echo json_encode($priceSelector);?>; |
|
| 4 | + var priceSelectors = <?php echo json_encode($priceSelector); ?>; |
|
| 5 | 5 | return priceSelectors.find(function(candidateSelector) { |
| 6 | 6 | var priceDOM = document.querySelector(candidateSelector); |
| 7 | 7 | return (priceDOM != null ); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | function findPositionSelector() |
| 13 | 13 | { |
| 14 | - var positionSelector = '<?php echo $positionSelector;?>'; |
|
| 14 | + var positionSelector = '<?php echo $positionSelector; ?>'; |
|
| 15 | 15 | if (positionSelector === 'default') { |
| 16 | 16 | positionSelector = '.pagantisSimulator'; |
| 17 | 17 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | function findQuantitySelector() |
| 23 | 23 | { |
| 24 | - var quantitySelectors = <?php echo json_encode($quantitySelector);?>; |
|
| 24 | + var quantitySelectors = <?php echo json_encode($quantitySelector); ?>; |
|
| 25 | 25 | return quantitySelectors.find(function(candidateSelector) { |
| 26 | 26 | var priceDOM = document.querySelector(candidateSelector); |
| 27 | 27 | return (priceDOM != null ); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | function findDestinationSim() |
| 51 | 51 | { |
| 52 | - var destinationSim = '<?php echo $finalDestination;?>'; |
|
| 52 | + var destinationSim = '<?php echo $finalDestination; ?>'; |
|
| 53 | 53 | if (destinationSim === 'default' || destinationSim == '') { |
| 54 | 54 | destinationSim = 'woocommerce-product-details__short-description'; |
| 55 | 55 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | function prependSeparator() |
| 78 | 78 | { |
| 79 | 79 | var node = document.querySelector(findPositionSelector()); |
| 80 | - var textnode = document.createTextNode(<?php echo json_encode($separator);?>); |
|
| 80 | + var textnode = document.createTextNode(<?php echo json_encode($separator); ?>); |
|
| 81 | 81 | var spannode = document.createElement("span"); |
| 82 | 82 | spannode.style.cssText = 'margin-right:5px'; |
| 83 | 83 | spannode.appendChild(textnode); |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | var positionSelector = findPositionSelector(); |
| 104 | 104 | var priceSelector = findPriceSelector(); |
| 105 | - var promotedProduct = '<?php echo $promoted;?>'; |
|
| 105 | + var promotedProduct = '<?php echo $promoted; ?>'; |
|
| 106 | 106 | var quantitySelector = findQuantitySelector(); |
| 107 | 107 | |
| 108 | 108 | simulator_options = { |
@@ -114,12 +114,12 @@ discard block |
||
| 114 | 114 | country: country, |
| 115 | 115 | itemAmountSelector: priceSelector, |
| 116 | 116 | amountParserConfig : { |
| 117 | - thousandSeparator: '<?php echo $thousandSeparator;?>', |
|
| 118 | - decimalSeparator: '<?php echo $decimalSeparator;?>' |
|
| 117 | + thousandSeparator: '<?php echo $thousandSeparator; ?>', |
|
| 118 | + decimalSeparator: '<?php echo $decimalSeparator; ?>' |
|
| 119 | 119 | }, |
| 120 | - numInstalments : '<?php echo $pagantisQuotesStart;?>', |
|
| 121 | - skin : <?php echo $pagantisSimulatorSkin;?>, |
|
| 122 | - position: <?php echo $pagantisSimulatorPosition;?> |
|
| 120 | + numInstalments : '<?php echo $pagantisQuotesStart; ?>', |
|
| 121 | + skin : <?php echo $pagantisSimulatorSkin; ?>, |
|
| 122 | + position: <?php echo $pagantisSimulatorPosition; ?> |
|
| 123 | 123 | }; |
| 124 | 124 | |
| 125 | 125 | window.pgSDK = sdk; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | { |
| 149 | 149 | if (window.WCSimulatorId != '') |
| 150 | 150 | { |
| 151 | - var updateSelector = '<?php echo $variationSelector;?>'; |
|
| 151 | + var updateSelector = '<?php echo $variationSelector; ?>'; |
|
| 152 | 152 | |
| 153 | 153 | if (updateSelector == 'default' || updateSelector === '') |
| 154 | 154 | { |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | } |
| 182 | 182 | </style> |
| 183 | 183 | <?php |
| 184 | -if ($promoted == 'true') { |
|
| 184 | +if ($promoted=='true') { |
|
| 185 | 185 | echo $promotedMessage; |
| 186 | 186 | } |
| 187 | 187 | ?> |
@@ -33,27 +33,27 @@ discard block |
||
| 33 | 33 | const ORDERS_TABLE = 'posts'; |
| 34 | 34 | |
| 35 | 35 | public $defaultConfigs = array( |
| 36 | - 'PAGANTIS_TITLE'=>'Pago en cuotas', |
|
| 37 | - 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'sdk.simulator.types.SELECTABLE_TEXT_CUSTOM', |
|
| 38 | - 'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'sdk.simulator.skins.BLUE', |
|
| 39 | - 'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons', |
|
| 40 | - 'PAGANTIS_SIMULATOR_START_INSTALLMENTS'=>3, |
|
| 41 | - 'PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'=>12, |
|
| 42 | - 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'=>'default', |
|
| 43 | - 'PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'=>'sdk.simulator.positions.INNER', |
|
| 44 | - '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";}', |
|
| 45 | - 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'=>'a:2:{i:0;s:22:"div.quantity input.qty";i:1;s:18:"div.quantity>input";}', |
|
| 46 | - 'PAGANTIS_FORM_DISPLAY_TYPE'=>0, |
|
| 47 | - 'PAGANTIS_DISPLAY_MIN_AMOUNT'=>1, |
|
| 48 | - 'PAGANTIS_DISPLAY_MAX_AMOUNT'=>0, |
|
| 49 | - 'PAGANTIS_URL_OK'=>'', |
|
| 50 | - 'PAGANTIS_URL_KO'=>'', |
|
| 51 | - 'PAGANTIS_ALLOWED_COUNTRIES' => 'a:3:{i:0;s:2:"es";i:1;s:2:"it";i:2;s:2:"fr";}', |
|
| 52 | - 'PAGANTIS_PROMOTION_EXTRA' => '<p>Finance this product <span class="pg-no-interest">without interest!</span></p>', |
|
| 53 | - 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR' => '.', |
|
| 54 | - 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR' => ',', |
|
| 55 | - 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION' => 'default', |
|
| 56 | - 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION' => 'default' |
|
| 36 | + 'PAGANTIS_TITLE'=>'Pago en cuotas', |
|
| 37 | + 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'sdk.simulator.types.SELECTABLE_TEXT_CUSTOM', |
|
| 38 | + 'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'sdk.simulator.skins.BLUE', |
|
| 39 | + 'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons', |
|
| 40 | + 'PAGANTIS_SIMULATOR_START_INSTALLMENTS'=>3, |
|
| 41 | + 'PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'=>12, |
|
| 42 | + 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'=>'default', |
|
| 43 | + 'PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'=>'sdk.simulator.positions.INNER', |
|
| 44 | + '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";}', |
|
| 45 | + 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'=>'a:2:{i:0;s:22:"div.quantity input.qty";i:1;s:18:"div.quantity>input";}', |
|
| 46 | + 'PAGANTIS_FORM_DISPLAY_TYPE'=>0, |
|
| 47 | + 'PAGANTIS_DISPLAY_MIN_AMOUNT'=>1, |
|
| 48 | + 'PAGANTIS_DISPLAY_MAX_AMOUNT'=>0, |
|
| 49 | + 'PAGANTIS_URL_OK'=>'', |
|
| 50 | + 'PAGANTIS_URL_KO'=>'', |
|
| 51 | + 'PAGANTIS_ALLOWED_COUNTRIES' => 'a:3:{i:0;s:2:"es";i:1;s:2:"it";i:2;s:2:"fr";}', |
|
| 52 | + 'PAGANTIS_PROMOTION_EXTRA' => '<p>Finance this product <span class="pg-no-interest">without interest!</span></p>', |
|
| 53 | + 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR' => '.', |
|
| 54 | + 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR' => ',', |
|
| 55 | + 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION' => 'default', |
|
| 56 | + 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION' => 'default' |
|
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | 59 | /** @var Array $extraConfig */ |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | if ($file == plugin_basename(__FILE__)) { |
| 400 | 400 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
| 401 | 401 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
| 402 | - __('API documentation', 'pagantis').'</a>'; |
|
| 402 | + __('API documentation', 'pagantis').'</a>'; |
|
| 403 | 403 | $links[] = '<a href="'.WcPagantis::SUPPORT_EML.'">'.__('Support', 'pagantis').'</a>'; |
| 404 | 404 | |
| 405 | 405 | return $links; |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | register_activation_hook(__FILE__, array($this, 'pagantisActivation')); |
| 83 | 83 | add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl')); |
| 84 | 84 | add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave')); |
| 85 | - add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate')); |
|
| 86 | - add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave')); |
|
| 85 | + add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate')); |
|
| 86 | + add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave')); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | { |
| 110 | 110 | $post_id = $product->get_id(); |
| 111 | 111 | $pagantis_promoted_value = $_REQUEST['pagantis_promoted']; |
| 112 | - if ($pagantis_promoted_value == 'on') { |
|
| 112 | + if ($pagantis_promoted_value=='on') { |
|
| 113 | 113 | $pagantis_promoted_value = 'yes'; |
| 114 | 114 | } else { |
| 115 | 115 | $pagantis_promoted_value = 'no'; |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | public function pagantisPromotedVarSave($post_id) |
| 144 | 144 | { |
| 145 | 145 | $pagantis_promoted_value = $_POST['pagantis_promoted']; |
| 146 | - if ($pagantis_promoted_value == null) { |
|
| 146 | + if ($pagantis_promoted_value==null) { |
|
| 147 | 147 | $pagantis_promoted_value = 'no'; |
| 148 | 148 | } |
| 149 | 149 | update_post_meta($post_id, 'custom_product_pagantis_promoted', esc_attr($pagantis_promoted_value)); |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | public function loadPagantisTranslation($mofile, $domain) |
| 158 | 158 | { |
| 159 | - if ('pagantis' === $domain) { |
|
| 160 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 159 | + if ('pagantis'===$domain) { |
|
| 160 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 161 | 161 | } |
| 162 | 162 | return $mofile; |
| 163 | 163 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | global $wpdb; |
| 171 | 171 | |
| 172 | 172 | $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE; |
| 173 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
| 173 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
| 174 | 174 | $charset_collate = $wpdb->get_charset_collate(); |
| 175 | 175 | $sql = "CREATE TABLE $tableName ( order_id int NOT NULL, |
| 176 | 176 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate"; |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 182 | 182 | |
| 183 | 183 | //Check if table exists |
| 184 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; |
|
| 184 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; |
|
| 185 | 185 | if ($tableExists) { |
| 186 | 186 | $charset_collate = $wpdb->get_charset_collate(); |
| 187 | 187 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | //Updated value field to adapt to new length < v8.0.1 |
| 197 | 197 | $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'"; |
| 198 | 198 | $results = $wpdb->get_results($query, ARRAY_A); |
| 199 | - if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') { |
|
| 199 | + if ($results['0']['COLUMN_TYPE']=='varchar(100)') { |
|
| 200 | 200 | $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)"; |
| 201 | 201 | $wpdb->query($sql); |
| 202 | 202 | } |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
| 207 | 207 | $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A); |
| 208 | 208 | foreach ($dbCurrentConfig as $item) { |
| 209 | - if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
| 209 | + if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
| 210 | 210 | $css_price_selector = $this->preparePriceSelector($item['value']); |
| 211 | - if ($item['value'] != $css_price_selector) { |
|
| 211 | + if ($item['value']!=$css_price_selector) { |
|
| 212 | 212 | $wpdb->update( |
| 213 | 213 | $tableName, |
| 214 | 214 | array('value' => stripslashes($css_price_selector)), |
@@ -217,9 +217,9 @@ discard block |
||
| 217 | 217 | array('%s') |
| 218 | 218 | ); |
| 219 | 219 | } |
| 220 | - } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
| 220 | + } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
| 221 | 221 | $css_quantity_selector = $this->prepareQuantitySelector($item['value']); |
| 222 | - if ($item['value'] != $css_quantity_selector) { |
|
| 222 | + if ($item['value']!=$css_quantity_selector) { |
|
| 223 | 223 | $wpdb->update( |
| 224 | 224 | $tableName, |
| 225 | 225 | array('value' => stripslashes($css_quantity_selector)), |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 237 | 237 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
| 238 | 238 | $results = $wpdb->get_results($query, ARRAY_A); |
| 239 | - if (count($results) == 0) { |
|
| 239 | + if (count($results)==0) { |
|
| 240 | 240 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value' => '.'), array('%s', '%s')); |
| 241 | 241 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value' => ','), array('%s', '%s')); |
| 242 | 242 | } |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 246 | 246 | $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'"; |
| 247 | 247 | $results = $wpdb->get_results($query, ARRAY_A); |
| 248 | - if (count($results) == 0) { |
|
| 248 | + if (count($results)==0) { |
|
| 249 | 249 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value' => '0'), array('%s', '%s')); |
| 250 | 250 | } |
| 251 | 251 | |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 254 | 254 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'"; |
| 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_SIMULATOR_DISPLAY_SITUATION', 'value' => 'default'), array('%s', '%s')); |
| 258 | 258 | } |
| 259 | 259 | |
@@ -301,9 +301,9 @@ discard block |
||
| 301 | 301 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
| 302 | 302 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
| 303 | 303 | $totalPrice = $product->get_price(); |
| 304 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
| 305 | - if ($cfg['enabled'] !== 'yes' || $cfg['pagantis_public_key'] == '' || $cfg['pagantis_private_key'] == '' || |
|
| 306 | - $cfg['simulator'] !== 'yes' || !$allowedCountry || !$validAmount) { |
|
| 304 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
| 305 | + if ($cfg['enabled']!=='yes' || $cfg['pagantis_public_key']=='' || $cfg['pagantis_private_key']=='' || |
|
| 306 | + $cfg['simulator']!=='yes' || !$allowedCountry || !$validAmount) { |
|
| 307 | 307 | return; |
| 308 | 308 | } |
| 309 | 309 | |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | public function addPagantisGateway($methods) |
| 343 | 343 | { |
| 344 | - if (! class_exists('WC_Payment_Gateway')) { |
|
| 344 | + if (!class_exists('WC_Payment_Gateway')) { |
|
| 345 | 345 | return $methods; |
| 346 | 346 | } |
| 347 | 347 | |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | */ |
| 397 | 397 | public function pagantisRowMeta($links, $file) |
| 398 | 398 | { |
| 399 | - if ($file == plugin_basename(__FILE__)) { |
|
| 399 | + if ($file==plugin_basename(__FILE__)) { |
|
| 400 | 400 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
| 401 | 401 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
| 402 | 402 | __('API documentation', 'pagantis').'</a>'; |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
| 425 | 425 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
| 426 | 426 | $results = $wpdb->get_results($query); |
| 427 | - if (isset($results) && $privateKey == $secretKey) { |
|
| 427 | + if (isset($results) && $privateKey==$secretKey) { |
|
| 428 | 428 | foreach ($results as $key => $result) { |
| 429 | 429 | $response[$key]['timestamp'] = $result->createdAt; |
| 430 | 430 | $response[$key]['log'] = json_decode($result->log); |
@@ -451,12 +451,12 @@ discard block |
||
| 451 | 451 | |
| 452 | 452 | $filters = ($data->get_params()); |
| 453 | 453 | $secretKey = $filters['secret']; |
| 454 | - $cfg = get_option('woocommerce_pagantis_settings'); |
|
| 454 | + $cfg = get_option('woocommerce_pagantis_settings'); |
|
| 455 | 455 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
| 456 | - if ($privateKey != $secretKey) { |
|
| 456 | + if ($privateKey!=$secretKey) { |
|
| 457 | 457 | $response['status'] = 401; |
| 458 | 458 | $response['result'] = 'Unauthorized'; |
| 459 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 459 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
| 460 | 460 | if (count($_POST)) { |
| 461 | 461 | foreach ($_POST as $config => $value) { |
| 462 | 462 | if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc"; |
| 517 | 517 | $results = $wpdb->get_results($query); |
| 518 | 518 | |
| 519 | - if (isset($results) && $privateKey == $secretKey) { |
|
| 519 | + if (isset($results) && $privateKey==$secretKey) { |
|
| 520 | 520 | foreach ($results as $result) { |
| 521 | 521 | $key = $result->ID; |
| 522 | 522 | $response['message'][$key]['timestamp'] = $result->post_date; |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | */ |
| 601 | 601 | private function prepareQuantitySelector($css_quantity_selector) |
| 602 | 602 | { |
| 603 | - if ($css_quantity_selector == 'default' || $css_quantity_selector == '') { |
|
| 603 | + if ($css_quantity_selector=='default' || $css_quantity_selector=='') { |
|
| 604 | 604 | $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
| 605 | 605 | } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
| 606 | 606 | $css_quantity_selector = serialize(array($css_quantity_selector)); |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | */ |
| 617 | 617 | private function preparePriceSelector($css_price_selector) |
| 618 | 618 | { |
| 619 | - if ($css_price_selector == 'default' || $css_price_selector == '') { |
|
| 619 | + if ($css_price_selector=='default' || $css_price_selector=='') { |
|
| 620 | 620 | $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
| 621 | 621 | } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
| 622 | 622 | $css_price_selector = serialize(array($css_price_selector)); |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | { |
| 635 | 635 | $metaProduct = get_post_meta($product_id); |
| 636 | 636 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && |
| 637 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
| 637 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
| 638 | 638 | } |
| 639 | 639 | } |
| 640 | 640 | |