@@ -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); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | try { |
| 69 | 69 | require_once(__ROOT__.'/vendor/autoload.php'); |
| 70 | 70 | try { |
| 71 | - if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_GET['origin'] == 'notification') { |
|
| 71 | + if ($_SERVER['REQUEST_METHOD']=='GET' && $_GET['origin']=='notification') { |
|
| 72 | 72 | return $this->buildResponse(); |
| 73 | 73 | } |
| 74 | 74 | $this->checkConcurrency(); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | private function checkConcurrency() |
| 118 | 118 | { |
| 119 | 119 | $this->woocommerceOrderId = $_GET['order-received']; |
| 120 | - if ($this->woocommerceOrderId == '') { |
|
| 120 | + if ($this->woocommerceOrderId=='') { |
|
| 121 | 121 | throw new QuoteNotFoundException(); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | private function getProductType() |
| 132 | 132 | { |
| 133 | - if ($_GET['product'] == '') { |
|
| 133 | + if ($_GET['product']=='') { |
|
| 134 | 134 | $this->setProduct(WcPagantisGateway::METHOD_ID); |
| 135 | 135 | } else { |
| 136 | 136 | $this->setProduct($_GET['product']); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $queryResult = $wpdb->get_row("select order_id from $tableName where id='".WC()->cart->get_cart_hash()."'"); |
| 162 | 162 | $this->pagantisOrderId = $queryResult->order_id; |
| 163 | 163 | |
| 164 | - if ($this->pagantisOrderId == '') { |
|
| 164 | + if ($this->pagantisOrderId=='') { |
|
| 165 | 165 | throw new NoIdentificationException(); |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | $status = '-'; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if ($status === Order::STATUS_CONFIRMED) { |
|
| 207 | + if ($status===Order::STATUS_CONFIRMED) { |
|
| 208 | 208 | return true; |
| 209 | 209 | } |
| 210 | 210 | throw new WrongStatusException($status); |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | ); |
| 226 | 226 | |
| 227 | 227 | if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM |
| 228 | - $logMessage = "WARNING checkMerchantOrderStatus." . |
|
| 228 | + $logMessage = "WARNING checkMerchantOrderStatus.". |
|
| 229 | 229 | " Merchant order id:".$this->woocommerceOrder->get_id(). |
| 230 | 230 | " Merchant order status:".$this->woocommerceOrder->get_status(). |
| 231 | 231 | " Pagantis order id:".$this->pagantisOrder->getStatus(). |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | { |
| 248 | 248 | $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
| 249 | 249 | $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total())); |
| 250 | - if ($pagantisAmount != $wcAmount) { |
|
| 250 | + if ($pagantisAmount!=$wcAmount) { |
|
| 251 | 251 | throw new AmountMismatchException($pagantisAmount, $wcAmount); |
| 252 | 252 | } |
| 253 | 253 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId); |
| 272 | 272 | } catch (\Exception $e) { |
| 273 | 273 | $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId); |
| 274 | - if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) { |
|
| 274 | + if ($this->pagantisOrder->getStatus()!==Order::STATUS_CONFIRMED) { |
|
| 275 | 275 | throw new UnknownException($e->getMessage()); |
| 276 | 276 | } else { |
| 277 | 277 | $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process'; |
@@ -292,9 +292,9 @@ discard block |
||
| 292 | 292 | */ |
| 293 | 293 | private function checkDbTable() |
| 294 | 294 | { |
| 295 | - if (isPgTableCreated(PG_CART_PROCESS_TABLE)){ |
|
| 295 | + if (isPgTableCreated(PG_CART_PROCESS_TABLE)) { |
|
| 296 | 296 | alterCartProcessingTable(); |
| 297 | - } else{ |
|
| 297 | + } else { |
|
| 298 | 298 | createCartProcessingTable(); |
| 299 | 299 | } |
| 300 | 300 | } |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | global $wpdb; |
| 308 | 308 | $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
| 309 | 309 | |
| 310 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
| 310 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
| 311 | 311 | $charset_collate = $wpdb->get_charset_collate(); |
| 312 | 312 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
| 313 | 313 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -364,12 +364,12 @@ discard block |
||
| 364 | 364 | $metadataOrder = $this->pagantisOrder->getMetadata(); |
| 365 | 365 | $metadataInfo = null; |
| 366 | 366 | foreach ($metadataOrder as $metadataKey => $metadataValue) { |
| 367 | - if ($metadataKey == 'promotedProduct') { |
|
| 368 | - $metadataInfo.= "/Producto promocionado = $metadataValue"; |
|
| 367 | + if ($metadataKey=='promotedProduct') { |
|
| 368 | + $metadataInfo .= "/Producto promocionado = $metadataValue"; |
|
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - if ($metadataInfo != null) { |
|
| 372 | + if ($metadataInfo!=null) { |
|
| 373 | 373 | $this->woocommerceOrder->add_order_note($metadataInfo); |
| 374 | 374 | } |
| 375 | 375 | |
@@ -438,13 +438,13 @@ discard block |
||
| 438 | 438 | { |
| 439 | 439 | global $wpdb; |
| 440 | 440 | $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME; |
| 441 | - if ($orderId == null) { |
|
| 441 | + if ($orderId==null) { |
|
| 442 | 442 | $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT." SECOND)"; |
| 443 | 443 | } else { |
| 444 | 444 | $query = "DELETE FROM $tableName WHERE order_id = $orderId"; |
| 445 | 445 | } |
| 446 | 446 | $resultDelete = $wpdb->query($query); |
| 447 | - if ($resultDelete === false) { |
|
| 447 | + if ($resultDelete===false) { |
|
| 448 | 448 | throw new ConcurrencyException(); |
| 449 | 449 | } |
| 450 | 450 | } |
@@ -459,8 +459,8 @@ discard block |
||
| 459 | 459 | global $wpdb; |
| 460 | 460 | $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME; |
| 461 | 461 | $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId)); |
| 462 | - if ($insertResult === false) { |
|
| 463 | - if ($this->getOrigin() == 'Notify') { |
|
| 462 | + if ($insertResult===false) { |
|
| 463 | + if ($this->getOrigin()=='Notify') { |
|
| 464 | 464 | throw new ConcurrencyException(); |
| 465 | 465 | } else { |
| 466 | 466 | $query = sprintf( |
@@ -471,8 +471,8 @@ discard block |
||
| 471 | 471 | ); |
| 472 | 472 | $resultSeconds = $wpdb->get_row($query); |
| 473 | 473 | $restSeconds = isset($resultSeconds) ? ($resultSeconds->rest) : 0; |
| 474 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
| 475 | - sleep($secondsToExpire+1); |
|
| 474 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
| 475 | + sleep($secondsToExpire + 1); |
|
| 476 | 476 | |
| 477 | 477 | $logMessage = sprintf( |
| 478 | 478 | "User waiting %s seconds, default seconds %s, bd time to expire %s seconds", |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | { |
| 497 | 497 | $this->unblockConcurrency($this->woocommerceOrderId); |
| 498 | 498 | |
| 499 | - if ($exception == null) { |
|
| 499 | + if ($exception==null) { |
|
| 500 | 500 | $jsonResponse = new JsonSuccessResponse(); |
| 501 | 501 | } else { |
| 502 | 502 | $jsonResponse = new JsonExceptionResponse(); |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | $jsonResponse->setMerchantOrderId($this->woocommerceOrderId); |
| 507 | 507 | $jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
| 508 | 508 | |
| 509 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 509 | + if ($_SERVER['REQUEST_METHOD']=='POST') { |
|
| 510 | 510 | $jsonResponse->printResponse(); |
| 511 | 511 | } else { |
| 512 | 512 | return $jsonResponse; |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | */ |
| 539 | 539 | private function isProduct4x() |
| 540 | 540 | { |
| 541 | - return ($this->product === Ucfirst(WcPagantis4xGateway::METHOD_ID)); |
|
| 541 | + return ($this->product===Ucfirst(WcPagantis4xGateway::METHOD_ID)); |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | /** |
@@ -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(); |
@@ -98,15 +98,15 @@ discard block |
||
| 98 | 98 | add_action('init', array($this, 'checkWcPriceSettings'), 10); |
| 99 | 99 | add_action('woocommerce_after_template_part', array($this, 'pagantisAddSimulatorHtmlDiv'), 10); |
| 100 | 100 | add_action('woocommerce_single_product_summary', array($this, 'pagantisInitProductSimulator'), 20); |
| 101 | - add_action('woocommerce_single_variation', array($this,'pagantisAddProductSnippetForVariations'), 30); |
|
| 101 | + add_action('woocommerce_single_variation', array($this, 'pagantisAddProductSnippetForVariations'), 30); |
|
| 102 | 102 | add_action('wp_enqueue_scripts', 'add_pagantis_widget_js'); |
| 103 | 103 | add_action('rest_api_init', array($this, 'pagantisRegisterEndpoint')); //Endpoint |
| 104 | 104 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
| 105 | 105 | register_activation_hook(__FILE__, array($this, 'pagantisActivation')); |
| 106 | 106 | add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl')); |
| 107 | 107 | add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave')); |
| 108 | - add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate')); |
|
| 109 | - add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave')); |
|
| 108 | + add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate')); |
|
| 109 | + add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave')); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | { |
| 133 | 133 | $post_id = $product->get_id(); |
| 134 | 134 | $pagantis_promoted_value = $_REQUEST['pagantis_promoted']; |
| 135 | - if ($pagantis_promoted_value === 'on') { |
|
| 135 | + if ($pagantis_promoted_value==='on') { |
|
| 136 | 136 | $pagantis_promoted_value = 'yes'; |
| 137 | 137 | } else { |
| 138 | 138 | $pagantis_promoted_value = 'no'; |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | public function pagantisPromotedVarSave($post_id) |
| 167 | 167 | { |
| 168 | 168 | $pagantis_promoted_value = $_POST['pagantis_promoted']; |
| 169 | - if ($pagantis_promoted_value !== 'yes') { |
|
| 169 | + if ($pagantis_promoted_value!=='yes') { |
|
| 170 | 170 | $pagantis_promoted_value = 'no'; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -180,8 +180,8 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function loadPagantisTranslation($mofile, $domain) |
| 182 | 182 | { |
| 183 | - if ('pagantis' === $domain) { |
|
| 184 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 183 | + if ('pagantis'===$domain) { |
|
| 184 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 185 | 185 | } |
| 186 | 186 | return $mofile; |
| 187 | 187 | } |
@@ -193,14 +193,14 @@ discard block |
||
| 193 | 193 | public function pagantisCheckTables() |
| 194 | 194 | { |
| 195 | 195 | // Creating new cart processing table < 8.6.13 |
| 196 | - if (isPgTableCreated(PG_CART_PROCESS_TABLE)){ |
|
| 196 | + if (isPgTableCreated(PG_CART_PROCESS_TABLE)) { |
|
| 197 | 197 | alterCartProcessingTable(); |
| 198 | - } else{ |
|
| 198 | + } else { |
|
| 199 | 199 | createCartProcessingTable(); |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | // Making sure DB tables are created < v8.6.9 |
| 203 | - if (!isPgTableCreated(PG_LOGS_TABLE_NAME)){ |
|
| 203 | + if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) { |
|
| 204 | 204 | createLogsTable(); |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | global $wpdb; |
| 214 | 214 | |
| 215 | 215 | $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME; |
| 216 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
| 216 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
| 217 | 217 | $charset_collate = $wpdb->get_charset_collate(); |
| 218 | 218 | $sql = "CREATE TABLE $tableName ( order_id int NOT NULL, |
| 219 | 219 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate"; |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 225 | 225 | |
| 226 | 226 | //Check if table exists |
| 227 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; |
|
| 227 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; |
|
| 228 | 228 | if ($tableExists) { |
| 229 | 229 | $charset_collate = $wpdb->get_charset_collate(); |
| 230 | 230 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | //Updated value field to adapt to new length < v8.0.1 |
| 240 | 240 | $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'"; |
| 241 | 241 | $results = $wpdb->get_results($query, ARRAY_A); |
| 242 | - if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') { |
|
| 242 | + if ($results['0']['COLUMN_TYPE']=='varchar(100)') { |
|
| 243 | 243 | $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)"; |
| 244 | 244 | $wpdb->query($sql); |
| 245 | 245 | } |
@@ -249,9 +249,9 @@ discard block |
||
| 249 | 249 | or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
| 250 | 250 | $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A); |
| 251 | 251 | foreach ($dbCurrentConfig as $item) { |
| 252 | - if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
| 252 | + if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
| 253 | 253 | $css_price_selector = $this->preparePriceSelector($item['value']); |
| 254 | - if ($item['value'] != $css_price_selector) { |
|
| 254 | + if ($item['value']!=$css_price_selector) { |
|
| 255 | 255 | $wpdb->update( |
| 256 | 256 | $tableName, |
| 257 | 257 | array('value' => stripslashes($css_price_selector)), |
@@ -260,9 +260,9 @@ discard block |
||
| 260 | 260 | array('%s') |
| 261 | 261 | ); |
| 262 | 262 | } |
| 263 | - } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
| 263 | + } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
| 264 | 264 | $css_quantity_selector = $this->prepareQuantitySelector($item['value']); |
| 265 | - if ($item['value'] != $css_quantity_selector) { |
|
| 265 | + if ($item['value']!=$css_quantity_selector) { |
|
| 266 | 266 | $wpdb->update( |
| 267 | 267 | $tableName, |
| 268 | 268 | array('value' => stripslashes($css_quantity_selector)), |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 281 | 281 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
| 282 | 282 | $results = $wpdb->get_results($query, ARRAY_A); |
| 283 | - if (count($results) == 0) { |
|
| 283 | + if (count($results)==0) { |
|
| 284 | 284 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value' => '.'), array('%s', '%s')); |
| 285 | 285 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value' => ','), array('%s', '%s')); |
| 286 | 286 | } |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 290 | 290 | $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'"; |
| 291 | 291 | $results = $wpdb->get_results($query, ARRAY_A); |
| 292 | - if (count($results) == 0) { |
|
| 292 | + if (count($results)==0) { |
|
| 293 | 293 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value' => '0'), array('%s', '%s')); |
| 294 | 294 | } |
| 295 | 295 | |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 298 | 298 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'"; |
| 299 | 299 | $results = $wpdb->get_results($query, ARRAY_A); |
| 300 | - if (count($results) == 0) { |
|
| 300 | + if (count($results)==0) { |
|
| 301 | 301 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value' => 'default'), array('%s', '%s')); |
| 302 | 302 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value' => 'default'), array('%s', '%s')); |
| 303 | 303 | } |
@@ -307,17 +307,17 @@ discard block |
||
| 307 | 307 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 308 | 308 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'"; |
| 309 | 309 | $results = $wpdb->get_results($query, ARRAY_A); |
| 310 | - if (count($results) == 0) { |
|
| 310 | + if (count($results)==0) { |
|
| 311 | 311 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', 'value' => 'sdk.simulator.types.CHECKOUT_PAGE'), array('%s', '%s')); |
| 312 | 312 | $wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), array('%s'), array('%s')); |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | //Adapting to variable selector < v8.3.6 |
| 316 | - $variableSelector="div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
| 316 | + $variableSelector = "div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
| 317 | 317 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 318 | 318 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'"; |
| 319 | 319 | $results = $wpdb->get_results($query, ARRAY_A); |
| 320 | - if (count($results) == 0) { |
|
| 320 | + if (count($results)==0) { |
|
| 321 | 321 | $wpdb->update($tableName, array('value' => $variableSelector), array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION'), array('%s'), array('%s')); |
| 322 | 322 | } |
| 323 | 323 | |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 326 | 326 | $query = "select * from $tableName where config='PAGANTIS_TITLE_4x'"; |
| 327 | 327 | $results = $wpdb->get_results($query, ARRAY_A); |
| 328 | - if (count($results) == 0) { |
|
| 328 | + if (count($results)==0) { |
|
| 329 | 329 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_TITLE_4x', 'value' => 'Until 4 installments, without fees'), array('%s', '%s')); |
| 330 | 330 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MIN_AMOUNT_4x', 'value' => 1), array('%s', '%s')); |
| 331 | 331 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT_4x', 'value' => 800), array('%s', '%s')); |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 339 | 339 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X'"; |
| 340 | 340 | $results = $wpdb->get_results($query, ARRAY_A); |
| 341 | - if (count($results) == 0) { |
|
| 341 | + if (count($results)==0) { |
|
| 342 | 342 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X', 'value' => 'default'), array('%s', '%s')); |
| 343 | 343 | } |
| 344 | 344 | |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 355 | 355 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
| 356 | 356 | $results = $wpdb->get_results($query, ARRAY_A); |
| 357 | - if (count($results) == 0) { |
|
| 357 | + if (count($results)==0) { |
|
| 358 | 358 | $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')); |
| 359 | 359 | } |
| 360 | 360 | |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | $isAtcTplPresent = isTemplatePresent( |
| 448 | 448 | $template_name, |
| 449 | 449 | array('single-product/add-to-cart/variation-add-to-cart-button.php', |
| 450 | - 'single-product/add-to-cart/variation.php','single-product/add-to-cart/simple.php') |
|
| 450 | + 'single-product/add-to-cart/variation.php', 'single-product/add-to-cart/simple.php') |
|
| 451 | 451 | ); |
| 452 | 452 | |
| 453 | 453 | $html = apply_filters('pagantis_simulator_selector_html', '<div class="mainPagantisSimulator"></div><div class="pagantisSimulator"></div>'); |
@@ -459,10 +459,10 @@ discard block |
||
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | $pagantisSimulator4x = 'enabled'; |
| 462 | - if (!isPluginEnabled4x() || !areMerchantKeysSet4x() || !isCountryShopContextValid() || !isProductAmountValid4x()) { |
|
| 462 | + if (!isPluginEnabled4x() || !areMerchantKeysSet4x() || !isCountryShopContextValid() || !isProductAmountValid4x()) { |
|
| 463 | 463 | $pagantisSimulator4x = 'disabled'; |
| 464 | 464 | } |
| 465 | - if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') { |
|
| 465 | + if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') { |
|
| 466 | 466 | return; |
| 467 | 467 | } |
| 468 | 468 | |
@@ -518,12 +518,12 @@ discard block |
||
| 518 | 518 | $pagantisSimulator4x = 'disabled'; |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | - if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') { |
|
| 521 | + if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') { |
|
| 522 | 522 | return; |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | $totalPrice = $product->get_price(); |
| 526 | - $formattedInstallments = number_format($totalPrice/4, 2); |
|
| 526 | + $formattedInstallments = number_format($totalPrice / 4, 2); |
|
| 527 | 527 | $simulatorMessage = sprintf(__('or 4 installments of %s€, without fees, with ', 'pagantis'), $formattedInstallments); |
| 528 | 528 | $post_id = $product->get_id(); |
| 529 | 529 | $logo = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | */ |
| 567 | 567 | public function addPagantisGateway($methods) |
| 568 | 568 | { |
| 569 | - if (! class_exists('WC_Payment_Gateway')) { |
|
| 569 | + if (!class_exists('WC_Payment_Gateway')) { |
|
| 570 | 570 | return $methods; |
| 571 | 571 | } |
| 572 | 572 | |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | */ |
| 632 | 632 | public function pagantisRowMeta($links, $file) |
| 633 | 633 | { |
| 634 | - if ($file == plugin_basename(__FILE__)) { |
|
| 634 | + if ($file==plugin_basename(__FILE__)) { |
|
| 635 | 635 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
| 636 | 636 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
| 637 | 637 | __('API documentation', 'pagantis').'</a>'; |
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
| 661 | 661 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
| 662 | 662 | $results = $wpdb->get_results($query); |
| 663 | - if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) { |
|
| 663 | + if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) { |
|
| 664 | 664 | foreach ($results as $key => $result) { |
| 665 | 665 | $response[$key]['timestamp'] = $result->createdAt; |
| 666 | 666 | $response[$key]['log'] = json_decode($result->log); |
@@ -687,13 +687,13 @@ discard block |
||
| 687 | 687 | |
| 688 | 688 | $filters = ($data->get_params()); |
| 689 | 689 | $secretKey = $filters['secret']; |
| 690 | - $cfg = get_option('woocommerce_pagantis_settings'); |
|
| 690 | + $cfg = get_option('woocommerce_pagantis_settings'); |
|
| 691 | 691 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
| 692 | 692 | $privateKey4x = isset($cfg['pagantis_private_key_4x']) ? $cfg['pagantis_private_key_4x'] : null; |
| 693 | - if ($privateKey != $secretKey && $privateKey4x != $secretKey) { |
|
| 693 | + if ($privateKey!=$secretKey && $privateKey4x!=$secretKey) { |
|
| 694 | 694 | $response['status'] = 401; |
| 695 | 695 | $response['result'] = 'Unauthorized'; |
| 696 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 696 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
| 697 | 697 | if (count($_POST)) { |
| 698 | 698 | foreach ($_POST as $config => $value) { |
| 699 | 699 | if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |
@@ -754,7 +754,7 @@ discard block |
||
| 754 | 754 | and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc"; |
| 755 | 755 | $results = $wpdb->get_results($query); |
| 756 | 756 | |
| 757 | - if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) { |
|
| 757 | + if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) { |
|
| 758 | 758 | foreach ($results as $result) { |
| 759 | 759 | $key = $result->ID; |
| 760 | 760 | $response['message'][$key]['timestamp'] = $result->post_date; |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | */ |
| 828 | 828 | private function prepareQuantitySelector($css_quantity_selector) |
| 829 | 829 | { |
| 830 | - if ($css_quantity_selector == 'default' || $css_quantity_selector == '') { |
|
| 830 | + if ($css_quantity_selector=='default' || $css_quantity_selector=='') { |
|
| 831 | 831 | $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
| 832 | 832 | } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
| 833 | 833 | $css_quantity_selector = serialize(array($css_quantity_selector)); |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | */ |
| 844 | 844 | private function preparePriceSelector($css_price_selector) |
| 845 | 845 | { |
| 846 | - if ($css_price_selector == 'default' || $css_price_selector == '') { |
|
| 846 | + if ($css_price_selector=='default' || $css_price_selector=='') { |
|
| 847 | 847 | $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
| 848 | 848 | } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
| 849 | 849 | $css_price_selector = serialize(array($css_price_selector)); |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | { |
| 862 | 862 | $metaProduct = get_post_meta($product_id); |
| 863 | 863 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && |
| 864 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
| 864 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | /** |
@@ -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,7 +60,7 @@ 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 | 65 | $this->language = strstr(get_locale(), '_', true); |
| 66 | 66 | if ($this->language=='') { |
@@ -69,24 +69,24 @@ discard block |
||
| 69 | 69 | $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
| 70 | 70 | |
| 71 | 71 | //Panel form fields |
| 72 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options |
|
| 72 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options |
|
| 73 | 73 | $this->init_settings(); |
| 74 | 74 | |
| 75 | 75 | $this->extraConfig = getExtraConfig(); |
| 76 | 76 | $this->title = __($this->extraConfig['PAGANTIS_TITLE_4x'], 'pagantis'); |
| 77 | 77 | $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis."; |
| 78 | 78 | |
| 79 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl(); |
|
| 80 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl(); |
|
| 79 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
| 80 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
| 81 | 81 | foreach ($this->settings as $setting_key => $setting_value) { |
| 82 | 82 | $this->$setting_key = $setting_value; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | //Hooks |
| 86 | - add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options |
|
| 87 | - add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
| 88 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
| 89 | - add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3); |
|
| 86 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options |
|
| 87 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
| 88 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
| 89 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3); |
|
| 90 | 90 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public function loadPagantisTranslation($mofile, $domain) |
| 100 | 100 | { |
| 101 | - if ('pagantis' === $domain) { |
|
| 102 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 101 | + if ('pagantis'===$domain) { |
|
| 102 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 103 | 103 | } |
| 104 | 104 | return $mofile; |
| 105 | 105 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | $shippingAddress = $order->get_address('shipping'); |
| 150 | 150 | $billingAddress = $order->get_address('billing'); |
| 151 | - if ($shippingAddress['address_1'] == '') { |
|
| 151 | + if ($shippingAddress['address_1']=='') { |
|
| 152 | 152 | $shippingAddress = $billingAddress; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | ->setNationalId($national_id) |
| 176 | 176 | ->setTaxId($tax_id) |
| 177 | 177 | ; |
| 178 | - $orderBillingAddress = new Address(); |
|
| 178 | + $orderBillingAddress = new Address(); |
|
| 179 | 179 | $orderBillingAddress |
| 180 | 180 | ->setZipCode($billingAddress['postcode']) |
| 181 | 181 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
@@ -248,12 +248,12 @@ discard block |
||
| 248 | 248 | $details->addProduct($product); |
| 249 | 249 | |
| 250 | 250 | $promotedProduct = isProductPromoted($item->get_product_id()); |
| 251 | - if ($promotedProduct == 'true') { |
|
| 252 | - $promotedAmount+=$product->getAmount(); |
|
| 253 | - $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
|
| 254 | - ' - Price: ' . $item->get_total() . |
|
| 255 | - ' - Qty: ' . $product->getQuantity() . |
|
| 256 | - ' - Item ID: ' . $item['id_product']; |
|
| 251 | + if ($promotedProduct=='true') { |
|
| 252 | + $promotedAmount += $product->getAmount(); |
|
| 253 | + $promotedMessage = 'Promoted Item: '.$wcProduct->get_name(). |
|
| 254 | + ' - Price: '.$item->get_total(). |
|
| 255 | + ' - Qty: '.$product->getQuantity(). |
|
| 256 | + ' - Item ID: '.$item['id_product']; |
|
| 257 | 257 | $promotedMessage = substr($promotedMessage, 0, 999); |
| 258 | 258 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
| 259 | 259 | } |
@@ -299,9 +299,7 @@ discard block |
||
| 299 | 299 | |
| 300 | 300 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
| 301 | 301 | $purchaseCountry = |
| 302 | - in_array(strtolower($this->language), $allowedCountries) ? $this->language : |
|
| 303 | - in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : |
|
| 304 | - in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null; |
|
| 302 | + 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; |
|
| 305 | 303 | |
| 306 | 304 | $orderConfiguration = new Configuration(); |
| 307 | 305 | $orderConfiguration |
@@ -345,7 +343,7 @@ discard block |
||
| 345 | 343 | wc_get_template('iframe.php', $template_fields, '', $this->template_path); |
| 346 | 344 | } |
| 347 | 345 | } catch (\Exception $exception) { |
| 348 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); |
|
| 346 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); |
|
| 349 | 347 | insertLogEntry($exception); |
| 350 | 348 | $checkout_url = get_permalink(wc_get_page_id('checkout')); |
| 351 | 349 | wp_redirect($checkout_url); |
@@ -361,7 +359,7 @@ discard block |
||
| 361 | 359 | public function pagantisNotification() |
| 362 | 360 | { |
| 363 | 361 | try { |
| 364 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
| 362 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
| 365 | 363 | |
| 366 | 364 | include_once('notifyController.php'); |
| 367 | 365 | $notify = new WcPagantisNotify(); |
@@ -400,10 +398,10 @@ discard block |
||
| 400 | 398 | */ |
| 401 | 399 | public function pagantisCompleteStatus($status, $order_id, $order) |
| 402 | 400 | { |
| 403 | - if ($order->get_payment_method() == WcPagantis4xGateway::METHOD_ID) { |
|
| 404 | - if ($order->get_status() == 'failed') { |
|
| 401 | + if ($order->get_payment_method()==WcPagantis4xGateway::METHOD_ID) { |
|
| 402 | + if ($order->get_status()=='failed') { |
|
| 405 | 403 | $status = 'processing'; |
| 406 | - } elseif ($order->get_status() == 'pending' && $status=='completed') { |
|
| 404 | + } elseif ($order->get_status()=='pending' && $status=='completed') { |
|
| 407 | 405 | $status = 'processing'; |
| 408 | 406 | } |
| 409 | 407 | } |
@@ -432,8 +430,8 @@ discard block |
||
| 432 | 430 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
| 433 | 431 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT_4x']; |
| 434 | 432 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT_4x']; |
| 435 | - $totalPrice = (int)$this->get_order_total(); |
|
| 436 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
| 433 | + $totalPrice = (int) $this->get_order_total(); |
|
| 434 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
| 437 | 435 | if ($cfg['enabled_4x']==='yes' && $cfg['pagantis_public_key_4x']!='' && $cfg['pagantis_private_key_4x']!='' && |
| 438 | 436 | $validAmount && $allowedCountry) { |
| 439 | 437 | return true; |
@@ -468,7 +466,7 @@ discard block |
||
| 468 | 466 | |
| 469 | 467 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
| 470 | 468 | if (strpos($redirectUrl, 'order-pay=')===false) { |
| 471 | - $redirectUrl.="&order-pay=".$order_id; |
|
| 469 | + $redirectUrl .= "&order-pay=".$order_id; |
|
| 472 | 470 | } |
| 473 | 471 | |
| 474 | 472 | return array( |
@@ -476,7 +474,7 @@ discard block |
||
| 476 | 474 | 'redirect' => $redirectUrl |
| 477 | 475 | ); |
| 478 | 476 | } catch (Exception $e) { |
| 479 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); |
|
| 477 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); |
|
| 480 | 478 | return array(); |
| 481 | 479 | } |
| 482 | 480 | } |
@@ -547,7 +545,7 @@ discard block |
||
| 547 | 545 | private function generateUrl($url) |
| 548 | 546 | { |
| 549 | 547 | $parsed_url = parse_url($url); |
| 550 | - if ($parsed_url !== false) { |
|
| 548 | + if ($parsed_url!==false) { |
|
| 551 | 549 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
| 552 | 550 | parse_str($parsed_url['query'], $arrayParams); |
| 553 | 551 | foreach ($arrayParams as $keyParam => $valueParam) { |
@@ -595,11 +593,10 @@ discard block |
||
| 595 | 593 | private function getKeysUrl($order, $url) |
| 596 | 594 | { |
| 597 | 595 | $defaultFields = (get_class($order)=='WC_Order') ? |
| 598 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : |
|
| 599 | - array(); |
|
| 596 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array(); |
|
| 600 | 597 | |
| 601 | 598 | $parsedUrl = parse_url($url); |
| 602 | - if ($parsedUrl !== false) { |
|
| 599 | + if ($parsedUrl!==false) { |
|
| 603 | 600 | //Replace parameters from url |
| 604 | 601 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
| 605 | 602 | |
@@ -644,7 +641,7 @@ discard block |
||
| 644 | 641 | foreach ($arrayParams as $keyParam => $valueParam) { |
| 645 | 642 | preg_match('#\{{.*?}\}#', $valueParam, $match); |
| 646 | 643 | if (count($match)) { |
| 647 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]); |
|
| 644 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]); |
|
| 648 | 645 | $arrayParams[$keyParam] = $defaultFields[$key]; |
| 649 | 646 | } |
| 650 | 647 | } |
@@ -659,12 +656,12 @@ discard block |
||
| 659 | 656 | */ |
| 660 | 657 | private function unparseUrl($parsed_url) |
| 661 | 658 | { |
| 662 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
| 659 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
| 663 | 660 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
| 664 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
| 665 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
| 666 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
| 661 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
| 662 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
| 663 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
| 667 | 664 | $path = $parsed_url['path']; |
| 668 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
| 665 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
| 669 | 666 | } |
| 670 | 667 | } |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | function requireWPPluginFunctions() |
| 6 | 6 | { |
| 7 | - if ( ! function_exists('is_plugin_active')) { |
|
| 8 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 7 | + if (!function_exists('is_plugin_active')) { |
|
| 8 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
| 9 | 9 | } |
| 10 | 10 | } |
| 11 | 11 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | function getConfigValue($configKey) |
| 24 | 24 | { |
| 25 | 25 | global $wpdb; |
| 26 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 26 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 27 | 27 | $value = $wpdb->get_var($wpdb->prepare("SELECT value FROM $tableName WHERE config= %s ", $configKey)); |
| 28 | 28 | |
| 29 | 29 | return $value; |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | function isPgTableCreated($tableToCheck) |
| 41 | 41 | { |
| 42 | 42 | global $wpdb; |
| 43 | - $tableName = $wpdb->prefix . $tableToCheck; |
|
| 44 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) { |
|
| 43 | + $tableName = $wpdb->prefix.$tableToCheck; |
|
| 44 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")==$tableName) { |
|
| 45 | 45 | return true; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -54,12 +54,12 @@ discard block |
||
| 54 | 54 | function createPgCartTable() |
| 55 | 55 | { |
| 56 | 56 | global $wpdb; |
| 57 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
| 57 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
| 58 | 58 | $charset_collate = $wpdb->get_charset_collate(); |
| 59 | 59 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
| 60 | 60 | UNIQUE KEY id (id)) $charset_collate"; |
| 61 | 61 | |
| 62 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 62 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 63 | 63 | dbDelta($sql); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | global $wpdb; |
| 69 | 69 | $charset_collate = $wpdb->get_charset_collate(); |
| 70 | - $LogsTableName = $wpdb->prefix . PG_LOGS_TABLE_NAME; |
|
| 70 | + $LogsTableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
|
| 71 | 71 | $sqlQuery = "CREATE TABLE $LogsTableName ( |
| 72 | 72 | id int NOT NULL AUTO_INCREMENT, |
| 73 | 73 | log text NOT NULL, |
| 74 | 74 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, |
| 75 | 75 | UNIQUE KEY id (id)) |
| 76 | 76 | $charset_collate"; |
| 77 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 77 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 78 | 78 | dbDelta($sqlQuery); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | function insertLogEntry($exception = null, $message = null) |
| 86 | 86 | { |
| 87 | 87 | global $wpdb; |
| 88 | - if ( ! isPgTableCreated(PG_LOGS_TABLE_NAME)) { |
|
| 88 | + if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) { |
|
| 89 | 89 | createLogsTable(); |
| 90 | 90 | } |
| 91 | 91 | $logEntry = new Pagantis\ModuleUtils\Model\Log\LogEntry(); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | } else { |
| 95 | 95 | $logEntry = $logEntry->info($message); |
| 96 | 96 | } |
| 97 | - $tableName = $wpdb->prefix . PG_LOGS_TABLE_NAME; |
|
| 97 | + $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
|
| 98 | 98 | $wpdb->insert($tableName, array('log' => $logEntry->toJson())); |
| 99 | 99 | } |
| 100 | 100 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | { |
| 106 | 106 | $pgDecimalSeparator = getPgSimulatorDecimalSeparatorConfig(); |
| 107 | 107 | $wc_decimal_sep = get_option('woocommerce_price_decimal_sep'); |
| 108 | - if (stripslashes($wc_decimal_sep) == stripslashes($pgDecimalSeparator)) { |
|
| 108 | + if (stripslashes($wc_decimal_sep)==stripslashes($pgDecimalSeparator)) { |
|
| 109 | 109 | return true; |
| 110 | 110 | } else { |
| 111 | 111 | return false; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | $pgThousandSeparator = getPgSimulatorThousandsSeparator(); |
| 122 | 122 | $wc_price_thousand = get_option('woocommerce_price_thousand_sep'); |
| 123 | - if (stripslashes($wc_price_thousand) == stripslashes($pgThousandSeparator)) { |
|
| 123 | + if (stripslashes($wc_price_thousand)==stripslashes($pgThousandSeparator)) { |
|
| 124 | 124 | return true; |
| 125 | 125 | } else { |
| 126 | 126 | return false; |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | function getPgSimulatorThousandsSeparator() |
| 134 | 134 | { |
| 135 | 135 | global $wpdb; |
| 136 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 136 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 137 | 137 | $query = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
| 138 | 138 | $result = $wpdb->get_row($query, ARRAY_A); |
| 139 | 139 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | function getPgSimulatorDecimalSeparatorConfig() |
| 147 | 147 | { |
| 148 | 148 | global $wpdb; |
| 149 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 149 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 150 | 150 | $query = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'"; |
| 151 | 151 | $result = $wpdb->get_row($query, ARRAY_A); |
| 152 | 152 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | if (areThousandsSeparatorEqual()) { |
| 160 | 160 | return; |
| 161 | 161 | } |
| 162 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 162 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 163 | 163 | $thousandSeparator = get_option('woocommerce_price_thousand_sep'); |
| 164 | 164 | $wpdb->update($tableName, array('value' => $thousandSeparator), array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'), |
| 165 | 165 | array('%s'), array('%s')); |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | if (areDecimalSeparatorEqual()) { |
| 172 | 172 | return; |
| 173 | 173 | } |
| 174 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 174 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 175 | 175 | $decimalSeparator = get_option('woocommerce_price_decimal_sep'); |
| 176 | 176 | $wpdb->update($tableName, array('value' => $decimalSeparator), array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'), |
| 177 | 177 | array('%s'), array('%s')); |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | function isSimulatorTypeValid($simulatorType, $validSimulatorTypes) |
| 188 | 188 | { |
| 189 | - if ( ! in_array($simulatorType, $validSimulatorTypes)) { |
|
| 189 | + if (!in_array($simulatorType, $validSimulatorTypes)) { |
|
| 190 | 190 | return false; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | function areMerchantKeysSet() |
| 214 | 214 | { |
| 215 | 215 | $settings = get_option('woocommerce_pagantis_settings'); |
| 216 | - $publicKey = ! empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : ''; |
|
| 217 | - $privateKey = ! empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : ''; |
|
| 216 | + $publicKey = !empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : ''; |
|
| 217 | + $privateKey = !empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : ''; |
|
| 218 | 218 | if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) { |
| 219 | 219 | return false; |
| 220 | 220 | } |
@@ -225,8 +225,8 @@ discard block |
||
| 225 | 225 | function areMerchantKeysSet4x() |
| 226 | 226 | { |
| 227 | 227 | $settings = get_option('woocommerce_pagantis_settings'); |
| 228 | - $publicKey = ! empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : ''; |
|
| 229 | - $privateKey = ! empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : ''; |
|
| 228 | + $publicKey = !empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : ''; |
|
| 229 | + $privateKey = !empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : ''; |
|
| 230 | 230 | if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) { |
| 231 | 231 | return false; |
| 232 | 232 | } |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | function isSimulatorEnabled() |
| 238 | 238 | { |
| 239 | 239 | $settings = get_option('woocommerce_pagantis_settings'); |
| 240 | - if (( ! empty($settings['simulator']) && 'yes' === $settings['simulator']) ? true : false) { |
|
| 240 | + if ((!empty($settings['simulator']) && 'yes'===$settings['simulator']) ? true : false) { |
|
| 241 | 241 | return true; |
| 242 | 242 | } |
| 243 | 243 | |
@@ -248,14 +248,14 @@ discard block |
||
| 248 | 248 | { |
| 249 | 249 | $settings = get_option('woocommerce_pagantis_settings'); |
| 250 | 250 | |
| 251 | - return ( ! empty($settings['enabled']) && 'yes' === $settings['enabled']); |
|
| 251 | + return (!empty($settings['enabled']) && 'yes'===$settings['enabled']); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | function isPluginEnabled4x() |
| 255 | 255 | { |
| 256 | 256 | $settings = get_option('woocommerce_pagantis_settings'); |
| 257 | 257 | |
| 258 | - return ( ! empty($settings['enabled_4x']) && 'yes' === $settings['enabled_4x']); |
|
| 258 | + return (!empty($settings['enabled_4x']) && 'yes'===$settings['enabled_4x']); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | { |
| 264 | 264 | $locale = strtolower(strstr(get_locale(), '_', true)); |
| 265 | 265 | $allowedCountries = maybe_unserialize(getConfigValue('PAGANTIS_ALLOWED_COUNTRIES')); |
| 266 | - if ( ! in_array(strtolower($locale), $allowedCountries)) { |
|
| 266 | + if (!in_array(strtolower($locale), $allowedCountries)) { |
|
| 267 | 267 | return false; |
| 268 | 268 | } |
| 269 | 269 | |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | global $product; |
| 281 | 281 | if (method_exists($product, 'get_price')) { |
| 282 | 282 | $productPrice = $product->get_price(); |
| 283 | - $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0')); |
|
| 283 | + $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0')); |
|
| 284 | 284 | if ($validAmount) { |
| 285 | 285 | return true; |
| 286 | 286 | } |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | global $product; |
| 300 | 300 | if (method_exists($product, 'get_price')) { |
| 301 | 301 | $productPrice = $product->get_price(); |
| 302 | - $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0')); |
|
| 302 | + $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0')); |
|
| 303 | 303 | if ($validAmount) { |
| 304 | 304 | return true; |
| 305 | 305 | } |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | function getExtraConfig() |
| 320 | 320 | { |
| 321 | 321 | global $wpdb; |
| 322 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 322 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 323 | 323 | $response = array(); |
| 324 | 324 | $dbResult = $wpdb->get_results("select config, value from $tableName", ARRAY_A); |
| 325 | 325 | foreach ($dbResult as $value) { |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | |
| 332 | 332 | function getModuleVersion() |
| 333 | 333 | { |
| 334 | - $mainFile = plugin_dir_path(PG_WC_MAIN_FILE) . '/WC_Pagantis.php'; |
|
| 334 | + $mainFile = plugin_dir_path(PG_WC_MAIN_FILE).'/WC_Pagantis.php'; |
|
| 335 | 335 | $version = get_file_data($mainFile, array('Version' => 'Version'), false); |
| 336 | 336 | |
| 337 | 337 | return $version['Version']; |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | */ |
| 345 | 345 | function getNationalId($order) |
| 346 | 346 | { |
| 347 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
| 347 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
| 348 | 348 | $data = $mdObject->get_data(); |
| 349 | - if ($data['key'] == 'vat_number') { |
|
| 349 | + if ($data['key']=='vat_number') { |
|
| 350 | 350 | return $data['value']; |
| 351 | 351 | } |
| 352 | 352 | } |
@@ -361,9 +361,9 @@ discard block |
||
| 361 | 361 | */ |
| 362 | 362 | function getTaxId($order) |
| 363 | 363 | { |
| 364 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
| 364 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
| 365 | 365 | $data = $mdObject->get_data(); |
| 366 | - if ($data['key'] == 'billing_cfpiva') { |
|
| 366 | + if ($data['key']=='billing_cfpiva') { |
|
| 367 | 367 | return $data['value']; |
| 368 | 368 | } |
| 369 | 369 | } |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | $metaProduct = get_post_meta($product_id); |
| 381 | 381 | |
| 382 | 382 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) |
| 383 | - && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
| 383 | + && $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | $promotedAmount = 0; |
| 392 | 392 | foreach (WC()->cart->get_cart() as $key => $item) { |
| 393 | 393 | $promotedProduct = isProductPromoted($item['product_id']); |
| 394 | - if ($promotedProduct == 'true') { |
|
| 394 | + if ($promotedProduct=='true') { |
|
| 395 | 395 | $promotedAmount += $item['line_total'] + $item['line_tax']; |
| 396 | 396 | } |
| 397 | 397 | } |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | function addOrderToCartProcessingQueue($cartHash, $pagantisOrderId, $wcOrderID, $origin, $token) |
| 411 | 411 | { |
| 412 | 412 | global $wpdb; |
| 413 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
| 413 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
| 414 | 414 | $wpdb->insert($tableName, array( |
| 415 | 415 | 'id' => $cartHash, |
| 416 | 416 | 'order_id' => $pagantisOrderId, |
@@ -420,11 +420,11 @@ discard block |
||
| 420 | 420 | ), array('%d', '%s', '%s', '%s', '%s')); |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | -function alterCartProcessingTable(){ |
|
| 423 | +function alterCartProcessingTable() { |
|
| 424 | 424 | global $wpdb; |
| 425 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
| 426 | - $wpdb->query( "ALTER TABLE $tableName ADD COLUMN token VARCHAR(32) NOT NULL AFTER wc_order_id"); |
|
| 427 | - $wpdb->query( "ALTER TABLE $tableName DROP PRIMARY KEY, ADD PRIMARY KEY(`id`, `token`)" ); |
|
| 425 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
| 426 | + $wpdb->query("ALTER TABLE $tableName ADD COLUMN token VARCHAR(32) NOT NULL AFTER wc_order_id"); |
|
| 427 | + $wpdb->query("ALTER TABLE $tableName DROP PRIMARY KEY, ADD PRIMARY KEY(`id`, `token`)"); |
|
| 428 | 428 | wp_cache_flush(); |
| 429 | 429 | } |
| 430 | 430 | |
@@ -434,13 +434,13 @@ discard block |
||
| 434 | 434 | function createCartProcessingTable() |
| 435 | 435 | { |
| 436 | 436 | global $wpdb; |
| 437 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
| 437 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
| 438 | 438 | |
| 439 | - if ( ! isPgTableCreated(PG_CART_PROCESS_TABLE)) { |
|
| 439 | + if (!isPgTableCreated(PG_CART_PROCESS_TABLE)) { |
|
| 440 | 440 | $charset_collate = $wpdb->get_charset_collate(); |
| 441 | 441 | $sql = "CREATE TABLE $tableName id VARCHAR(60) NOT NULL, order_id VARCHAR(60) NOT NULL, wc_order_id VARCHAR(50) NOT NULL, token VARCHAR(32) NOT NULL PRIMARY KEY('id' , 'token')) $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 | } |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
| 483 | 483 | )); |
| 484 | 484 | foreach ($customer_orders as $customer_order) { |
| 485 | - if (trim($sign_up) == '' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) { |
|
| 485 | + if (trim($sign_up)=='' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) { |
|
| 486 | 486 | $sign_up = substr($customer_order->post_date, 0, 10); |
| 487 | 487 | } |
| 488 | 488 | } |
@@ -495,14 +495,14 @@ discard block |
||
| 495 | 495 | function updateCartProcessingTable() |
| 496 | 496 | { |
| 497 | 497 | global $wpdb; |
| 498 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
| 498 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
| 499 | 499 | |
| 500 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
| 500 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
| 501 | 501 | $charset_collate = $wpdb->get_charset_collate(); |
| 502 | 502 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), token varchar(32) |
| 503 | 503 | UNIQUE KEY id (id)) $charset_collate"; |
| 504 | 504 | |
| 505 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 505 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 506 | 506 | dbDelta($sql); |
| 507 | 507 | } |
| 508 | 508 | } |
@@ -514,5 +514,5 @@ discard block |
||
| 514 | 514 | |
| 515 | 515 | function isPagePaymentPage() |
| 516 | 516 | { |
| 517 | - return (is_checkout() && ! is_order_received_page()) || is_checkout_pay_page(); |
|
| 517 | + return (is_checkout() && !is_order_received_page()) || is_checkout_pay_page(); |
|
| 518 | 518 | } |