@@ -299,9 +299,9 @@ |
||
299 | 299 | if ($promotedProduct == 'true') { |
300 | 300 | $promotedAmount+=$product->getAmount(); |
301 | 301 | $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
302 | - ' - Price: ' . $item->get_total() . |
|
303 | - ' - Qty: ' . $product->getQuantity() . |
|
304 | - ' - Item ID: ' . $item['id_product']; |
|
302 | + ' - Price: ' . $item->get_total() . |
|
303 | + ' - Qty: ' . $product->getQuantity() . |
|
304 | + ' - Item ID: ' . $item['id_product']; |
|
305 | 305 | $promotedMessage = substr($promotedMessage, 0, 999); |
306 | 306 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
307 | 307 | } |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | $this->method_title = ucfirst($this->id); |
57 | 57 | |
58 | 58 | //Useful vars |
59 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/'; |
|
59 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/'; |
|
60 | 60 | $this->allowed_currencies = getAllowedCurrencies(); |
61 | - $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Pagantis.php'; |
|
61 | + $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)).'/WC_Pagantis.php'; |
|
62 | 62 | $this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false); |
63 | 63 | $this->language = strstr(get_locale(), '_', true); |
64 | 64 | if ($this->language=='') { |
@@ -67,25 +67,25 @@ discard block |
||
67 | 67 | $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
68 | 68 | |
69 | 69 | //Panel form fields |
70 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options |
|
70 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options |
|
71 | 71 | $this->init_settings(); |
72 | 72 | |
73 | 73 | $this->extraConfig = getExtraConfig(); |
74 | 74 | $this->title = __($this->extraConfig['PAGANTIS_TITLE'], 'pagantis'); |
75 | 75 | $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis."; |
76 | 76 | |
77 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl(); |
|
78 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl(); |
|
77 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
78 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
79 | 79 | foreach ($this->settings as $setting_key => $setting_value) { |
80 | 80 | $this->$setting_key = $setting_value; |
81 | 81 | } |
82 | 82 | |
83 | 83 | //Hooks |
84 | - add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options |
|
85 | - add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields |
|
86 | - add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
87 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
88 | - add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3); |
|
84 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options |
|
85 | + add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields |
|
86 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
87 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
88 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3); |
|
89 | 89 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
90 | 90 | } |
91 | 91 | |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function loadPagantisTranslation($mofile, $domain) |
99 | 99 | { |
100 | - if ('pagantis' === $domain) { |
|
101 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
100 | + if ('pagantis'===$domain) { |
|
101 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
102 | 102 | } |
103 | 103 | return $mofile; |
104 | 104 | } |
@@ -132,24 +132,24 @@ discard block |
||
132 | 132 | public function pagantisCheckFields() |
133 | 133 | { |
134 | 134 | $error_string = ''; |
135 | - if ($this->settings['enabled'] !== 'yes') { |
|
135 | + if ($this->settings['enabled']!=='yes') { |
|
136 | 136 | return; |
137 | 137 | } elseif (!version_compare(phpversion(), '5.3.0', '>=')) { |
138 | - $error_string = __(' is not compatible with your php and/or curl version', 'pagantis'); |
|
138 | + $error_string = __(' is not compatible with your php and/or curl version', 'pagantis'); |
|
139 | 139 | $this->settings['enabled'] = 'no'; |
140 | - } elseif (($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="") && (empty($this->settings['pagantis_public_key_4x']) || empty($this->settings['pagantis_private_key_4x']))) { |
|
140 | + } elseif (($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="") && (empty($this->settings['pagantis_public_key_4x']) || empty($this->settings['pagantis_private_key_4x']))) { |
|
141 | 141 | $error_string = __(' is not configured correctly, the fields Public Key and Secret Key are mandatory for use this plugin', 'pagantis'); |
142 | 142 | $this->settings['enabled'] = 'no'; |
143 | 143 | } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) { |
144 | - $error_string = __(' only can be used in Euros', 'pagantis'); |
|
144 | + $error_string = __(' only can be used in Euros', 'pagantis'); |
|
145 | 145 | $this->settings['enabled'] = 'no'; |
146 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']<'2' |
|
147 | - || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']>'12') { |
|
146 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] < '2' |
|
147 | + || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] > '12') { |
|
148 | 148 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis'); |
149 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']<'2' |
|
150 | - || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']>'12') { |
|
149 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] < '2' |
|
150 | + || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] > '12') { |
|
151 | 151 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis'); |
152 | - } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']<0) { |
|
152 | + } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] < 0) { |
|
153 | 153 | $error_string = __(' can not have a minimum amount less than 0', 'pagantis'); |
154 | 154 | } |
155 | 155 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | $shippingAddress = $order->get_address('shipping'); |
184 | 184 | $billingAddress = $order->get_address('billing'); |
185 | - if ($shippingAddress['address_1'] == '') { |
|
185 | + if ($shippingAddress['address_1']=='') { |
|
186 | 186 | $shippingAddress = $billingAddress; |
187 | 187 | } |
188 | 188 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | ->setNationalId($national_id) |
210 | 210 | ->setTaxId($tax_id) |
211 | 211 | ; |
212 | - $orderBillingAddress = new Address(); |
|
212 | + $orderBillingAddress = new Address(); |
|
213 | 213 | $orderBillingAddress |
214 | 214 | ->setZipCode($billingAddress['postcode']) |
215 | 215 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
@@ -282,12 +282,12 @@ discard block |
||
282 | 282 | $details->addProduct($product); |
283 | 283 | |
284 | 284 | $promotedProduct = isProductPromoted($item->get_product_id()); |
285 | - if ($promotedProduct == 'true') { |
|
286 | - $promotedAmount+=$product->getAmount(); |
|
287 | - $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
|
288 | - ' - Price: ' . $item->get_total() . |
|
289 | - ' - Qty: ' . $product->getQuantity() . |
|
290 | - ' - Item ID: ' . $item['id_product']; |
|
285 | + if ($promotedProduct=='true') { |
|
286 | + $promotedAmount += $product->getAmount(); |
|
287 | + $promotedMessage = 'Promoted Item: '.$wcProduct->get_name(). |
|
288 | + ' - Price: '.$item->get_total(). |
|
289 | + ' - Qty: '.$product->getQuantity(). |
|
290 | + ' - Item ID: '.$item['id_product']; |
|
291 | 291 | $promotedMessage = substr($promotedMessage, 0, 999); |
292 | 292 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
293 | 293 | } |
@@ -333,9 +333,7 @@ discard block |
||
333 | 333 | |
334 | 334 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
335 | 335 | $purchaseCountry = |
336 | - in_array(strtolower($this->language), $allowedCountries) ? $this->language : |
|
337 | - in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : |
|
338 | - in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null; |
|
336 | + 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; |
|
339 | 337 | |
340 | 338 | $orderConfiguration = new Configuration(); |
341 | 339 | $orderConfiguration |
@@ -377,7 +375,7 @@ discard block |
||
377 | 375 | wc_get_template('iframe.php', $template_fields, '', $this->template_path); |
378 | 376 | } |
379 | 377 | } catch (\Exception $exception) { |
380 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); |
|
378 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); |
|
381 | 379 | insertLogEntry($exception); |
382 | 380 | $checkout_url = get_permalink(wc_get_page_id('checkout')); |
383 | 381 | wp_redirect($checkout_url); |
@@ -392,7 +390,7 @@ discard block |
||
392 | 390 | public function pagantisNotification() |
393 | 391 | { |
394 | 392 | try { |
395 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
393 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
396 | 394 | |
397 | 395 | include_once('notifyController.php'); |
398 | 396 | $notify = new WcPagantisNotify(); |
@@ -431,10 +429,10 @@ discard block |
||
431 | 429 | */ |
432 | 430 | public function pagantisCompleteStatus($status, $order_id, $order) |
433 | 431 | { |
434 | - if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) { |
|
435 | - if ($order->get_status() == 'failed') { |
|
432 | + if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) { |
|
433 | + if ($order->get_status()=='failed') { |
|
436 | 434 | $status = 'processing'; |
437 | - } elseif ($order->get_status() == 'pending' && $status=='completed') { |
|
435 | + } elseif ($order->get_status()=='pending' && $status=='completed') { |
|
438 | 436 | $status = 'processing'; |
439 | 437 | } |
440 | 438 | } |
@@ -460,8 +458,8 @@ discard block |
||
460 | 458 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
461 | 459 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
462 | 460 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
463 | - $totalPrice = (int)$this->get_order_total(); |
|
464 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
461 | + $totalPrice = (int) $this->get_order_total(); |
|
462 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
465 | 463 | if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' && |
466 | 464 | $validAmount && $allowedCountry) { |
467 | 465 | return true; |
@@ -494,7 +492,7 @@ discard block |
||
494 | 492 | |
495 | 493 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
496 | 494 | if (strpos($redirectUrl, 'order-pay=')===false) { |
497 | - $redirectUrl.="&order-pay=".$order_id; |
|
495 | + $redirectUrl .= "&order-pay=".$order_id; |
|
498 | 496 | } |
499 | 497 | |
500 | 498 | return array( |
@@ -502,7 +500,7 @@ discard block |
||
502 | 500 | 'redirect' => $redirectUrl |
503 | 501 | ); |
504 | 502 | } catch (Exception $e) { |
505 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); |
|
503 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); |
|
506 | 504 | return array(); |
507 | 505 | } |
508 | 506 | } |
@@ -571,7 +569,7 @@ discard block |
||
571 | 569 | private function generateUrl($url) |
572 | 570 | { |
573 | 571 | $parsed_url = parse_url($url); |
574 | - if ($parsed_url !== false) { |
|
572 | + if ($parsed_url!==false) { |
|
575 | 573 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
576 | 574 | parse_str($parsed_url['query'], $arrayParams); |
577 | 575 | foreach ($arrayParams as $keyParam => $valueParam) { |
@@ -619,11 +617,10 @@ discard block |
||
619 | 617 | private function getKeysUrl($order, $url) |
620 | 618 | { |
621 | 619 | $defaultFields = (get_class($order)=='WC_Order') ? |
622 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : |
|
623 | - array(); |
|
620 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array(); |
|
624 | 621 | |
625 | 622 | $parsedUrl = parse_url($url); |
626 | - if ($parsedUrl !== false) { |
|
623 | + if ($parsedUrl!==false) { |
|
627 | 624 | //Replace parameters from url |
628 | 625 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
629 | 626 | |
@@ -668,7 +665,7 @@ discard block |
||
668 | 665 | foreach ($arrayParams as $keyParam => $valueParam) { |
669 | 666 | preg_match('#\{{.*?}\}#', $valueParam, $match); |
670 | 667 | if (count($match)) { |
671 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]); |
|
668 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]); |
|
672 | 669 | $arrayParams[$keyParam] = $defaultFields[$key]; |
673 | 670 | } |
674 | 671 | } |
@@ -683,12 +680,12 @@ discard block |
||
683 | 680 | */ |
684 | 681 | private function unparseUrl($parsed_url) |
685 | 682 | { |
686 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
683 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
687 | 684 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
688 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
689 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
690 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
685 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
686 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
687 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
691 | 688 | $path = $parsed_url['path']; |
692 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
689 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
693 | 690 | } |
694 | 691 | } |
@@ -198,10 +198,10 @@ |
||
198 | 198 | |
199 | 199 | if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM |
200 | 200 | $logMessage = "WARNING checkMerchantOrderStatus." . |
201 | - " Merchant order id:".$this->woocommerceOrder->get_id(). |
|
202 | - " Merchant order status:".$this->woocommerceOrder->get_status(). |
|
203 | - " Pagantis order id:".$this->pagantisOrder->getStatus(). |
|
204 | - " Pagantis order status:".$this->pagantisOrder->getId(); |
|
201 | + " Merchant order id:".$this->woocommerceOrder->get_id(). |
|
202 | + " Merchant order status:".$this->woocommerceOrder->get_status(). |
|
203 | + " Pagantis order id:".$this->pagantisOrder->getStatus(). |
|
204 | + " Pagantis order status:".$this->pagantisOrder->getId(); |
|
205 | 205 | |
206 | 206 | $this->insertLog(null, $logMessage); |
207 | 207 | $this->woocommerceOrder->add_order_note($logMessage); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | try { |
66 | 66 | require_once(__ROOT__.'/vendor/autoload.php'); |
67 | 67 | try { |
68 | - if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_GET['origin'] == 'notification') { |
|
68 | + if ($_SERVER['REQUEST_METHOD']=='GET' && $_GET['origin']=='notification') { |
|
69 | 69 | return $this->buildResponse(); |
70 | 70 | } |
71 | 71 | $this->checkConcurrency(); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | private function checkConcurrency() |
115 | 115 | { |
116 | 116 | $this->woocommerceOrderId = $_GET['order-received']; |
117 | - if ($this->woocommerceOrderId == '') { |
|
117 | + if ($this->woocommerceOrderId=='') { |
|
118 | 118 | throw new QuoteNotFoundException(); |
119 | 119 | } |
120 | 120 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | private function getProductType() |
129 | 129 | { |
130 | - if ($_GET['product'] == '') { |
|
130 | + if ($_GET['product']=='') { |
|
131 | 131 | $this->setProduct(WcPagantisGateway::METHOD_ID); |
132 | 132 | } else { |
133 | 133 | $this->setProduct($_GET['product']); |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | $queryResult = $wpdb->get_row("select order_id from $tableName where id='".$this->woocommerceOrderId."'"); |
159 | 159 | $this->pagantisOrderId = $queryResult->order_id; |
160 | 160 | |
161 | - if ($this->pagantisOrderId == '') { |
|
161 | + if ($this->pagantisOrderId=='') { |
|
162 | 162 | throw new NoIdentificationException(); |
163 | 163 | } |
164 | 164 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | $status = '-'; |
202 | 202 | } |
203 | 203 | |
204 | - if ($status === Order::STATUS_CONFIRMED) { |
|
204 | + if ($status===Order::STATUS_CONFIRMED) { |
|
205 | 205 | return true; |
206 | 206 | } |
207 | 207 | throw new WrongStatusException($status); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | ); |
223 | 223 | |
224 | 224 | if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM |
225 | - $logMessage = "WARNING checkMerchantOrderStatus." . |
|
225 | + $logMessage = "WARNING checkMerchantOrderStatus.". |
|
226 | 226 | " Merchant order id:".$this->woocommerceOrder->get_id(). |
227 | 227 | " Merchant order status:".$this->woocommerceOrder->get_status(). |
228 | 228 | " Pagantis order id:".$this->pagantisOrder->getStatus(). |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | { |
245 | 245 | $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
246 | 246 | $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total())); |
247 | - if ($pagantisAmount != $wcAmount) { |
|
247 | + if ($pagantisAmount!=$wcAmount) { |
|
248 | 248 | throw new AmountMismatchException($pagantisAmount, $wcAmount); |
249 | 249 | } |
250 | 250 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId); |
269 | 269 | } catch (\Exception $e) { |
270 | 270 | $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId); |
271 | - if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) { |
|
271 | + if ($this->pagantisOrder->getStatus()!==Order::STATUS_CONFIRMED) { |
|
272 | 272 | throw new UnknownException($e->getMessage()); |
273 | 273 | } else { |
274 | 274 | $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process'; |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | global $wpdb; |
293 | 293 | $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
294 | 294 | |
295 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
295 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
296 | 296 | $charset_collate = $wpdb->get_charset_collate(); |
297 | 297 | $sql = "CREATE TABLE $tableName (id int, order_id varchar(50), wc_order_id varchar(50), |
298 | 298 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | global $wpdb; |
311 | 311 | $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
312 | 312 | |
313 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
313 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
314 | 314 | $charset_collate = $wpdb->get_charset_collate(); |
315 | 315 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
316 | 316 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -367,12 +367,12 @@ discard block |
||
367 | 367 | $metadataOrder = $this->pagantisOrder->getMetadata(); |
368 | 368 | $metadataInfo = null; |
369 | 369 | foreach ($metadataOrder as $metadataKey => $metadataValue) { |
370 | - if ($metadataKey == 'promotedProduct') { |
|
371 | - $metadataInfo.= "/Producto promocionado = $metadataValue"; |
|
370 | + if ($metadataKey=='promotedProduct') { |
|
371 | + $metadataInfo .= "/Producto promocionado = $metadataValue"; |
|
372 | 372 | } |
373 | 373 | } |
374 | 374 | |
375 | - if ($metadataInfo != null) { |
|
375 | + if ($metadataInfo!=null) { |
|
376 | 376 | $this->woocommerceOrder->add_order_note($metadataInfo); |
377 | 377 | } |
378 | 378 | |
@@ -441,13 +441,13 @@ discard block |
||
441 | 441 | { |
442 | 442 | global $wpdb; |
443 | 443 | $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME; |
444 | - if ($orderId == null) { |
|
444 | + if ($orderId==null) { |
|
445 | 445 | $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT." SECOND)"; |
446 | 446 | } else { |
447 | 447 | $query = "DELETE FROM $tableName WHERE order_id = $orderId"; |
448 | 448 | } |
449 | 449 | $resultDelete = $wpdb->query($query); |
450 | - if ($resultDelete === false) { |
|
450 | + if ($resultDelete===false) { |
|
451 | 451 | throw new ConcurrencyException(); |
452 | 452 | } |
453 | 453 | } |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | global $wpdb; |
463 | 463 | $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME; |
464 | 464 | $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId)); |
465 | - if ($insertResult === false) { |
|
466 | - if ($this->getOrigin() == 'Notify') { |
|
465 | + if ($insertResult===false) { |
|
466 | + if ($this->getOrigin()=='Notify') { |
|
467 | 467 | throw new ConcurrencyException(); |
468 | 468 | } else { |
469 | 469 | $query = sprintf( |
@@ -474,8 +474,8 @@ discard block |
||
474 | 474 | ); |
475 | 475 | $resultSeconds = $wpdb->get_row($query); |
476 | 476 | $restSeconds = isset($resultSeconds) ? ($resultSeconds->rest) : 0; |
477 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
478 | - sleep($secondsToExpire+1); |
|
477 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
478 | + sleep($secondsToExpire + 1); |
|
479 | 479 | |
480 | 480 | $logMessage = sprintf( |
481 | 481 | "User waiting %s seconds, default seconds %s, bd time to expire %s seconds", |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | { |
500 | 500 | $this->unblockConcurrency($this->woocommerceOrderId); |
501 | 501 | |
502 | - if ($exception == null) { |
|
502 | + if ($exception==null) { |
|
503 | 503 | $jsonResponse = new JsonSuccessResponse(); |
504 | 504 | } else { |
505 | 505 | $jsonResponse = new JsonExceptionResponse(); |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | $jsonResponse->setMerchantOrderId($this->woocommerceOrderId); |
510 | 510 | $jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
511 | 511 | |
512 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
512 | + if ($_SERVER['REQUEST_METHOD']=='POST') { |
|
513 | 513 | $jsonResponse->printResponse(); |
514 | 514 | } else { |
515 | 515 | return $jsonResponse; |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | */ |
542 | 542 | private function isProduct4x() |
543 | 543 | { |
544 | - return ($this->product === Ucfirst(WcPagantis4xGateway::METHOD_ID)); |
|
544 | + return ($this->product===Ucfirst(WcPagantis4xGateway::METHOD_ID)); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -613,7 +613,7 @@ |
||
613 | 613 | if ($file == plugin_basename(__FILE__)) { |
614 | 614 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
615 | 615 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
616 | - __('API documentation', 'pagantis').'</a>'; |
|
616 | + __('API documentation', 'pagantis').'</a>'; |
|
617 | 617 | $links[] = '<a href="'.WcPagantis::SUPPORT_EML.'">'.__('Support', 'pagantis').'</a>'; |
618 | 618 | |
619 | 619 | return $links; |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | |
22 | -require_once(__DIR__ . '/includes/pg-functions.php'); |
|
22 | +require_once(__DIR__.'/includes/pg-functions.php'); |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Required minimums and constants |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | public function __construct() |
82 | 82 | { |
83 | 83 | require_once(plugin_dir_path(__FILE__).'/vendor/autoload.php'); |
84 | - require_once(PG_ABSPATH . '/includes/pg-functions.php'); |
|
84 | + require_once(PG_ABSPATH.'/includes/pg-functions.php'); |
|
85 | 85 | $this->template_path = plugin_dir_path(__FILE__).'/templates/'; |
86 | 86 | |
87 | 87 | $this->pagantisActivation(); |
@@ -97,15 +97,15 @@ discard block |
||
97 | 97 | add_action('init', array($this, 'checkWcPriceSettings'), 10); |
98 | 98 | add_action('woocommerce_after_template_part', array($this, 'pagantisAddSimulatorHtmlDiv'), 10); |
99 | 99 | add_action('woocommerce_single_product_summary', array($this, 'pagantisInitProductSimulator'), 20); |
100 | - add_action('woocommerce_single_variation', array($this,'pagantisAddProductSnippetForVariations'), 30); |
|
100 | + add_action('woocommerce_single_variation', array($this, 'pagantisAddProductSnippetForVariations'), 30); |
|
101 | 101 | add_action('wp_enqueue_scripts', 'add_pagantis_widget_js'); |
102 | 102 | add_action('rest_api_init', array($this, 'pagantisRegisterEndpoint')); //Endpoint |
103 | 103 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
104 | 104 | register_activation_hook(__FILE__, array($this, 'pagantisActivation')); |
105 | 105 | add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl')); |
106 | 106 | add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave')); |
107 | - add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate')); |
|
108 | - add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave')); |
|
107 | + add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate')); |
|
108 | + add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave')); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | { |
132 | 132 | $post_id = $product->get_id(); |
133 | 133 | $pagantis_promoted_value = $_REQUEST['pagantis_promoted']; |
134 | - if ($pagantis_promoted_value === 'on') { |
|
134 | + if ($pagantis_promoted_value==='on') { |
|
135 | 135 | $pagantis_promoted_value = 'yes'; |
136 | 136 | } else { |
137 | 137 | $pagantis_promoted_value = 'no'; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | public function pagantisPromotedVarSave($post_id) |
166 | 166 | { |
167 | 167 | $pagantis_promoted_value = $_POST['pagantis_promoted']; |
168 | - if ($pagantis_promoted_value !== 'yes') { |
|
168 | + if ($pagantis_promoted_value!=='yes') { |
|
169 | 169 | $pagantis_promoted_value = 'no'; |
170 | 170 | } |
171 | 171 | |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function loadPagantisTranslation($mofile, $domain) |
181 | 181 | { |
182 | - if ('pagantis' === $domain) { |
|
183 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
182 | + if ('pagantis'===$domain) { |
|
183 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
184 | 184 | } |
185 | 185 | return $mofile; |
186 | 186 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | global $wpdb; |
194 | 194 | |
195 | 195 | $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME; |
196 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
196 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
197 | 197 | $charset_collate = $wpdb->get_charset_collate(); |
198 | 198 | $sql = "CREATE TABLE $tableName ( order_id int NOT NULL, |
199 | 199 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate"; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
205 | 205 | |
206 | 206 | //Check if table exists |
207 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; |
|
207 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; |
|
208 | 208 | if ($tableExists) { |
209 | 209 | $charset_collate = $wpdb->get_charset_collate(); |
210 | 210 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | //Updated value field to adapt to new length < v8.0.1 |
220 | 220 | $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'"; |
221 | 221 | $results = $wpdb->get_results($query, ARRAY_A); |
222 | - if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') { |
|
222 | + if ($results['0']['COLUMN_TYPE']=='varchar(100)') { |
|
223 | 223 | $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)"; |
224 | 224 | $wpdb->query($sql); |
225 | 225 | } |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
230 | 230 | $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A); |
231 | 231 | foreach ($dbCurrentConfig as $item) { |
232 | - if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
232 | + if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
233 | 233 | $css_price_selector = $this->preparePriceSelector($item['value']); |
234 | - if ($item['value'] != $css_price_selector) { |
|
234 | + if ($item['value']!=$css_price_selector) { |
|
235 | 235 | $wpdb->update( |
236 | 236 | $tableName, |
237 | 237 | array('value' => stripslashes($css_price_selector)), |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | array('%s') |
241 | 241 | ); |
242 | 242 | } |
243 | - } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
243 | + } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
244 | 244 | $css_quantity_selector = $this->prepareQuantitySelector($item['value']); |
245 | - if ($item['value'] != $css_quantity_selector) { |
|
245 | + if ($item['value']!=$css_quantity_selector) { |
|
246 | 246 | $wpdb->update( |
247 | 247 | $tableName, |
248 | 248 | array('value' => stripslashes($css_quantity_selector)), |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | // Making sure DB tables are created < v8.6.9 |
259 | - if (!isPgTableCreated(PG_LOGS_TABLE_NAME)){ |
|
259 | + if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) { |
|
260 | 260 | createLogsTable(); |
261 | 261 | } |
262 | 262 | checkCartProcessTable(); |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
266 | 266 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
267 | 267 | $results = $wpdb->get_results($query, ARRAY_A); |
268 | - if (count($results) == 0) { |
|
268 | + if (count($results)==0) { |
|
269 | 269 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value' => '.'), array('%s', '%s')); |
270 | 270 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value' => ','), array('%s', '%s')); |
271 | 271 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
275 | 275 | $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'"; |
276 | 276 | $results = $wpdb->get_results($query, ARRAY_A); |
277 | - if (count($results) == 0) { |
|
277 | + if (count($results)==0) { |
|
278 | 278 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value' => '0'), array('%s', '%s')); |
279 | 279 | } |
280 | 280 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
283 | 283 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'"; |
284 | 284 | $results = $wpdb->get_results($query, ARRAY_A); |
285 | - if (count($results) == 0) { |
|
285 | + if (count($results)==0) { |
|
286 | 286 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value' => 'default'), array('%s', '%s')); |
287 | 287 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value' => 'default'), array('%s', '%s')); |
288 | 288 | } |
@@ -292,17 +292,17 @@ discard block |
||
292 | 292 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
293 | 293 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'"; |
294 | 294 | $results = $wpdb->get_results($query, ARRAY_A); |
295 | - if (count($results) == 0) { |
|
295 | + if (count($results)==0) { |
|
296 | 296 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', 'value' => 'sdk.simulator.types.CHECKOUT_PAGE'), array('%s', '%s')); |
297 | 297 | $wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), array('%s'), array('%s')); |
298 | 298 | } |
299 | 299 | |
300 | 300 | //Adapting to variable selector < v8.3.6 |
301 | - $variableSelector="div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
301 | + $variableSelector = "div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
302 | 302 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
303 | 303 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'"; |
304 | 304 | $results = $wpdb->get_results($query, ARRAY_A); |
305 | - if (count($results) == 0) { |
|
305 | + if (count($results)==0) { |
|
306 | 306 | $wpdb->update($tableName, array('value' => $variableSelector), array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION'), array('%s'), array('%s')); |
307 | 307 | } |
308 | 308 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
311 | 311 | $query = "select * from $tableName where config='PAGANTIS_TITLE_4x'"; |
312 | 312 | $results = $wpdb->get_results($query, ARRAY_A); |
313 | - if (count($results) == 0) { |
|
313 | + if (count($results)==0) { |
|
314 | 314 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_TITLE_4x', 'value' => 'Until 4 installments, without fees'), array('%s', '%s')); |
315 | 315 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MIN_AMOUNT_4x', 'value' => 1), array('%s', '%s')); |
316 | 316 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT_4x', 'value' => 800), array('%s', '%s')); |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
324 | 324 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X'"; |
325 | 325 | $results = $wpdb->get_results($query, ARRAY_A); |
326 | - if (count($results) == 0) { |
|
326 | + if (count($results)==0) { |
|
327 | 327 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X', 'value' => 'default'), array('%s', '%s')); |
328 | 328 | } |
329 | 329 | |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
340 | 340 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
341 | 341 | $results = $wpdb->get_results($query, ARRAY_A); |
342 | - if (count($results) == 0) { |
|
342 | + if (count($results)==0) { |
|
343 | 343 | $wpdb->update($tableName, array('value' => 'a:4:{i:0;s:52:"div.summary *:not(del)>.woocommerce-Price-amount bdi";i:1;s:48:"div.summary *:not(del)>.woocommerce-Price-amount";i:2;s:54:"div.entry-summary *:not(del)>.woocommerce-Price-amount";i:3;s:36:"*:not(del)>.woocommerce-Price-amount";}'), array('config' => 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'), array('%s'), array('%s')); |
344 | 344 | } |
345 | 345 | |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | $isAtcTplPresent = isTemplatePresent( |
433 | 433 | $template_name, |
434 | 434 | array('single-product/add-to-cart/variation-add-to-cart-button.php', |
435 | - 'single-product/add-to-cart/variation.php','single-product/add-to-cart/simple.php') |
|
435 | + 'single-product/add-to-cart/variation.php', 'single-product/add-to-cart/simple.php') |
|
436 | 436 | ); |
437 | 437 | |
438 | 438 | $html = apply_filters('pagantis_simulator_selector_html', '<div class="mainPagantisSimulator"></div><div class="pagantisSimulator"></div>'); |
@@ -444,10 +444,10 @@ discard block |
||
444 | 444 | } |
445 | 445 | |
446 | 446 | $pagantisSimulator4x = 'enabled'; |
447 | - if (!isPluginEnabled4x() || !areMerchantKeysSet4x() || !isCountryShopContextValid() || !isProductAmountValid4x()) { |
|
447 | + if (!isPluginEnabled4x() || !areMerchantKeysSet4x() || !isCountryShopContextValid() || !isProductAmountValid4x()) { |
|
448 | 448 | $pagantisSimulator4x = 'disabled'; |
449 | 449 | } |
450 | - if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') { |
|
450 | + if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') { |
|
451 | 451 | return; |
452 | 452 | } |
453 | 453 | |
@@ -503,12 +503,12 @@ discard block |
||
503 | 503 | $pagantisSimulator4x = 'disabled'; |
504 | 504 | } |
505 | 505 | |
506 | - if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') { |
|
506 | + if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') { |
|
507 | 507 | return; |
508 | 508 | } |
509 | 509 | |
510 | 510 | $totalPrice = $product->get_price(); |
511 | - $formattedInstallments = number_format($totalPrice/4, 2); |
|
511 | + $formattedInstallments = number_format($totalPrice / 4, 2); |
|
512 | 512 | $simulatorMessage = sprintf(__('or 4 installments of %s€, without fees, with ', 'pagantis'), $formattedInstallments); |
513 | 513 | $post_id = $product->get_id(); |
514 | 514 | $simulatorData = array( |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | */ |
551 | 551 | public function addPagantisGateway($methods) |
552 | 552 | { |
553 | - if (! class_exists('WC_Payment_Gateway')) { |
|
553 | + if (!class_exists('WC_Payment_Gateway')) { |
|
554 | 554 | return $methods; |
555 | 555 | } |
556 | 556 | |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | */ |
616 | 616 | public function pagantisRowMeta($links, $file) |
617 | 617 | { |
618 | - if ($file == plugin_basename(__FILE__)) { |
|
618 | + if ($file==plugin_basename(__FILE__)) { |
|
619 | 619 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
620 | 620 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
621 | 621 | __('API documentation', 'pagantis').'</a>'; |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
645 | 645 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
646 | 646 | $results = $wpdb->get_results($query); |
647 | - if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) { |
|
647 | + if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) { |
|
648 | 648 | foreach ($results as $key => $result) { |
649 | 649 | $response[$key]['timestamp'] = $result->createdAt; |
650 | 650 | $response[$key]['log'] = json_decode($result->log); |
@@ -671,13 +671,13 @@ discard block |
||
671 | 671 | |
672 | 672 | $filters = ($data->get_params()); |
673 | 673 | $secretKey = $filters['secret']; |
674 | - $cfg = get_option('woocommerce_pagantis_settings'); |
|
674 | + $cfg = get_option('woocommerce_pagantis_settings'); |
|
675 | 675 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
676 | 676 | $privateKey4x = isset($cfg['pagantis_private_key_4x']) ? $cfg['pagantis_private_key_4x'] : null; |
677 | - if ($privateKey != $secretKey && $privateKey4x != $secretKey) { |
|
677 | + if ($privateKey!=$secretKey && $privateKey4x!=$secretKey) { |
|
678 | 678 | $response['status'] = 401; |
679 | 679 | $response['result'] = 'Unauthorized'; |
680 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
680 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
681 | 681 | if (count($_POST)) { |
682 | 682 | foreach ($_POST as $config => $value) { |
683 | 683 | if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc"; |
739 | 739 | $results = $wpdb->get_results($query); |
740 | 740 | |
741 | - if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) { |
|
741 | + if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) { |
|
742 | 742 | foreach ($results as $result) { |
743 | 743 | $key = $result->ID; |
744 | 744 | $response['message'][$key]['timestamp'] = $result->post_date; |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | */ |
812 | 812 | private function prepareQuantitySelector($css_quantity_selector) |
813 | 813 | { |
814 | - if ($css_quantity_selector == 'default' || $css_quantity_selector == '') { |
|
814 | + if ($css_quantity_selector=='default' || $css_quantity_selector=='') { |
|
815 | 815 | $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
816 | 816 | } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
817 | 817 | $css_quantity_selector = serialize(array($css_quantity_selector)); |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | */ |
828 | 828 | private function preparePriceSelector($css_price_selector) |
829 | 829 | { |
830 | - if ($css_price_selector == 'default' || $css_price_selector == '') { |
|
830 | + if ($css_price_selector=='default' || $css_price_selector=='') { |
|
831 | 831 | $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
832 | 832 | } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
833 | 833 | $css_price_selector = serialize(array($css_price_selector)); |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | { |
846 | 846 | $metaProduct = get_post_meta($product_id); |
847 | 847 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && |
848 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
848 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
849 | 849 | } |
850 | 850 | |
851 | 851 | /** |
@@ -245,9 +245,9 @@ discard block |
||
245 | 245 | if ($promotedProduct == 'true') { |
246 | 246 | $promotedAmount+=$product->getAmount(); |
247 | 247 | $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
248 | - ' - Price: ' . $item->get_total() . |
|
249 | - ' - Qty: ' . $product->getQuantity() . |
|
250 | - ' - Item ID: ' . $item['id_product']; |
|
248 | + ' - Price: ' . $item->get_total() . |
|
249 | + ' - Qty: ' . $product->getQuantity() . |
|
250 | + ' - Item ID: ' . $item['id_product']; |
|
251 | 251 | $promotedMessage = substr($promotedMessage, 0, 999); |
252 | 252 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
253 | 253 | } |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | $orderConfigurationUrls = new Urls(); |
264 | 264 | $cancelUrl = $this->getKoUrl($order); |
265 | 265 | $callback_arg = array('wc-api'=>'wcpagantisgateway', |
266 | - 'key'=>$order->get_order_key(), |
|
267 | - 'order-received'=>$order->get_id(), |
|
268 | - 'origin' => '' |
|
266 | + 'key'=>$order->get_order_key(), |
|
267 | + 'order-received'=>$order->get_id(), |
|
268 | + 'origin' => '' |
|
269 | 269 | ); |
270 | 270 | |
271 | 271 | $callback_arg_user = $callback_arg; |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | $this->method_title = ucfirst($this->id); |
61 | 61 | |
62 | 62 | //Useful vars |
63 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/'; |
|
63 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/'; |
|
64 | 64 | $this->allowed_currencies = getAllowedCurrencies(); |
65 | - $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Pagantis.php'; |
|
65 | + $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)).'/WC_Pagantis.php'; |
|
66 | 66 | $this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false); |
67 | 67 | $this->language = strstr(get_locale(), '_', true); |
68 | 68 | if ($this->language=='') { |
@@ -71,24 +71,24 @@ discard block |
||
71 | 71 | $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
72 | 72 | |
73 | 73 | //Panel form fields |
74 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options |
|
74 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options |
|
75 | 75 | $this->init_settings(); |
76 | 76 | |
77 | 77 | $this->extraConfig = getExtraConfig(); |
78 | 78 | $this->title = __($this->extraConfig['PAGANTIS_TITLE_4x'], 'pagantis'); |
79 | 79 | $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis."; |
80 | 80 | |
81 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl(); |
|
82 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl(); |
|
81 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
82 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
83 | 83 | foreach ($this->settings as $setting_key => $setting_value) { |
84 | 84 | $this->$setting_key = $setting_value; |
85 | 85 | } |
86 | 86 | |
87 | 87 | //Hooks |
88 | - add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options |
|
89 | - add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
90 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
91 | - add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3); |
|
88 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options |
|
89 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
90 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
91 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3); |
|
92 | 92 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
93 | 93 | } |
94 | 94 | |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function loadPagantisTranslation($mofile, $domain) |
102 | 102 | { |
103 | - if ('pagantis' === $domain) { |
|
104 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
103 | + if ('pagantis'===$domain) { |
|
104 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
105 | 105 | } |
106 | 106 | return $mofile; |
107 | 107 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | $shippingAddress = $order->get_address('shipping'); |
152 | 152 | $billingAddress = $order->get_address('billing'); |
153 | - if ($shippingAddress['address_1'] == '') { |
|
153 | + if ($shippingAddress['address_1']=='') { |
|
154 | 154 | $shippingAddress = $billingAddress; |
155 | 155 | } |
156 | 156 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | ->setNationalId($national_id) |
178 | 178 | ->setTaxId($tax_id) |
179 | 179 | ; |
180 | - $orderBillingAddress = new Address(); |
|
180 | + $orderBillingAddress = new Address(); |
|
181 | 181 | $orderBillingAddress |
182 | 182 | ->setZipCode($billingAddress['postcode']) |
183 | 183 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
@@ -250,12 +250,12 @@ discard block |
||
250 | 250 | $details->addProduct($product); |
251 | 251 | |
252 | 252 | $promotedProduct = isProductPromoted($item->get_product_id()); |
253 | - if ($promotedProduct == 'true') { |
|
254 | - $promotedAmount+=$product->getAmount(); |
|
255 | - $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
|
256 | - ' - Price: ' . $item->get_total() . |
|
257 | - ' - Qty: ' . $product->getQuantity() . |
|
258 | - ' - Item ID: ' . $item['id_product']; |
|
253 | + if ($promotedProduct=='true') { |
|
254 | + $promotedAmount += $product->getAmount(); |
|
255 | + $promotedMessage = 'Promoted Item: '.$wcProduct->get_name(). |
|
256 | + ' - Price: '.$item->get_total(). |
|
257 | + ' - Qty: '.$product->getQuantity(). |
|
258 | + ' - Item ID: '.$item['id_product']; |
|
259 | 259 | $promotedMessage = substr($promotedMessage, 0, 999); |
260 | 260 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
261 | 261 | } |
@@ -301,9 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
303 | 303 | $purchaseCountry = |
304 | - in_array(strtolower($this->language), $allowedCountries) ? $this->language : |
|
305 | - in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : |
|
306 | - in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null; |
|
304 | + 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; |
|
307 | 305 | |
308 | 306 | $orderConfiguration = new Configuration(); |
309 | 307 | $orderConfiguration |
@@ -347,7 +345,7 @@ discard block |
||
347 | 345 | wc_get_template('iframe.php', $template_fields, '', $this->template_path); |
348 | 346 | } |
349 | 347 | } catch (\Exception $exception) { |
350 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); |
|
348 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); |
|
351 | 349 | insertLogEntry($exception); |
352 | 350 | $checkout_url = get_permalink(wc_get_page_id('checkout')); |
353 | 351 | wp_redirect($checkout_url); |
@@ -363,7 +361,7 @@ discard block |
||
363 | 361 | public function pagantisNotification() |
364 | 362 | { |
365 | 363 | try { |
366 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
364 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
367 | 365 | |
368 | 366 | include_once('notifyController.php'); |
369 | 367 | $notify = new WcPagantisNotify(); |
@@ -402,10 +400,10 @@ discard block |
||
402 | 400 | */ |
403 | 401 | public function pagantisCompleteStatus($status, $order_id, $order) |
404 | 402 | { |
405 | - if ($order->get_payment_method() == WcPagantis4xGateway::METHOD_ID) { |
|
406 | - if ($order->get_status() == 'failed') { |
|
403 | + if ($order->get_payment_method()==WcPagantis4xGateway::METHOD_ID) { |
|
404 | + if ($order->get_status()=='failed') { |
|
407 | 405 | $status = 'processing'; |
408 | - } elseif ($order->get_status() == 'pending' && $status=='completed') { |
|
406 | + } elseif ($order->get_status()=='pending' && $status=='completed') { |
|
409 | 407 | $status = 'processing'; |
410 | 408 | } |
411 | 409 | } |
@@ -434,8 +432,8 @@ discard block |
||
434 | 432 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
435 | 433 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT_4x']; |
436 | 434 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT_4x']; |
437 | - $totalPrice = (int)$this->get_order_total(); |
|
438 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
435 | + $totalPrice = (int) $this->get_order_total(); |
|
436 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
439 | 437 | if ($cfg['enabled_4x']==='yes' && $cfg['pagantis_public_key_4x']!='' && $cfg['pagantis_private_key_4x']!='' && |
440 | 438 | $validAmount && $allowedCountry) { |
441 | 439 | return true; |
@@ -470,7 +468,7 @@ discard block |
||
470 | 468 | |
471 | 469 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
472 | 470 | if (strpos($redirectUrl, 'order-pay=')===false) { |
473 | - $redirectUrl.="&order-pay=".$order_id; |
|
471 | + $redirectUrl .= "&order-pay=".$order_id; |
|
474 | 472 | } |
475 | 473 | |
476 | 474 | return array( |
@@ -478,7 +476,7 @@ discard block |
||
478 | 476 | 'redirect' => $redirectUrl |
479 | 477 | ); |
480 | 478 | } catch (Exception $e) { |
481 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); |
|
479 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); |
|
482 | 480 | return array(); |
483 | 481 | } |
484 | 482 | } |
@@ -549,7 +547,7 @@ discard block |
||
549 | 547 | private function generateUrl($url) |
550 | 548 | { |
551 | 549 | $parsed_url = parse_url($url); |
552 | - if ($parsed_url !== false) { |
|
550 | + if ($parsed_url!==false) { |
|
553 | 551 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
554 | 552 | parse_str($parsed_url['query'], $arrayParams); |
555 | 553 | foreach ($arrayParams as $keyParam => $valueParam) { |
@@ -597,11 +595,10 @@ discard block |
||
597 | 595 | private function getKeysUrl($order, $url) |
598 | 596 | { |
599 | 597 | $defaultFields = (get_class($order)=='WC_Order') ? |
600 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : |
|
601 | - array(); |
|
598 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array(); |
|
602 | 599 | |
603 | 600 | $parsedUrl = parse_url($url); |
604 | - if ($parsedUrl !== false) { |
|
601 | + if ($parsedUrl!==false) { |
|
605 | 602 | //Replace parameters from url |
606 | 603 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
607 | 604 | |
@@ -646,7 +643,7 @@ discard block |
||
646 | 643 | foreach ($arrayParams as $keyParam => $valueParam) { |
647 | 644 | preg_match('#\{{.*?}\}#', $valueParam, $match); |
648 | 645 | if (count($match)) { |
649 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]); |
|
646 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]); |
|
650 | 647 | $arrayParams[$keyParam] = $defaultFields[$key]; |
651 | 648 | } |
652 | 649 | } |
@@ -661,12 +658,12 @@ discard block |
||
661 | 658 | */ |
662 | 659 | private function unparseUrl($parsed_url) |
663 | 660 | { |
664 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
661 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
665 | 662 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
666 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
667 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
668 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
663 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
664 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
665 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
669 | 666 | $path = $parsed_url['path']; |
670 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
667 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
671 | 668 | } |
672 | 669 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | function requireWPPluginFunctions() |
3 | 3 | { |
4 | - if (! function_exists('is_plugin_active')) { |
|
5 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
4 | + if (!function_exists('is_plugin_active')) { |
|
5 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
6 | 6 | } |
7 | 7 | } |
8 | 8 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | function getConfigValue($configKey) |
21 | 21 | { |
22 | 22 | global $wpdb; |
23 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
23 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
24 | 24 | $value = $wpdb->get_var($wpdb->prepare("SELECT value FROM $tableName WHERE config= %s ", $configKey)); |
25 | 25 | |
26 | 26 | return $value; |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | function isPgTableCreated($tableToCheck) |
38 | 38 | { |
39 | 39 | global $wpdb; |
40 | - $tableName = $wpdb->prefix . $tableToCheck; |
|
41 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) { |
|
40 | + $tableName = $wpdb->prefix.$tableToCheck; |
|
41 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")==$tableName) { |
|
42 | 42 | return true; |
43 | 43 | } |
44 | 44 | |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | function createPgCartTable() |
52 | 52 | { |
53 | 53 | global $wpdb; |
54 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
54 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
55 | 55 | $charset_collate = $wpdb->get_charset_collate(); |
56 | 56 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
57 | 57 | UNIQUE KEY id (id)) $charset_collate"; |
58 | 58 | |
59 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
59 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
60 | 60 | dbDelta($sql); |
61 | 61 | } |
62 | 62 | |
@@ -64,14 +64,14 @@ discard block |
||
64 | 64 | { |
65 | 65 | global $wpdb; |
66 | 66 | $charset_collate = $wpdb->get_charset_collate(); |
67 | - $LogsTableName = $wpdb->prefix . PG_LOGS_TABLE_NAME; |
|
67 | + $LogsTableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
|
68 | 68 | $sqlQuery = "CREATE TABLE $LogsTableName ( |
69 | 69 | id int NOT NULL AUTO_INCREMENT, |
70 | 70 | log text NOT NULL, |
71 | 71 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, |
72 | 72 | UNIQUE KEY id (id)) |
73 | 73 | $charset_collate"; |
74 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
74 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
75 | 75 | dbDelta($sqlQuery); |
76 | 76 | } |
77 | 77 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | function insertLogEntry($exception = null, $message = null) |
83 | 83 | { |
84 | 84 | global $wpdb; |
85 | - if (! isPgTableCreated(PG_LOGS_TABLE_NAME)) { |
|
85 | + if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) { |
|
86 | 86 | createLogsTable(); |
87 | 87 | } |
88 | 88 | $logEntry = new Pagantis\ModuleUtils\Model\Log\LogEntry(); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | } else { |
92 | 92 | $logEntry = $logEntry->info($message); |
93 | 93 | } |
94 | - $tableName = $wpdb->prefix . PG_LOGS_TABLE_NAME; |
|
94 | + $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
|
95 | 95 | $wpdb->insert($tableName, array('log' => $logEntry->toJson())); |
96 | 96 | } |
97 | 97 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | { |
103 | 103 | $pgDecimalSeparator = getPgSimulatorDecimalSeparatorConfig(); |
104 | 104 | $wc_decimal_sep = get_option('woocommerce_price_decimal_sep'); |
105 | - if (stripslashes($wc_decimal_sep) == stripslashes($pgDecimalSeparator)) { |
|
105 | + if (stripslashes($wc_decimal_sep)==stripslashes($pgDecimalSeparator)) { |
|
106 | 106 | return true; |
107 | 107 | } else { |
108 | 108 | return false; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | { |
118 | 118 | $pgThousandSeparator = getPgSimulatorThousandsSeparator(); |
119 | 119 | $wc_price_thousand = get_option('woocommerce_price_thousand_sep'); |
120 | - if (stripslashes($wc_price_thousand) == stripslashes($pgThousandSeparator)) { |
|
120 | + if (stripslashes($wc_price_thousand)==stripslashes($pgThousandSeparator)) { |
|
121 | 121 | return true; |
122 | 122 | } else { |
123 | 123 | return false; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | function getPgSimulatorThousandsSeparator() |
131 | 131 | { |
132 | 132 | global $wpdb; |
133 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
133 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
134 | 134 | $query = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
135 | 135 | $result = $wpdb->get_row($query, ARRAY_A); |
136 | 136 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | function getPgSimulatorDecimalSeparatorConfig() |
144 | 144 | { |
145 | 145 | global $wpdb; |
146 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
146 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
147 | 147 | $query = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'"; |
148 | 148 | $result = $wpdb->get_row($query, ARRAY_A); |
149 | 149 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | if (areThousandsSeparatorEqual()) { |
157 | 157 | return; |
158 | 158 | } |
159 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
159 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
160 | 160 | $thousandSeparator = get_option('woocommerce_price_thousand_sep'); |
161 | 161 | $wpdb->update( |
162 | 162 | $tableName, |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | if (areDecimalSeparatorEqual()) { |
174 | 174 | return; |
175 | 175 | } |
176 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
176 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
177 | 177 | $decimalSeparator = get_option('woocommerce_price_decimal_sep'); |
178 | 178 | $wpdb->update( |
179 | 179 | $tableName, |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | function isSimulatorTypeValid($simulatorType, $validSimulatorTypes) |
195 | 195 | { |
196 | - if (! in_array($simulatorType, $validSimulatorTypes)) { |
|
196 | + if (!in_array($simulatorType, $validSimulatorTypes)) { |
|
197 | 197 | return false; |
198 | 198 | } |
199 | 199 | |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | function areMerchantKeysSet() |
221 | 221 | { |
222 | 222 | $settings = get_option('woocommerce_pagantis_settings'); |
223 | - $publicKey = ! empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : ''; |
|
224 | - $privateKey = ! empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : ''; |
|
223 | + $publicKey = !empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : ''; |
|
224 | + $privateKey = !empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : ''; |
|
225 | 225 | if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) { |
226 | 226 | return false; |
227 | 227 | } |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | function areMerchantKeysSet4x() |
233 | 233 | { |
234 | 234 | $settings = get_option('woocommerce_pagantis_settings'); |
235 | - $publicKey = ! empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : ''; |
|
236 | - $privateKey = ! empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : ''; |
|
235 | + $publicKey = !empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : ''; |
|
236 | + $privateKey = !empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : ''; |
|
237 | 237 | if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) { |
238 | 238 | return false; |
239 | 239 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | function isSimulatorEnabled() |
245 | 245 | { |
246 | 246 | $settings = get_option('woocommerce_pagantis_settings'); |
247 | - if ((! empty($settings['simulator']) && 'yes' === $settings['simulator']) ? true : false) { |
|
247 | + if ((!empty($settings['simulator']) && 'yes'===$settings['simulator']) ? true : false) { |
|
248 | 248 | return true; |
249 | 249 | } |
250 | 250 | |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | { |
256 | 256 | $settings = get_option('woocommerce_pagantis_settings'); |
257 | 257 | |
258 | - return (! empty($settings['enabled']) && 'yes' === $settings['enabled']); |
|
258 | + return (!empty($settings['enabled']) && 'yes'===$settings['enabled']); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | function isPluginEnabled4x() |
262 | 262 | { |
263 | 263 | $settings = get_option('woocommerce_pagantis_settings'); |
264 | - return (! empty($settings['enabled_4x']) && 'yes' === $settings['enabled_4x']); |
|
264 | + return (!empty($settings['enabled_4x']) && 'yes'===$settings['enabled_4x']); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | { |
270 | 270 | $locale = strtolower(strstr(get_locale(), '_', true)); |
271 | 271 | $allowedCountries = maybe_unserialize(getConfigValue('PAGANTIS_ALLOWED_COUNTRIES')); |
272 | - if (! in_array(strtolower($locale), $allowedCountries)) { |
|
272 | + if (!in_array(strtolower($locale), $allowedCountries)) { |
|
273 | 273 | return false; |
274 | 274 | } |
275 | 275 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | global $product; |
287 | 287 | if (method_exists($product, 'get_price')) { |
288 | 288 | $productPrice = $product->get_price(); |
289 | - $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0')); |
|
289 | + $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0')); |
|
290 | 290 | if ($validAmount) { |
291 | 291 | return true; |
292 | 292 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | global $product; |
306 | 306 | if (method_exists($product, 'get_price')) { |
307 | 307 | $productPrice = $product->get_price(); |
308 | - $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0')); |
|
308 | + $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0')); |
|
309 | 309 | if ($validAmount) { |
310 | 310 | return true; |
311 | 311 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | function getExtraConfig() |
325 | 325 | { |
326 | 326 | global $wpdb; |
327 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
327 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
328 | 328 | $response = array(); |
329 | 329 | $dbResult = $wpdb->get_results("select config, value from $tableName", ARRAY_A); |
330 | 330 | foreach ($dbResult as $value) { |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | function getModuleVersion() |
338 | 338 | { |
339 | 339 | |
340 | - $mainFile = plugin_dir_path(PG_WC_MAIN_FILE). '/WC_Pagantis.php'; |
|
340 | + $mainFile = plugin_dir_path(PG_WC_MAIN_FILE).'/WC_Pagantis.php'; |
|
341 | 341 | $version = get_file_data($mainFile, array('Version' => 'Version'), false); |
342 | 342 | return $version; |
343 | 343 | } |
@@ -350,9 +350,9 @@ discard block |
||
350 | 350 | */ |
351 | 351 | function getNationalId($order) |
352 | 352 | { |
353 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
353 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
354 | 354 | $data = $mdObject->get_data(); |
355 | - if ($data['key'] == 'vat_number') { |
|
355 | + if ($data['key']=='vat_number') { |
|
356 | 356 | return $data['value']; |
357 | 357 | } |
358 | 358 | } |
@@ -367,9 +367,9 @@ discard block |
||
367 | 367 | */ |
368 | 368 | function getTaxId($order) |
369 | 369 | { |
370 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
370 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
371 | 371 | $data = $mdObject->get_data(); |
372 | - if ($data['key'] == 'billing_cfpiva') { |
|
372 | + if ($data['key']=='billing_cfpiva') { |
|
373 | 373 | return $data['value']; |
374 | 374 | } |
375 | 375 | } |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | $metaProduct = get_post_meta($product_id); |
387 | 387 | |
388 | 388 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) |
389 | - && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
389 | + && $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | $promotedAmount = 0; |
398 | 398 | foreach (WC()->cart->get_cart() as $key => $item) { |
399 | 399 | $promotedProduct = isProductPromoted($item['product_id']); |
400 | - if ($promotedProduct == 'true') { |
|
400 | + if ($promotedProduct=='true') { |
|
401 | 401 | $promotedAmount += $item['line_total'] + $item['line_tax']; |
402 | 402 | } |
403 | 403 | } |
@@ -415,12 +415,12 @@ discard block |
||
415 | 415 | { |
416 | 416 | global $wpdb; |
417 | 417 | checkCartProcessTable(); |
418 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
418 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
419 | 419 | |
420 | 420 | //Check if id exists |
421 | 421 | $resultsSelect = $wpdb->get_results("SELECT * FROM $tableName WHERE id='$orderId'"); |
422 | 422 | $countResults = count($resultsSelect); |
423 | - if ($countResults == 0) { |
|
423 | + if ($countResults==0) { |
|
424 | 424 | $wpdb->insert($tableName, array('id' => $orderId, 'order_id' => $pagantisOrderId), array('%d', '%s')); |
425 | 425 | } else { |
426 | 426 | $wpdb->update($tableName, array('order_id' => $pagantisOrderId), array('id' => $orderId), array('%s'), array('%d')); |
@@ -433,14 +433,14 @@ discard block |
||
433 | 433 | function checkCartProcessTable() |
434 | 434 | { |
435 | 435 | global $wpdb; |
436 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
436 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
437 | 437 | |
438 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
438 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
439 | 439 | $charset_collate = $wpdb->get_charset_collate(); |
440 | 440 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
441 | 441 | UNIQUE KEY id (id)) $charset_collate"; |
442 | 442 | |
443 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
443 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
444 | 444 | dbDelta($sql); |
445 | 445 | } |
446 | 446 | } |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
484 | 484 | )); |
485 | 485 | foreach ($customer_orders as $customer_order) { |
486 | - if (trim($sign_up) == '' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) { |
|
486 | + if (trim($sign_up)=='' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) { |
|
487 | 487 | $sign_up = substr($customer_order->post_date, 0, 10); |
488 | 488 | } |
489 | 489 | } |
@@ -494,5 +494,5 @@ discard block |
||
494 | 494 | |
495 | 495 | function isPagePaymentPage() |
496 | 496 | { |
497 | - return (is_checkout() && ! is_order_received_page()) || is_checkout_pay_page(); |
|
497 | + return (is_checkout() && !is_order_received_page()) || is_checkout_pay_page(); |
|
498 | 498 | } |