@@ -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,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 | |
@@ -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 | }); |
@@ -33,28 +33,28 @@ 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.PRODUCT_PAGE', |
|
| 38 | - 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'=>'sdk.simulator.types.CHECKOUT_PAGE', |
|
| 39 | - 'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'sdk.simulator.skins.BLUE', |
|
| 40 | - 'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons', |
|
| 41 | - 'PAGANTIS_SIMULATOR_START_INSTALLMENTS'=>3, |
|
| 42 | - 'PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'=>12, |
|
| 43 | - 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'=>'default', |
|
| 44 | - 'PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'=>'sdk.simulator.positions.INNER', |
|
| 45 | - '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";}', |
|
| 46 | - 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'=>'a:2:{i:0;s:22:"div.quantity input.qty";i:1;s:18:"div.quantity>input";}', |
|
| 47 | - 'PAGANTIS_FORM_DISPLAY_TYPE'=>0, |
|
| 48 | - 'PAGANTIS_DISPLAY_MIN_AMOUNT'=>1, |
|
| 49 | - 'PAGANTIS_DISPLAY_MAX_AMOUNT'=>0, |
|
| 50 | - 'PAGANTIS_URL_OK'=>'', |
|
| 51 | - 'PAGANTIS_URL_KO'=>'', |
|
| 52 | - 'PAGANTIS_ALLOWED_COUNTRIES' => 'a:3:{i:0;s:2:"es";i:1;s:2:"it";i:2;s:2:"fr";}', |
|
| 53 | - 'PAGANTIS_PROMOTION_EXTRA' => '<p>Finance this product <span class="pg-no-interest">without interest!</span></p>', |
|
| 54 | - 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR' => '.', |
|
| 55 | - 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR' => ',', |
|
| 56 | - 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION' => 'default', |
|
| 57 | - 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION' => 'default' |
|
| 36 | + 'PAGANTIS_TITLE'=>'Pago en cuotas', |
|
| 37 | + 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'sdk.simulator.types.PRODUCT_PAGE', |
|
| 38 | + 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'=>'sdk.simulator.types.CHECKOUT_PAGE', |
|
| 39 | + 'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'sdk.simulator.skins.BLUE', |
|
| 40 | + 'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons', |
|
| 41 | + 'PAGANTIS_SIMULATOR_START_INSTALLMENTS'=>3, |
|
| 42 | + 'PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'=>12, |
|
| 43 | + 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'=>'default', |
|
| 44 | + 'PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'=>'sdk.simulator.positions.INNER', |
|
| 45 | + '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";}', |
|
| 46 | + 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'=>'a:2:{i:0;s:22:"div.quantity input.qty";i:1;s:18:"div.quantity>input";}', |
|
| 47 | + 'PAGANTIS_FORM_DISPLAY_TYPE'=>0, |
|
| 48 | + 'PAGANTIS_DISPLAY_MIN_AMOUNT'=>1, |
|
| 49 | + 'PAGANTIS_DISPLAY_MAX_AMOUNT'=>0, |
|
| 50 | + 'PAGANTIS_URL_OK'=>'', |
|
| 51 | + 'PAGANTIS_URL_KO'=>'', |
|
| 52 | + 'PAGANTIS_ALLOWED_COUNTRIES' => 'a:3:{i:0;s:2:"es";i:1;s:2:"it";i:2;s:2:"fr";}', |
|
| 53 | + 'PAGANTIS_PROMOTION_EXTRA' => '<p>Finance this product <span class="pg-no-interest">without interest!</span></p>', |
|
| 54 | + 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR' => '.', |
|
| 55 | + 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR' => ',', |
|
| 56 | + 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION' => 'default', |
|
| 57 | + 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION' => 'default' |
|
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | 60 | /** @var Array $extraConfig */ |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | if ($file == plugin_basename(__FILE__)) { |
| 410 | 410 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
| 411 | 411 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
| 412 | - __('API documentation', 'pagantis').'</a>'; |
|
| 412 | + __('API documentation', 'pagantis').'</a>'; |
|
| 413 | 413 | $links[] = '<a href="'.WcPagantis::SUPPORT_EML.'">'.__('Support', 'pagantis').'</a>'; |
| 414 | 414 | |
| 415 | 415 | return $links; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | $this->extraConfig = $this->getExtraConfig(); |
| 79 | 79 | |
| 80 | - load_plugin_textdomain('pagantis', false, dirname(plugin_basename( __FILE__)).'/languages'); |
|
| 80 | + load_plugin_textdomain('pagantis', false, dirname(plugin_basename(__FILE__)).'/languages'); |
|
| 81 | 81 | |
| 82 | 82 | add_filter('woocommerce_payment_gateways', array($this, 'addPagantisGateway')); |
| 83 | 83 | add_filter('woocommerce_available_payment_gateways', array($this, 'pagantisFilterGateways'), 9999); |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | register_activation_hook(__FILE__, array($this, 'pagantisActivation')); |
| 91 | 91 | add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl')); |
| 92 | 92 | add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave')); |
| 93 | - add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate')); |
|
| 94 | - add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave')); |
|
| 93 | + add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate')); |
|
| 94 | + add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave')); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | { |
| 118 | 118 | $post_id = $product->get_id(); |
| 119 | 119 | $pagantis_promoted_value = $_REQUEST['pagantis_promoted']; |
| 120 | - if ($pagantis_promoted_value == 'on') { |
|
| 120 | + if ($pagantis_promoted_value=='on') { |
|
| 121 | 121 | $pagantis_promoted_value = 'yes'; |
| 122 | 122 | } else { |
| 123 | 123 | $pagantis_promoted_value = 'no'; |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | public function pagantisPromotedVarSave($post_id) |
| 152 | 152 | { |
| 153 | 153 | $pagantis_promoted_value = $_POST['pagantis_promoted']; |
| 154 | - if ($pagantis_promoted_value == null) { |
|
| 154 | + if ($pagantis_promoted_value==null) { |
|
| 155 | 155 | $pagantis_promoted_value = 'no'; |
| 156 | 156 | } |
| 157 | 157 | update_post_meta($post_id, 'custom_product_pagantis_promoted', esc_attr($pagantis_promoted_value)); |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | public function loadPagantisTranslation($mofile, $domain) |
| 166 | 166 | { |
| 167 | - if ('pagantis' === $domain) { |
|
| 168 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 167 | + if ('pagantis'===$domain) { |
|
| 168 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 169 | 169 | } |
| 170 | 170 | return $mofile; |
| 171 | 171 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | global $wpdb; |
| 179 | 179 | |
| 180 | 180 | $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE; |
| 181 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
| 181 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
| 182 | 182 | $charset_collate = $wpdb->get_charset_collate(); |
| 183 | 183 | $sql = "CREATE TABLE $tableName ( order_id int NOT NULL, |
| 184 | 184 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate"; |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 190 | 190 | |
| 191 | 191 | //Check if table exists |
| 192 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; |
|
| 192 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; |
|
| 193 | 193 | if ($tableExists) { |
| 194 | 194 | $charset_collate = $wpdb->get_charset_collate(); |
| 195 | 195 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | //Updated value field to adapt to new length < v8.0.1 |
| 205 | 205 | $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'"; |
| 206 | 206 | $results = $wpdb->get_results($query, ARRAY_A); |
| 207 | - if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') { |
|
| 207 | + if ($results['0']['COLUMN_TYPE']=='varchar(100)') { |
|
| 208 | 208 | $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)"; |
| 209 | 209 | $wpdb->query($sql); |
| 210 | 210 | } |
@@ -214,9 +214,9 @@ discard block |
||
| 214 | 214 | or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
| 215 | 215 | $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A); |
| 216 | 216 | foreach ($dbCurrentConfig as $item) { |
| 217 | - if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
| 217 | + if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
| 218 | 218 | $css_price_selector = $this->preparePriceSelector($item['value']); |
| 219 | - if ($item['value'] != $css_price_selector) { |
|
| 219 | + if ($item['value']!=$css_price_selector) { |
|
| 220 | 220 | $wpdb->update( |
| 221 | 221 | $tableName, |
| 222 | 222 | array('value' => stripslashes($css_price_selector)), |
@@ -225,9 +225,9 @@ discard block |
||
| 225 | 225 | array('%s') |
| 226 | 226 | ); |
| 227 | 227 | } |
| 228 | - } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
| 228 | + } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
| 229 | 229 | $css_quantity_selector = $this->prepareQuantitySelector($item['value']); |
| 230 | - if ($item['value'] != $css_quantity_selector) { |
|
| 230 | + if ($item['value']!=$css_quantity_selector) { |
|
| 231 | 231 | $wpdb->update( |
| 232 | 232 | $tableName, |
| 233 | 233 | array('value' => stripslashes($css_quantity_selector)), |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 245 | 245 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
| 246 | 246 | $results = $wpdb->get_results($query, ARRAY_A); |
| 247 | - if (count($results) == 0) { |
|
| 247 | + if (count($results)==0) { |
|
| 248 | 248 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value' => '.'), array('%s', '%s')); |
| 249 | 249 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value' => ','), array('%s', '%s')); |
| 250 | 250 | } |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 254 | 254 | $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'"; |
| 255 | 255 | $results = $wpdb->get_results($query, ARRAY_A); |
| 256 | - if (count($results) == 0) { |
|
| 256 | + if (count($results)==0) { |
|
| 257 | 257 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value' => '0'), array('%s', '%s')); |
| 258 | 258 | } |
| 259 | 259 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 262 | 262 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'"; |
| 263 | 263 | $results = $wpdb->get_results($query, ARRAY_A); |
| 264 | - if (count($results) == 0) { |
|
| 264 | + if (count($results)==0) { |
|
| 265 | 265 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value' => 'default'), array('%s', '%s')); |
| 266 | 266 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value' => 'default'), array('%s', '%s')); |
| 267 | 267 | } |
@@ -270,17 +270,17 @@ discard block |
||
| 270 | 270 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 271 | 271 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'"; |
| 272 | 272 | $results = $wpdb->get_results($query, ARRAY_A); |
| 273 | - if (count($results) == 0) { |
|
| 273 | + if (count($results)==0) { |
|
| 274 | 274 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', 'value' => 'sdk.simulator.types.CHECKOUT_PAGE'), array('%s', '%s')); |
| 275 | 275 | $wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), array('%s'), array('%s')); |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | //Adapting to variable selector < v8.3.6 |
| 279 | - $variableSelector="div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
| 279 | + $variableSelector = "div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
| 280 | 280 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 281 | 281 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'"; |
| 282 | 282 | $results = $wpdb->get_results($query, ARRAY_A); |
| 283 | - if (count($results) == 0) { |
|
| 283 | + if (count($results)==0) { |
|
| 284 | 284 | $wpdb->update($tableName, array('value' => $variableSelector), array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION'), array('%s'), array('%s')); |
| 285 | 285 | } |
| 286 | 286 | |
@@ -328,9 +328,9 @@ discard block |
||
| 328 | 328 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
| 329 | 329 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
| 330 | 330 | $totalPrice = $product->get_price(); |
| 331 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
| 332 | - if ($cfg['enabled'] !== 'yes' || $cfg['pagantis_public_key'] == '' || $cfg['pagantis_private_key'] == '' || |
|
| 333 | - $cfg['simulator'] !== 'yes' || !$allowedCountry || !$validAmount) { |
|
| 331 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
| 332 | + if ($cfg['enabled']!=='yes' || $cfg['pagantis_public_key']=='' || $cfg['pagantis_private_key']=='' || |
|
| 333 | + $cfg['simulator']!=='yes' || !$allowedCountry || !$validAmount) { |
|
| 334 | 334 | return; |
| 335 | 335 | } |
| 336 | 336 | |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | */ |
| 370 | 370 | public function addPagantisGateway($methods) |
| 371 | 371 | { |
| 372 | - if (! class_exists('WC_Payment_Gateway')) { |
|
| 372 | + if (!class_exists('WC_Payment_Gateway')) { |
|
| 373 | 373 | return $methods; |
| 374 | 374 | } |
| 375 | 375 | |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | public function pagantisRowMeta($links, $file) |
| 426 | 426 | { |
| 427 | - if ($file == plugin_basename(__FILE__)) { |
|
| 427 | + if ($file==plugin_basename(__FILE__)) { |
|
| 428 | 428 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
| 429 | 429 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
| 430 | 430 | __('API documentation', 'pagantis').'</a>'; |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
| 453 | 453 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
| 454 | 454 | $results = $wpdb->get_results($query); |
| 455 | - if (isset($results) && $privateKey == $secretKey) { |
|
| 455 | + if (isset($results) && $privateKey==$secretKey) { |
|
| 456 | 456 | foreach ($results as $key => $result) { |
| 457 | 457 | $response[$key]['timestamp'] = $result->createdAt; |
| 458 | 458 | $response[$key]['log'] = json_decode($result->log); |
@@ -479,12 +479,12 @@ discard block |
||
| 479 | 479 | |
| 480 | 480 | $filters = ($data->get_params()); |
| 481 | 481 | $secretKey = $filters['secret']; |
| 482 | - $cfg = get_option('woocommerce_pagantis_settings'); |
|
| 482 | + $cfg = get_option('woocommerce_pagantis_settings'); |
|
| 483 | 483 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
| 484 | - if ($privateKey != $secretKey) { |
|
| 484 | + if ($privateKey!=$secretKey) { |
|
| 485 | 485 | $response['status'] = 401; |
| 486 | 486 | $response['result'] = 'Unauthorized'; |
| 487 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 487 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
| 488 | 488 | if (count($_POST)) { |
| 489 | 489 | foreach ($_POST as $config => $value) { |
| 490 | 490 | if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc"; |
| 545 | 545 | $results = $wpdb->get_results($query); |
| 546 | 546 | |
| 547 | - if (isset($results) && $privateKey == $secretKey) { |
|
| 547 | + if (isset($results) && $privateKey==$secretKey) { |
|
| 548 | 548 | foreach ($results as $result) { |
| 549 | 549 | $key = $result->ID; |
| 550 | 550 | $response['message'][$key]['timestamp'] = $result->post_date; |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | */ |
| 629 | 629 | private function prepareQuantitySelector($css_quantity_selector) |
| 630 | 630 | { |
| 631 | - if ($css_quantity_selector == 'default' || $css_quantity_selector == '') { |
|
| 631 | + if ($css_quantity_selector=='default' || $css_quantity_selector=='') { |
|
| 632 | 632 | $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
| 633 | 633 | } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
| 634 | 634 | $css_quantity_selector = serialize(array($css_quantity_selector)); |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | */ |
| 645 | 645 | private function preparePriceSelector($css_price_selector) |
| 646 | 646 | { |
| 647 | - if ($css_price_selector == 'default' || $css_price_selector == '') { |
|
| 647 | + if ($css_price_selector=='default' || $css_price_selector=='') { |
|
| 648 | 648 | $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
| 649 | 649 | } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
| 650 | 650 | $css_price_selector = serialize(array($css_price_selector)); |
@@ -662,7 +662,7 @@ discard block |
||
| 662 | 662 | { |
| 663 | 663 | $metaProduct = get_post_meta($product_id); |
| 664 | 664 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && |
| 665 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
| 665 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
| 666 | 666 | } |
| 667 | 667 | } |
| 668 | 668 | |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <script> |
| 2 | 2 | function findPriceSelector() |
| 3 | 3 | { |
| 4 | - var priceSelectors = <?php echo json_encode($priceSelector);?>; |
|
| 4 | + var priceSelectors = <?php echo json_encode($priceSelector); ?>; |
|
| 5 | 5 | return priceSelectors.find(function(candidateSelector) { |
| 6 | 6 | var priceDOM = document.querySelector(candidateSelector); |
| 7 | 7 | return (priceDOM != null ); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | function findPositionSelector() |
| 13 | 13 | { |
| 14 | - var positionSelector = '<?php echo $positionSelector;?>'; |
|
| 14 | + var positionSelector = '<?php echo $positionSelector; ?>'; |
|
| 15 | 15 | if (positionSelector === 'default') { |
| 16 | 16 | positionSelector = '.pagantisSimulator'; |
| 17 | 17 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | function findQuantitySelector() |
| 23 | 23 | { |
| 24 | - var quantitySelectors = <?php echo json_encode($quantitySelector);?>; |
|
| 24 | + var quantitySelectors = <?php echo json_encode($quantitySelector); ?>; |
|
| 25 | 25 | return quantitySelectors.find(function(candidateSelector) { |
| 26 | 26 | var priceDOM = document.querySelector(candidateSelector); |
| 27 | 27 | return (priceDOM != null ); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | function findDestinationSim() |
| 50 | 50 | { |
| 51 | - var destinationSim = '<?php echo $finalDestination;?>'; |
|
| 51 | + var destinationSim = '<?php echo $finalDestination; ?>'; |
|
| 52 | 52 | if (destinationSim === 'default' || destinationSim == '') { |
| 53 | 53 | destinationSim = 'woocommerce-product-details__short-description'; |
| 54 | 54 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | var positionSelector = findPositionSelector(); |
| 94 | 94 | var priceSelector = findPriceSelector(); |
| 95 | - var promotedProduct = '<?php echo $promoted;?>'; |
|
| 95 | + var promotedProduct = '<?php echo $promoted; ?>'; |
|
| 96 | 96 | var quantitySelector = findQuantitySelector(); |
| 97 | 97 | |
| 98 | 98 | simulator_options = { |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | country: country, |
| 105 | 105 | itemAmountSelector: priceSelector, |
| 106 | 106 | amountParserConfig : { |
| 107 | - thousandSeparator: '<?php echo $thousandSeparator;?>', |
|
| 108 | - decimalSeparator: '<?php echo $decimalSeparator;?>' |
|
| 107 | + thousandSeparator: '<?php echo $thousandSeparator; ?>', |
|
| 108 | + decimalSeparator: '<?php echo $decimalSeparator; ?>' |
|
| 109 | 109 | }, |
| 110 | - numInstalments : '<?php echo $pagantisQuotesStart;?>', |
|
| 111 | - skin : <?php echo $pagantisSimulatorSkin;?>, |
|
| 112 | - position: <?php echo $pagantisSimulatorPosition;?> |
|
| 110 | + numInstalments : '<?php echo $pagantisQuotesStart; ?>', |
|
| 111 | + skin : <?php echo $pagantisSimulatorSkin; ?>, |
|
| 112 | + position: <?php echo $pagantisSimulatorPosition; ?> |
|
| 113 | 113 | }; |
| 114 | 114 | |
| 115 | 115 | window.pgSDK = sdk; |
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | { |
| 139 | 139 | if (window.WCSimulatorId != '') |
| 140 | 140 | { |
| 141 | - var updateSelector = '<?php echo $variationSelector;?>'; |
|
| 141 | + var updateSelector = '<?php echo $variationSelector; ?>'; |
|
| 142 | 142 | |
| 143 | - var productType = '<?php echo $productType;?>'; |
|
| 143 | + var productType = '<?php echo $productType; ?>'; |
|
| 144 | 144 | |
| 145 | 145 | if (updateSelector == 'default' || updateSelector === '' || productType!=='variable') |
| 146 | 146 | { |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | </style> |
| 175 | 175 | <?php |
| 176 | -if ($promoted == 'true') { |
|
| 176 | +if ($promoted=='true') { |
|
| 177 | 177 | echo $promotedMessage; |
| 178 | 178 | } |
| 179 | 179 | ?> |