@@ -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 | } |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | $this->urlToken = strtoupper(md5(uniqid(rand(), true))); |
| 64 | 64 | |
| 65 | 65 | //Useful vars |
| 66 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/'; |
|
| 66 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/'; |
|
| 67 | 67 | $this->allowed_currencies = getAllowedCurrencies(); |
| 68 | - $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Pagantis.php'; |
|
| 68 | + $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)).'/WC_Pagantis.php'; |
|
| 69 | 69 | $this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false); |
| 70 | 70 | $this->language = strstr(get_locale(), '_', true); |
| 71 | 71 | if ($this->language=='') { |
@@ -74,25 +74,25 @@ discard block |
||
| 74 | 74 | $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
| 75 | 75 | |
| 76 | 76 | //Panel form fields |
| 77 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options |
|
| 77 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options |
|
| 78 | 78 | $this->init_settings(); |
| 79 | 79 | |
| 80 | 80 | $this->extraConfig = getExtraConfig(); |
| 81 | 81 | $this->title = __($this->extraConfig['PAGANTIS_TITLE'], 'pagantis'); |
| 82 | 82 | $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis."; |
| 83 | 83 | |
| 84 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl(); |
|
| 85 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl(); |
|
| 84 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
| 85 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
| 86 | 86 | foreach ($this->settings as $setting_key => $setting_value) { |
| 87 | 87 | $this->$setting_key = $setting_value; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | //Hooks |
| 91 | - add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options |
|
| 92 | - add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields |
|
| 93 | - add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
| 94 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
| 95 | - add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3); |
|
| 91 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options |
|
| 92 | + add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields |
|
| 93 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
| 94 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
| 95 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3); |
|
| 96 | 96 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function loadPagantisTranslation($mofile, $domain) |
| 106 | 106 | { |
| 107 | - if ('pagantis' === $domain) { |
|
| 108 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 107 | + if ('pagantis'===$domain) { |
|
| 108 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 109 | 109 | } |
| 110 | 110 | return $mofile; |
| 111 | 111 | } |
@@ -139,24 +139,24 @@ discard block |
||
| 139 | 139 | public function pagantisCheckFields() |
| 140 | 140 | { |
| 141 | 141 | $error_string = ''; |
| 142 | - if ($this->settings['enabled'] !== 'yes') { |
|
| 142 | + if ($this->settings['enabled']!=='yes') { |
|
| 143 | 143 | return; |
| 144 | 144 | } elseif (!version_compare(phpversion(), '5.3.0', '>=')) { |
| 145 | - $error_string = __(' is not compatible with your php and/or curl version', 'pagantis'); |
|
| 145 | + $error_string = __(' is not compatible with your php and/or curl version', 'pagantis'); |
|
| 146 | 146 | $this->settings['enabled'] = 'no'; |
| 147 | - } 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']))) { |
|
| 147 | + } 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']))) { |
|
| 148 | 148 | $error_string = __(' is not configured correctly, the fields Public Key and Secret Key are mandatory for use this plugin', 'pagantis'); |
| 149 | 149 | $this->settings['enabled'] = 'no'; |
| 150 | 150 | } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) { |
| 151 | - $error_string = __(' only can be used in Euros', 'pagantis'); |
|
| 151 | + $error_string = __(' only can be used in Euros', 'pagantis'); |
|
| 152 | 152 | $this->settings['enabled'] = 'no'; |
| 153 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']<'2' |
|
| 154 | - || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']>'12') { |
|
| 153 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] < '2' |
|
| 154 | + || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] > '12') { |
|
| 155 | 155 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis'); |
| 156 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']<'2' |
|
| 157 | - || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']>'12') { |
|
| 156 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] < '2' |
|
| 157 | + || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] > '12') { |
|
| 158 | 158 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis'); |
| 159 | - } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']<0) { |
|
| 159 | + } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] < 0) { |
|
| 160 | 160 | $error_string = __(' can not have a minimum amount less than 0', 'pagantis'); |
| 161 | 161 | } |
| 162 | 162 | |
@@ -189,14 +189,14 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | $shippingAddress = $order->get_address('shipping'); |
| 191 | 191 | $billingAddress = $order->get_address('billing'); |
| 192 | - if ($shippingAddress['address_1'] == '') { |
|
| 192 | + if ($shippingAddress['address_1']=='') { |
|
| 193 | 193 | $shippingAddress = $billingAddress; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | $customer_id = $order->get_customer_id(); |
| 197 | - $national_id = maybeGetIDNumber($order , $customer_id); |
|
| 198 | - $tax_id = maybeGetTaxIDNumber($order , $customer_id); |
|
| 199 | - $phoneNumber = maybeGetPhoneNumber($order , $customer_id); |
|
| 197 | + $national_id = maybeGetIDNumber($order, $customer_id); |
|
| 198 | + $tax_id = maybeGetTaxIDNumber($order, $customer_id); |
|
| 199 | + $phoneNumber = maybeGetPhoneNumber($order, $customer_id); |
|
| 200 | 200 | |
| 201 | 201 | $userAddress = new Address(); |
| 202 | 202 | $userAddress |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | ->setDni($national_id) |
| 221 | 221 | ->setTaxId($tax_id) |
| 222 | 222 | ; |
| 223 | - $orderBillingAddress = new Address(); |
|
| 223 | + $orderBillingAddress = new Address(); |
|
| 224 | 224 | $orderBillingAddress |
| 225 | 225 | ->setZipCode($billingAddress['postcode']) |
| 226 | 226 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
@@ -296,12 +296,12 @@ discard block |
||
| 296 | 296 | $details->addProduct($product); |
| 297 | 297 | |
| 298 | 298 | $promotedProduct = isProductPromoted($item->get_product_id()); |
| 299 | - if ($promotedProduct == 'true') { |
|
| 300 | - $promotedAmount+=$product->getAmount(); |
|
| 301 | - $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
|
| 302 | - ' - Price: ' . $item->get_total() . |
|
| 303 | - ' - Qty: ' . $product->getQuantity() . |
|
| 304 | - ' - Item ID: ' . $item['id_product']; |
|
| 299 | + if ($promotedProduct=='true') { |
|
| 300 | + $promotedAmount += $product->getAmount(); |
|
| 301 | + $promotedMessage = 'Promoted Item: '.$wcProduct->get_name(). |
|
| 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 | } |
@@ -348,9 +348,7 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
| 350 | 350 | $purchaseCountry = |
| 351 | - in_array(strtolower($this->language), $allowedCountries) ? $this->language : |
|
| 352 | - in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : |
|
| 353 | - in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null; |
|
| 351 | + 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; |
|
| 354 | 352 | |
| 355 | 353 | $orderConfiguration = new Configuration(); |
| 356 | 354 | $orderConfiguration |
@@ -392,7 +390,7 @@ discard block |
||
| 392 | 390 | wc_get_template('iframe.php', $template_fields, '', $this->template_path); |
| 393 | 391 | } |
| 394 | 392 | } catch (\Exception $exception) { |
| 395 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); |
|
| 393 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); |
|
| 396 | 394 | insertLogEntry($exception); |
| 397 | 395 | $checkout_url = get_permalink(wc_get_page_id('checkout')); |
| 398 | 396 | wp_redirect($checkout_url); |
@@ -407,7 +405,7 @@ discard block |
||
| 407 | 405 | public function pagantisNotification() |
| 408 | 406 | { |
| 409 | 407 | try { |
| 410 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
| 408 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
| 411 | 409 | |
| 412 | 410 | include_once('notifyController.php'); |
| 413 | 411 | $notify = new WcPagantisNotify(); |
@@ -446,10 +444,10 @@ discard block |
||
| 446 | 444 | */ |
| 447 | 445 | public function pagantisCompleteStatus($status, $order_id, $order) |
| 448 | 446 | { |
| 449 | - if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) { |
|
| 450 | - if ($order->get_status() == 'failed') { |
|
| 447 | + if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) { |
|
| 448 | + if ($order->get_status()=='failed') { |
|
| 451 | 449 | $status = 'processing'; |
| 452 | - } elseif ($order->get_status() == 'pending' && $status=='completed') { |
|
| 450 | + } elseif ($order->get_status()=='pending' && $status=='completed') { |
|
| 453 | 451 | $status = 'processing'; |
| 454 | 452 | } |
| 455 | 453 | } |
@@ -475,8 +473,8 @@ discard block |
||
| 475 | 473 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
| 476 | 474 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
| 477 | 475 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
| 478 | - $totalPrice = (int)$this->get_order_total(); |
|
| 479 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
| 476 | + $totalPrice = (int) $this->get_order_total(); |
|
| 477 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
| 480 | 478 | if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' && |
| 481 | 479 | $validAmount && $allowedCountry) { |
| 482 | 480 | return true; |
@@ -509,7 +507,7 @@ discard block |
||
| 509 | 507 | |
| 510 | 508 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
| 511 | 509 | if (strpos($redirectUrl, 'order-pay=')===false) { |
| 512 | - $redirectUrl.="&order-pay=".$order_id; |
|
| 510 | + $redirectUrl .= "&order-pay=".$order_id; |
|
| 513 | 511 | } |
| 514 | 512 | |
| 515 | 513 | return array( |
@@ -517,7 +515,7 @@ discard block |
||
| 517 | 515 | 'redirect' => $redirectUrl |
| 518 | 516 | ); |
| 519 | 517 | } catch (Exception $e) { |
| 520 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); |
|
| 518 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); |
|
| 521 | 519 | return array(); |
| 522 | 520 | } |
| 523 | 521 | } |
@@ -586,7 +584,7 @@ discard block |
||
| 586 | 584 | private function generateUrl($url) |
| 587 | 585 | { |
| 588 | 586 | $parsed_url = parse_url($url); |
| 589 | - if ($parsed_url !== false) { |
|
| 587 | + if ($parsed_url!==false) { |
|
| 590 | 588 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
| 591 | 589 | parse_str($parsed_url['query'], $arrayParams); |
| 592 | 590 | foreach ($arrayParams as $keyParam => $valueParam) { |
@@ -634,11 +632,10 @@ discard block |
||
| 634 | 632 | private function getKeysUrl($order, $url) |
| 635 | 633 | { |
| 636 | 634 | $defaultFields = (get_class($order)=='WC_Order') ? |
| 637 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : |
|
| 638 | - array(); |
|
| 635 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array(); |
|
| 639 | 636 | |
| 640 | 637 | $parsedUrl = parse_url($url); |
| 641 | - if ($parsedUrl !== false) { |
|
| 638 | + if ($parsedUrl!==false) { |
|
| 642 | 639 | //Replace parameters from url |
| 643 | 640 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
| 644 | 641 | |
@@ -683,7 +680,7 @@ discard block |
||
| 683 | 680 | foreach ($arrayParams as $keyParam => $valueParam) { |
| 684 | 681 | preg_match('#\{{.*?}\}#', $valueParam, $match); |
| 685 | 682 | if (count($match)) { |
| 686 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]); |
|
| 683 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]); |
|
| 687 | 684 | $arrayParams[$keyParam] = $defaultFields[$key]; |
| 688 | 685 | } |
| 689 | 686 | } |
@@ -698,13 +695,13 @@ discard block |
||
| 698 | 695 | */ |
| 699 | 696 | private function unparseUrl($parsed_url) |
| 700 | 697 | { |
| 701 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
| 698 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
| 702 | 699 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
| 703 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
| 704 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
| 705 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
| 700 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
| 701 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
| 702 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
| 706 | 703 | $path = $parsed_url['path']; |
| 707 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
| 704 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
| 708 | 705 | } |
| 709 | 706 | |
| 710 | 707 | } |
@@ -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 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | private function checkConcurrency() |
| 120 | 120 | { |
| 121 | 121 | $this->woocommerceOrderId = $_GET['order-received']; |
| 122 | - if ($this->woocommerceOrderId == '') { |
|
| 122 | + if ($this->woocommerceOrderId=='') { |
|
| 123 | 123 | throw new QuoteNotFoundException(); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | private function getProductType() |
| 134 | 134 | { |
| 135 | - if ($_GET['product'] == '') { |
|
| 135 | + if ($_GET['product']=='') { |
|
| 136 | 136 | $this->setProduct(WcPagantisGateway::METHOD_ID); |
| 137 | 137 | } else { |
| 138 | 138 | $this->setProduct($_GET['product']); |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | $order_id = $wpdb->get_var("SELECT order_id FROM $tableName WHERE token='{$this->getUrlToken()}' "); |
| 168 | 168 | $this->pagantisOrderId = $order_id; |
| 169 | 169 | |
| 170 | - if ($this->pagantisOrderId == '') { |
|
| 170 | + if ($this->pagantisOrderId=='') { |
|
| 171 | 171 | throw new NoIdentificationException(); |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | $status = '-'; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - if ($status === Order::STATUS_CONFIRMED) { |
|
| 213 | + if ($status===Order::STATUS_CONFIRMED) { |
|
| 214 | 214 | return true; |
| 215 | 215 | } |
| 216 | 216 | throw new WrongStatusException($status); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | ); |
| 232 | 232 | |
| 233 | 233 | if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM |
| 234 | - $logMessage = "WARNING checkMerchantOrderStatus." . |
|
| 234 | + $logMessage = "WARNING checkMerchantOrderStatus.". |
|
| 235 | 235 | " Merchant order id:".$this->woocommerceOrder->get_id(). |
| 236 | 236 | " Merchant order status:".$this->woocommerceOrder->get_status(). |
| 237 | 237 | " Pagantis order id:".$this->pagantisOrder->getStatus(). |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | { |
| 254 | 254 | $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
| 255 | 255 | $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total())); |
| 256 | - if ($pagantisAmount != $wcAmount) { |
|
| 256 | + if ($pagantisAmount!=$wcAmount) { |
|
| 257 | 257 | throw new AmountMismatchException($pagantisAmount, $wcAmount); |
| 258 | 258 | } |
| 259 | 259 | } |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId); |
| 278 | 278 | } catch (\Exception $e) { |
| 279 | 279 | $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId); |
| 280 | - if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) { |
|
| 280 | + if ($this->pagantisOrder->getStatus()!==Order::STATUS_CONFIRMED) { |
|
| 281 | 281 | throw new UnknownException($e->getMessage()); |
| 282 | 282 | } else { |
| 283 | 283 | $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process'; |
@@ -301,9 +301,9 @@ discard block |
||
| 301 | 301 | global $wpdb; |
| 302 | 302 | $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
| 303 | 303 | |
| 304 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
| 304 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
| 305 | 305 | $charset_collate = $wpdb->get_charset_collate(); |
| 306 | - $sql= "CREATE TABLE IF NOT EXISTS $tableName |
|
| 306 | + $sql = "CREATE TABLE IF NOT EXISTS $tableName |
|
| 307 | 307 | (id INT, |
| 308 | 308 | order_id varchar(60), |
| 309 | 309 | wc_order_id varchar(60), |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | global $wpdb; |
| 325 | 325 | $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
| 326 | 326 | |
| 327 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
| 327 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
| 328 | 328 | $charset_collate = $wpdb->get_charset_collate(); |
| 329 | 329 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
| 330 | 330 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -381,12 +381,12 @@ discard block |
||
| 381 | 381 | $metadataOrder = $this->pagantisOrder->getMetadata(); |
| 382 | 382 | $metadataInfo = null; |
| 383 | 383 | foreach ($metadataOrder as $metadataKey => $metadataValue) { |
| 384 | - if ($metadataKey == 'promotedProduct') { |
|
| 385 | - $metadataInfo.= "/Producto promocionado = $metadataValue"; |
|
| 384 | + if ($metadataKey=='promotedProduct') { |
|
| 385 | + $metadataInfo .= "/Producto promocionado = $metadataValue"; |
|
| 386 | 386 | } |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - if ($metadataInfo != null) { |
|
| 389 | + if ($metadataInfo!=null) { |
|
| 390 | 390 | $this->woocommerceOrder->add_order_note($metadataInfo); |
| 391 | 391 | } |
| 392 | 392 | |
@@ -414,9 +414,9 @@ discard block |
||
| 414 | 414 | $wpdb->update( |
| 415 | 415 | $tableName, |
| 416 | 416 | array('wc_order_id'=>$this->woocommerceOrderId), |
| 417 | - array('token' => $this->getUrlToken(),'order_id' => $this->pagantisOrderId), |
|
| 418 | - array( '%s'), |
|
| 419 | - array( '%s', '%s' ) |
|
| 417 | + array('token' => $this->getUrlToken(), 'order_id' => $this->pagantisOrderId), |
|
| 418 | + array('%s'), |
|
| 419 | + array('%s', '%s') |
|
| 420 | 420 | ); |
| 421 | 421 | } |
| 422 | 422 | |
@@ -454,13 +454,13 @@ discard block |
||
| 454 | 454 | { |
| 455 | 455 | global $wpdb; |
| 456 | 456 | $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME; |
| 457 | - if ($orderId == null) { |
|
| 457 | + if ($orderId==null) { |
|
| 458 | 458 | $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT." SECOND)"; |
| 459 | 459 | } else { |
| 460 | 460 | $query = "DELETE FROM $tableName WHERE order_id = $orderId"; |
| 461 | 461 | } |
| 462 | 462 | $resultDelete = $wpdb->query($query); |
| 463 | - if ($resultDelete === false) { |
|
| 463 | + if ($resultDelete===false) { |
|
| 464 | 464 | throw new ConcurrencyException(); |
| 465 | 465 | } |
| 466 | 466 | } |
@@ -475,8 +475,8 @@ discard block |
||
| 475 | 475 | global $wpdb; |
| 476 | 476 | $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME; |
| 477 | 477 | $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId)); |
| 478 | - if ($insertResult === false) { |
|
| 479 | - if ($this->getOrigin() == 'Notify') { |
|
| 478 | + if ($insertResult===false) { |
|
| 479 | + if ($this->getOrigin()=='Notify') { |
|
| 480 | 480 | throw new ConcurrencyException(); |
| 481 | 481 | } else { |
| 482 | 482 | $query = sprintf( |
@@ -487,8 +487,8 @@ discard block |
||
| 487 | 487 | ); |
| 488 | 488 | $resultSeconds = $wpdb->get_row($query); |
| 489 | 489 | $restSeconds = isset($resultSeconds) ? ($resultSeconds->rest) : 0; |
| 490 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
| 491 | - sleep($secondsToExpire+1); |
|
| 490 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
| 491 | + sleep($secondsToExpire + 1); |
|
| 492 | 492 | |
| 493 | 493 | $logMessage = sprintf( |
| 494 | 494 | "User waiting %s seconds, default seconds %s, bd time to expire %s seconds", |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | { |
| 513 | 513 | $this->unblockConcurrency($this->woocommerceOrderId); |
| 514 | 514 | |
| 515 | - if ($exception == null) { |
|
| 515 | + if ($exception==null) { |
|
| 516 | 516 | $jsonResponse = new JsonSuccessResponse(); |
| 517 | 517 | } else { |
| 518 | 518 | $jsonResponse = new JsonExceptionResponse(); |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | $jsonResponse->setMerchantOrderId($this->woocommerceOrderId); |
| 523 | 523 | $jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
| 524 | 524 | |
| 525 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 525 | + if ($_SERVER['REQUEST_METHOD']=='POST') { |
|
| 526 | 526 | $jsonResponse->printResponse(); |
| 527 | 527 | } else { |
| 528 | 528 | return $jsonResponse; |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | */ |
| 555 | 555 | private function isProduct4x() |
| 556 | 556 | { |
| 557 | - return ($this->product === Ucfirst(WcPagantis4xGateway::METHOD_ID)); |
|
| 557 | + return ($this->product===Ucfirst(WcPagantis4xGateway::METHOD_ID)); |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | /** |
@@ -594,13 +594,13 @@ discard block |
||
| 594 | 594 | */ |
| 595 | 595 | private function setUrlToken() |
| 596 | 596 | { |
| 597 | - if (!isset($_GET['token'])){ |
|
| 598 | - $logEntry = '$_GET[\'token\'] is empty' . |
|
| 597 | + if (!isset($_GET['token'])) { |
|
| 598 | + $logEntry = '$_GET[\'token\'] is empty'. |
|
| 599 | 599 | " cart hash: ".WC()->cart->get_cart_hash(). |
| 600 | 600 | " Merchant order id: ".$this->woocommerceOrderId. |
| 601 | 601 | " Pagantis order id: ".$this->pagantisOrderId. |
| 602 | 602 | " Pagantis urlToken: ".$this->getUrlToken(). |
| 603 | - " Function: " . __FUNCTION__; |
|
| 603 | + " Function: ".__FUNCTION__; |
|
| 604 | 604 | insertLogEntry(null, $logEntry); |
| 605 | 605 | } |
| 606 | 606 | |
@@ -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,10 +256,10 @@ 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 | - if (isPgTableCreated(PG_CART_PROCESS_TABLE)){ |
|
| 262 | + if (isPgTableCreated(PG_CART_PROCESS_TABLE)) { |
|
| 263 | 263 | alterCartProcessTable(); |
| 264 | 264 | } |
| 265 | 265 | |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 272 | 272 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
| 273 | 273 | $results = $wpdb->get_results($query, ARRAY_A); |
| 274 | - if (count($results) == 0) { |
|
| 274 | + if (count($results)==0) { |
|
| 275 | 275 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value' => '.'), array('%s', '%s')); |
| 276 | 276 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value' => ','), array('%s', '%s')); |
| 277 | 277 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 281 | 281 | $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'"; |
| 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_DISPLAY_MAX_AMOUNT', 'value' => '0'), array('%s', '%s')); |
| 285 | 285 | } |
| 286 | 286 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 289 | 289 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'"; |
| 290 | 290 | $results = $wpdb->get_results($query, ARRAY_A); |
| 291 | - if (count($results) == 0) { |
|
| 291 | + if (count($results)==0) { |
|
| 292 | 292 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value' => 'default'), array('%s', '%s')); |
| 293 | 293 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value' => 'default'), array('%s', '%s')); |
| 294 | 294 | } |
@@ -298,17 +298,17 @@ discard block |
||
| 298 | 298 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 299 | 299 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'"; |
| 300 | 300 | $results = $wpdb->get_results($query, ARRAY_A); |
| 301 | - if (count($results) == 0) { |
|
| 301 | + if (count($results)==0) { |
|
| 302 | 302 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', 'value' => 'sdk.simulator.types.CHECKOUT_PAGE'), array('%s', '%s')); |
| 303 | 303 | $wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), array('%s'), array('%s')); |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | //Adapting to variable selector < v8.3.6 |
| 307 | - $variableSelector="div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
| 307 | + $variableSelector = "div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
| 308 | 308 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 309 | 309 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'"; |
| 310 | 310 | $results = $wpdb->get_results($query, ARRAY_A); |
| 311 | - if (count($results) == 0) { |
|
| 311 | + if (count($results)==0) { |
|
| 312 | 312 | $wpdb->update($tableName, array('value' => $variableSelector), array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION'), array('%s'), array('%s')); |
| 313 | 313 | } |
| 314 | 314 | |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 317 | 317 | $query = "select * from $tableName where config='PAGANTIS_TITLE_4x'"; |
| 318 | 318 | $results = $wpdb->get_results($query, ARRAY_A); |
| 319 | - if (count($results) == 0) { |
|
| 319 | + if (count($results)==0) { |
|
| 320 | 320 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_TITLE_4x', 'value' => 'Until 4 installments, without fees'), array('%s', '%s')); |
| 321 | 321 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MIN_AMOUNT_4x', 'value' => 1), array('%s', '%s')); |
| 322 | 322 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT_4x', 'value' => 800), array('%s', '%s')); |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 330 | 330 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X'"; |
| 331 | 331 | $results = $wpdb->get_results($query, ARRAY_A); |
| 332 | - if (count($results) == 0) { |
|
| 332 | + if (count($results)==0) { |
|
| 333 | 333 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X', 'value' => 'default'), array('%s', '%s')); |
| 334 | 334 | } |
| 335 | 335 | |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
| 346 | 346 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
| 347 | 347 | $results = $wpdb->get_results($query, ARRAY_A); |
| 348 | - if (count($results) == 0) { |
|
| 348 | + if (count($results)==0) { |
|
| 349 | 349 | $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')); |
| 350 | 350 | } |
| 351 | 351 | |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | */ |
| 385 | 385 | public function checkWcPriceSettings() |
| 386 | 386 | { |
| 387 | - if (class_exists( 'WooCommerce' ) ){ |
|
| 387 | + if (class_exists('WooCommerce')) { |
|
| 388 | 388 | $this->checkWcDecimalSeparatorSettings(); |
| 389 | 389 | $this->checkWcThousandsSeparatorSettings(); |
| 390 | 390 | } |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | $isAtcTplPresent = isTemplatePresent( |
| 438 | 438 | $template_name, |
| 439 | 439 | array('single-product/add-to-cart/variation-add-to-cart-button.php', |
| 440 | - 'single-product/add-to-cart/variation.php','single-product/add-to-cart/simple.php') |
|
| 440 | + 'single-product/add-to-cart/variation.php', 'single-product/add-to-cart/simple.php') |
|
| 441 | 441 | ); |
| 442 | 442 | |
| 443 | 443 | $html = apply_filters('pagantis_simulator_selector_html', '<div class="mainPagantisSimulator"></div><div class="pagantisSimulator"></div>'); |
@@ -449,10 +449,10 @@ discard block |
||
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | $pagantisSimulator4x = 'enabled'; |
| 452 | - if (!isPluginEnabled4x() || !areMerchantKeysSet4x() || !isCountryShopContextValid() || !isProductAmountValid4x()) { |
|
| 452 | + if (!isPluginEnabled4x() || !areMerchantKeysSet4x() || !isCountryShopContextValid() || !isProductAmountValid4x()) { |
|
| 453 | 453 | $pagantisSimulator4x = 'disabled'; |
| 454 | 454 | } |
| 455 | - if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') { |
|
| 455 | + if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') { |
|
| 456 | 456 | return; |
| 457 | 457 | } |
| 458 | 458 | |
@@ -508,12 +508,12 @@ discard block |
||
| 508 | 508 | $pagantisSimulator4x = 'disabled'; |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') { |
|
| 511 | + if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') { |
|
| 512 | 512 | return; |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | $totalPrice = $product->get_price(); |
| 516 | - $formattedInstallments = number_format($totalPrice/4, 2); |
|
| 516 | + $formattedInstallments = number_format($totalPrice / 4, 2); |
|
| 517 | 517 | $simulatorMessage = sprintf(__('or 4 installments of %s€, without fees, with ', 'pagantis'), $formattedInstallments); |
| 518 | 518 | $post_id = $product->get_id(); |
| 519 | 519 | $logo = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | */ |
| 557 | 557 | public function addPagantisGateway($methods) |
| 558 | 558 | { |
| 559 | - if (! class_exists('WC_Payment_Gateway')) { |
|
| 559 | + if (!class_exists('WC_Payment_Gateway')) { |
|
| 560 | 560 | return $methods; |
| 561 | 561 | } |
| 562 | 562 | |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | */ |
| 622 | 622 | public function pagantisRowMeta($links, $file) |
| 623 | 623 | { |
| 624 | - if ($file == plugin_basename(__FILE__)) { |
|
| 624 | + if ($file==plugin_basename(__FILE__)) { |
|
| 625 | 625 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
| 626 | 626 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
| 627 | 627 | __('API documentation', 'pagantis').'</a>'; |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
| 651 | 651 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
| 652 | 652 | $results = $wpdb->get_results($query); |
| 653 | - if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) { |
|
| 653 | + if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) { |
|
| 654 | 654 | foreach ($results as $key => $result) { |
| 655 | 655 | $response[$key]['timestamp'] = $result->createdAt; |
| 656 | 656 | $response[$key]['log'] = json_decode($result->log); |
@@ -677,13 +677,13 @@ discard block |
||
| 677 | 677 | |
| 678 | 678 | $filters = ($data->get_params()); |
| 679 | 679 | $secretKey = $filters['secret']; |
| 680 | - $cfg = get_option('woocommerce_pagantis_settings'); |
|
| 680 | + $cfg = get_option('woocommerce_pagantis_settings'); |
|
| 681 | 681 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
| 682 | 682 | $privateKey4x = isset($cfg['pagantis_private_key_4x']) ? $cfg['pagantis_private_key_4x'] : null; |
| 683 | - if ($privateKey != $secretKey && $privateKey4x != $secretKey) { |
|
| 683 | + if ($privateKey!=$secretKey && $privateKey4x!=$secretKey) { |
|
| 684 | 684 | $response['status'] = 401; |
| 685 | 685 | $response['result'] = 'Unauthorized'; |
| 686 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 686 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
| 687 | 687 | if (count($_POST)) { |
| 688 | 688 | foreach ($_POST as $config => $value) { |
| 689 | 689 | if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc"; |
| 745 | 745 | $results = $wpdb->get_results($query); |
| 746 | 746 | |
| 747 | - if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) { |
|
| 747 | + if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) { |
|
| 748 | 748 | foreach ($results as $result) { |
| 749 | 749 | $key = $result->ID; |
| 750 | 750 | $response['message'][$key]['timestamp'] = $result->post_date; |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | */ |
| 818 | 818 | private function prepareQuantitySelector($css_quantity_selector) |
| 819 | 819 | { |
| 820 | - if ($css_quantity_selector == 'default' || $css_quantity_selector == '') { |
|
| 820 | + if ($css_quantity_selector=='default' || $css_quantity_selector=='') { |
|
| 821 | 821 | $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
| 822 | 822 | } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
| 823 | 823 | $css_quantity_selector = serialize(array($css_quantity_selector)); |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | */ |
| 834 | 834 | private function preparePriceSelector($css_price_selector) |
| 835 | 835 | { |
| 836 | - if ($css_price_selector == 'default' || $css_price_selector == '') { |
|
| 836 | + if ($css_price_selector=='default' || $css_price_selector=='') { |
|
| 837 | 837 | $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
| 838 | 838 | } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
| 839 | 839 | $css_price_selector = serialize(array($css_price_selector)); |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | { |
| 852 | 852 | $metaProduct = get_post_meta($product_id); |
| 853 | 853 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && |
| 854 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
| 854 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | /** |
@@ -257,9 +257,9 @@ discard block |
||
| 257 | 257 | if ($promotedProduct == 'true') { |
| 258 | 258 | $promotedAmount+=$product->getAmount(); |
| 259 | 259 | $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
| 260 | - ' - Price: ' . $item->get_total() . |
|
| 261 | - ' - Qty: ' . $product->getQuantity() . |
|
| 262 | - ' - Item ID: ' . $item['id_product']; |
|
| 260 | + ' - Price: ' . $item->get_total() . |
|
| 261 | + ' - Qty: ' . $product->getQuantity() . |
|
| 262 | + ' - Item ID: ' . $item['id_product']; |
|
| 263 | 263 | $promotedMessage = substr($promotedMessage, 0, 999); |
| 264 | 264 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
| 265 | 265 | } |
@@ -275,10 +275,10 @@ discard block |
||
| 275 | 275 | $orderConfigurationUrls = new Urls(); |
| 276 | 276 | $cancelUrl = $this->getKoUrl($order); |
| 277 | 277 | $callback_arg = array('wc-api'=>'wcpagantisgateway', |
| 278 | - 'key'=>$order->get_order_key(), |
|
| 279 | - 'order-received'=>$order->get_id(), |
|
| 280 | - 'origin' => '', |
|
| 281 | - 'token' => $this->urlToken4x |
|
| 278 | + 'key'=>$order->get_order_key(), |
|
| 279 | + 'order-received'=>$order->get_id(), |
|
| 280 | + 'origin' => '', |
|
| 281 | + 'token' => $this->urlToken4x |
|
| 282 | 282 | |
| 283 | 283 | ); |
| 284 | 284 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $this->urlToken4x = strtoupper(md5(uniqid(rand(), true))); |
| 67 | 67 | |
| 68 | 68 | //Useful vars |
| 69 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/'; |
|
| 69 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/'; |
|
| 70 | 70 | $this->allowed_currencies = getAllowedCurrencies(); |
| 71 | 71 | $this->language = strstr(get_locale(), '_', true); |
| 72 | 72 | if ($this->language=='') { |
@@ -75,24 +75,24 @@ discard block |
||
| 75 | 75 | $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
| 76 | 76 | |
| 77 | 77 | //Panel form fields |
| 78 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options |
|
| 78 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options |
|
| 79 | 79 | $this->init_settings(); |
| 80 | 80 | |
| 81 | 81 | $this->extraConfig = getExtraConfig(); |
| 82 | 82 | $this->title = __($this->extraConfig['PAGANTIS_TITLE_4x'], 'pagantis'); |
| 83 | 83 | $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis."; |
| 84 | 84 | |
| 85 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl(); |
|
| 86 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl(); |
|
| 85 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
| 86 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
| 87 | 87 | foreach ($this->settings as $setting_key => $setting_value) { |
| 88 | 88 | $this->$setting_key = $setting_value; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | //Hooks |
| 92 | - add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options |
|
| 93 | - add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
| 94 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
| 95 | - add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3); |
|
| 92 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options |
|
| 93 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
| 94 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
| 95 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3); |
|
| 96 | 96 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function loadPagantisTranslation($mofile, $domain) |
| 106 | 106 | { |
| 107 | - if ('pagantis' === $domain) { |
|
| 108 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 107 | + if ('pagantis'===$domain) { |
|
| 108 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 109 | 109 | } |
| 110 | 110 | return $mofile; |
| 111 | 111 | } |
@@ -154,14 +154,14 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | $shippingAddress = $order->get_address('shipping'); |
| 156 | 156 | $billingAddress = $order->get_address('billing'); |
| 157 | - if ($shippingAddress['address_1'] == '') { |
|
| 157 | + if ($shippingAddress['address_1']=='') { |
|
| 158 | 158 | $shippingAddress = $billingAddress; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | $customer_id = $order->get_customer_id(); |
| 162 | - $national_id = maybeGetIDNumber($order , $customer_id); |
|
| 163 | - $tax_id = maybeGetTaxIDNumber($order , $customer_id); |
|
| 164 | - $phoneNumber = maybeGetPhoneNumber($order , $customer_id); |
|
| 162 | + $national_id = maybeGetIDNumber($order, $customer_id); |
|
| 163 | + $tax_id = maybeGetTaxIDNumber($order, $customer_id); |
|
| 164 | + $phoneNumber = maybeGetPhoneNumber($order, $customer_id); |
|
| 165 | 165 | |
| 166 | 166 | |
| 167 | 167 | $userAddress = new Address(); |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | ->setDni($national_id) |
| 188 | 188 | ->setTaxId($tax_id) |
| 189 | 189 | ; |
| 190 | - $orderBillingAddress = new Address(); |
|
| 190 | + $orderBillingAddress = new Address(); |
|
| 191 | 191 | $orderBillingAddress |
| 192 | 192 | ->setZipCode($billingAddress['postcode']) |
| 193 | 193 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
@@ -264,12 +264,12 @@ discard block |
||
| 264 | 264 | $details->addProduct($product); |
| 265 | 265 | |
| 266 | 266 | $promotedProduct = isProductPromoted($item->get_product_id()); |
| 267 | - if ($promotedProduct == 'true') { |
|
| 268 | - $promotedAmount+=$product->getAmount(); |
|
| 269 | - $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
|
| 270 | - ' - Price: ' . $item->get_total() . |
|
| 271 | - ' - Qty: ' . $product->getQuantity() . |
|
| 272 | - ' - Item ID: ' . $item['id_product']; |
|
| 267 | + if ($promotedProduct=='true') { |
|
| 268 | + $promotedAmount += $product->getAmount(); |
|
| 269 | + $promotedMessage = 'Promoted Item: '.$wcProduct->get_name(). |
|
| 270 | + ' - Price: '.$item->get_total(). |
|
| 271 | + ' - Qty: '.$product->getQuantity(). |
|
| 272 | + ' - Item ID: '.$item['id_product']; |
|
| 273 | 273 | $promotedMessage = substr($promotedMessage, 0, 999); |
| 274 | 274 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
| 275 | 275 | } |
@@ -317,9 +317,7 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
| 319 | 319 | $purchaseCountry = |
| 320 | - in_array(strtolower($this->language), $allowedCountries) ? $this->language : |
|
| 321 | - in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : |
|
| 322 | - in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null; |
|
| 320 | + 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; |
|
| 323 | 321 | |
| 324 | 322 | $orderConfiguration = new Configuration(); |
| 325 | 323 | $orderConfiguration |
@@ -344,7 +342,7 @@ discard block |
||
| 344 | 342 | $pagantisOrder = $orderClient->createOrder($orderApiClient); |
| 345 | 343 | if ($pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) { |
| 346 | 344 | $url = $pagantisOrder->getActionUrls()->getForm(); |
| 347 | - addOrderToProcessingQueue($pagantisOrder->getId(), $order->get_id(), $this->urlToken4x,self::METHOD_ID); |
|
| 345 | + addOrderToProcessingQueue($pagantisOrder->getId(), $order->get_id(), $this->urlToken4x, self::METHOD_ID); |
|
| 348 | 346 | } else { |
| 349 | 347 | throw new OrderNotFoundException(); |
| 350 | 348 | } |
@@ -363,7 +361,7 @@ discard block |
||
| 363 | 361 | wc_get_template('iframe.php', $template_fields, '', $this->template_path); |
| 364 | 362 | } |
| 365 | 363 | } catch (\Exception $exception) { |
| 366 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); |
|
| 364 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); |
|
| 367 | 365 | insertLogEntry($exception); |
| 368 | 366 | $checkout_url = get_permalink(wc_get_page_id('checkout')); |
| 369 | 367 | wp_redirect($checkout_url); |
@@ -379,7 +377,7 @@ discard block |
||
| 379 | 377 | public function pagantisNotification() |
| 380 | 378 | { |
| 381 | 379 | try { |
| 382 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
| 380 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
| 383 | 381 | |
| 384 | 382 | include_once('notifyController.php'); |
| 385 | 383 | $notify = new WcPagantisNotify(); |
@@ -418,10 +416,10 @@ discard block |
||
| 418 | 416 | */ |
| 419 | 417 | public function pagantisCompleteStatus($status, $order_id, $order) |
| 420 | 418 | { |
| 421 | - if ($order->get_payment_method() == WcPagantis4xGateway::METHOD_ID) { |
|
| 422 | - if ($order->get_status() == 'failed') { |
|
| 419 | + if ($order->get_payment_method()==WcPagantis4xGateway::METHOD_ID) { |
|
| 420 | + if ($order->get_status()=='failed') { |
|
| 423 | 421 | $status = 'processing'; |
| 424 | - } elseif ($order->get_status() == 'pending' && $status=='completed') { |
|
| 422 | + } elseif ($order->get_status()=='pending' && $status=='completed') { |
|
| 425 | 423 | $status = 'processing'; |
| 426 | 424 | } |
| 427 | 425 | } |
@@ -450,8 +448,8 @@ discard block |
||
| 450 | 448 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
| 451 | 449 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT_4x']; |
| 452 | 450 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT_4x']; |
| 453 | - $totalPrice = (int)$this->get_order_total(); |
|
| 454 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
| 451 | + $totalPrice = (int) $this->get_order_total(); |
|
| 452 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
| 455 | 453 | if ($cfg['enabled_4x']==='yes' && $cfg['pagantis_public_key_4x']!='' && $cfg['pagantis_private_key_4x']!='' && |
| 456 | 454 | $validAmount && $allowedCountry) { |
| 457 | 455 | return true; |
@@ -486,7 +484,7 @@ discard block |
||
| 486 | 484 | |
| 487 | 485 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
| 488 | 486 | if (strpos($redirectUrl, 'order-pay=')===false) { |
| 489 | - $redirectUrl.="&order-pay=".$order_id; |
|
| 487 | + $redirectUrl .= "&order-pay=".$order_id; |
|
| 490 | 488 | } |
| 491 | 489 | |
| 492 | 490 | return array( |
@@ -494,7 +492,7 @@ discard block |
||
| 494 | 492 | 'redirect' => $redirectUrl |
| 495 | 493 | ); |
| 496 | 494 | } catch (Exception $e) { |
| 497 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); |
|
| 495 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); |
|
| 498 | 496 | return array(); |
| 499 | 497 | } |
| 500 | 498 | } |
@@ -565,7 +563,7 @@ discard block |
||
| 565 | 563 | private function generateUrl($url) |
| 566 | 564 | { |
| 567 | 565 | $parsed_url = parse_url($url); |
| 568 | - if ($parsed_url !== false) { |
|
| 566 | + if ($parsed_url!==false) { |
|
| 569 | 567 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
| 570 | 568 | parse_str($parsed_url['query'], $arrayParams); |
| 571 | 569 | foreach ($arrayParams as $keyParam => $valueParam) { |
@@ -613,11 +611,10 @@ discard block |
||
| 613 | 611 | private function getKeysUrl($order, $url) |
| 614 | 612 | { |
| 615 | 613 | $defaultFields = (get_class($order)=='WC_Order') ? |
| 616 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : |
|
| 617 | - array(); |
|
| 614 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array(); |
|
| 618 | 615 | |
| 619 | 616 | $parsedUrl = parse_url($url); |
| 620 | - if ($parsedUrl !== false) { |
|
| 617 | + if ($parsedUrl!==false) { |
|
| 621 | 618 | //Replace parameters from url |
| 622 | 619 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
| 623 | 620 | |
@@ -662,7 +659,7 @@ discard block |
||
| 662 | 659 | foreach ($arrayParams as $keyParam => $valueParam) { |
| 663 | 660 | preg_match('#\{{.*?}\}#', $valueParam, $match); |
| 664 | 661 | if (count($match)) { |
| 665 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]); |
|
| 662 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]); |
|
| 666 | 663 | $arrayParams[$keyParam] = $defaultFields[$key]; |
| 667 | 664 | } |
| 668 | 665 | } |
@@ -677,12 +674,12 @@ discard block |
||
| 677 | 674 | */ |
| 678 | 675 | private function unparseUrl($parsed_url) |
| 679 | 676 | { |
| 680 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
| 677 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
| 681 | 678 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
| 682 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
| 683 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
| 684 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
| 679 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
| 680 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
| 681 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
| 685 | 682 | $path = $parsed_url['path']; |
| 686 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
| 683 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
| 687 | 684 | } |
| 688 | 685 | } |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | function requireWPPluginFunctions() |
| 4 | 4 | { |
| 5 | - if (! function_exists('is_plugin_active')) { |
|
| 6 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 5 | + if (!function_exists('is_plugin_active')) { |
|
| 6 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
| 7 | 7 | } |
| 8 | 8 | } |
| 9 | 9 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | function getConfigValue($configKey) |
| 22 | 22 | { |
| 23 | 23 | global $wpdb; |
| 24 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 24 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 25 | 25 | $value = $wpdb->get_var($wpdb->prepare("SELECT value FROM $tableName WHERE config= %s ", $configKey)); |
| 26 | 26 | |
| 27 | 27 | return $value; |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | function isPgTableCreated($tableToCheck) |
| 39 | 39 | { |
| 40 | 40 | global $wpdb; |
| 41 | - $tableName = $wpdb->prefix . $tableToCheck; |
|
| 42 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) { |
|
| 41 | + $tableName = $wpdb->prefix.$tableToCheck; |
|
| 42 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")==$tableName) { |
|
| 43 | 43 | return true; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | function createPgCartTable() |
| 53 | 53 | { |
| 54 | 54 | global $wpdb; |
| 55 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
| 55 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
| 56 | 56 | $charset_collate = $wpdb->get_charset_collate(); |
| 57 | 57 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
| 58 | 58 | UNIQUE KEY id (id)) $charset_collate"; |
| 59 | 59 | |
| 60 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 60 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 61 | 61 | dbDelta($sql); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | { |
| 66 | 66 | global $wpdb; |
| 67 | 67 | $charset_collate = $wpdb->get_charset_collate(); |
| 68 | - $LogsTableName = $wpdb->prefix . PG_LOGS_TABLE_NAME; |
|
| 68 | + $LogsTableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
|
| 69 | 69 | $sqlQuery = "CREATE TABLE $LogsTableName ( |
| 70 | 70 | id int NOT NULL AUTO_INCREMENT, |
| 71 | 71 | log text NOT NULL, |
| 72 | 72 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, |
| 73 | 73 | UNIQUE KEY id (id)) |
| 74 | 74 | $charset_collate"; |
| 75 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 75 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 76 | 76 | dbDelta($sqlQuery); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | function insertLogEntry($exception = null, $message = null) |
| 84 | 84 | { |
| 85 | 85 | global $wpdb; |
| 86 | - if (! isPgTableCreated(PG_LOGS_TABLE_NAME)) { |
|
| 86 | + if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) { |
|
| 87 | 87 | createLogsTable(); |
| 88 | 88 | } |
| 89 | 89 | $logEntry = new Pagantis\ModuleUtils\Model\Log\LogEntry(); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | } else { |
| 93 | 93 | $logEntry = $logEntry->info($message); |
| 94 | 94 | } |
| 95 | - $tableName = $wpdb->prefix . PG_LOGS_TABLE_NAME; |
|
| 95 | + $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
|
| 96 | 96 | $wpdb->insert($tableName, array('log' => $logEntry->toJson())); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | { |
| 104 | 104 | $pgDecimalSeparator = getPgSimulatorDecimalSeparatorConfig(); |
| 105 | 105 | $wc_decimal_sep = get_option('woocommerce_price_decimal_sep'); |
| 106 | - if (stripslashes($wc_decimal_sep) == stripslashes($pgDecimalSeparator)) { |
|
| 106 | + if (stripslashes($wc_decimal_sep)==stripslashes($pgDecimalSeparator)) { |
|
| 107 | 107 | return true; |
| 108 | 108 | } else { |
| 109 | 109 | return false; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | { |
| 119 | 119 | $pgThousandSeparator = getPgSimulatorThousandsSeparator(); |
| 120 | 120 | $wc_price_thousand = get_option('woocommerce_price_thousand_sep'); |
| 121 | - if (stripslashes($wc_price_thousand) == stripslashes($pgThousandSeparator)) { |
|
| 121 | + if (stripslashes($wc_price_thousand)==stripslashes($pgThousandSeparator)) { |
|
| 122 | 122 | return true; |
| 123 | 123 | } else { |
| 124 | 124 | return false; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | function getPgSimulatorThousandsSeparator() |
| 132 | 132 | { |
| 133 | 133 | global $wpdb; |
| 134 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 134 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 135 | 135 | $query = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
| 136 | 136 | $result = $wpdb->get_row($query, ARRAY_A); |
| 137 | 137 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | function getPgSimulatorDecimalSeparatorConfig() |
| 145 | 145 | { |
| 146 | 146 | global $wpdb; |
| 147 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 147 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 148 | 148 | $query = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'"; |
| 149 | 149 | $result = $wpdb->get_row($query, ARRAY_A); |
| 150 | 150 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | if (areThousandsSeparatorEqual()) { |
| 158 | 158 | return; |
| 159 | 159 | } |
| 160 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 160 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 161 | 161 | $thousandSeparator = get_option('woocommerce_price_thousand_sep'); |
| 162 | 162 | $wpdb->update( |
| 163 | 163 | $tableName, |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | if (areDecimalSeparatorEqual()) { |
| 175 | 175 | return; |
| 176 | 176 | } |
| 177 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 177 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 178 | 178 | $decimalSeparator = get_option('woocommerce_price_decimal_sep'); |
| 179 | 179 | $wpdb->update( |
| 180 | 180 | $tableName, |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | function isSimulatorTypeValid($simulatorType, $validSimulatorTypes) |
| 196 | 196 | { |
| 197 | - if (! in_array($simulatorType, $validSimulatorTypes)) { |
|
| 197 | + if (!in_array($simulatorType, $validSimulatorTypes)) { |
|
| 198 | 198 | return false; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -221,8 +221,8 @@ discard block |
||
| 221 | 221 | function areMerchantKeysSet() |
| 222 | 222 | { |
| 223 | 223 | $settings = get_option('woocommerce_pagantis_settings'); |
| 224 | - $publicKey = ! empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : ''; |
|
| 225 | - $privateKey = ! empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : ''; |
|
| 224 | + $publicKey = !empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : ''; |
|
| 225 | + $privateKey = !empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : ''; |
|
| 226 | 226 | if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) { |
| 227 | 227 | return false; |
| 228 | 228 | } |
@@ -233,8 +233,8 @@ discard block |
||
| 233 | 233 | function areMerchantKeysSet4x() |
| 234 | 234 | { |
| 235 | 235 | $settings = get_option('woocommerce_pagantis_settings'); |
| 236 | - $publicKey = ! empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : ''; |
|
| 237 | - $privateKey = ! empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : ''; |
|
| 236 | + $publicKey = !empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : ''; |
|
| 237 | + $privateKey = !empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : ''; |
|
| 238 | 238 | if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) { |
| 239 | 239 | return false; |
| 240 | 240 | } |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | function isSimulatorEnabled() |
| 246 | 246 | { |
| 247 | 247 | $settings = get_option('woocommerce_pagantis_settings'); |
| 248 | - if ((! empty($settings['simulator']) && 'yes' === $settings['simulator']) ? true : false) { |
|
| 248 | + if ((!empty($settings['simulator']) && 'yes'===$settings['simulator']) ? true : false) { |
|
| 249 | 249 | return true; |
| 250 | 250 | } |
| 251 | 251 | |
@@ -256,13 +256,13 @@ discard block |
||
| 256 | 256 | { |
| 257 | 257 | $settings = get_option('woocommerce_pagantis_settings'); |
| 258 | 258 | |
| 259 | - return (! empty($settings['enabled']) && 'yes' === $settings['enabled']); |
|
| 259 | + return (!empty($settings['enabled']) && 'yes'===$settings['enabled']); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | function isPluginEnabled4x() |
| 263 | 263 | { |
| 264 | 264 | $settings = get_option('woocommerce_pagantis_settings'); |
| 265 | - return (! empty($settings['enabled_4x']) && 'yes' === $settings['enabled_4x']); |
|
| 265 | + return (!empty($settings['enabled_4x']) && 'yes'===$settings['enabled_4x']); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | { |
| 271 | 271 | $locale = strtolower(strstr(get_locale(), '_', true)); |
| 272 | 272 | $allowedCountries = maybe_unserialize(getConfigValue('PAGANTIS_ALLOWED_COUNTRIES')); |
| 273 | - if (! in_array(strtolower($locale), $allowedCountries)) { |
|
| 273 | + if (!in_array(strtolower($locale), $allowedCountries)) { |
|
| 274 | 274 | return false; |
| 275 | 275 | } |
| 276 | 276 | |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | global $product; |
| 288 | 288 | if (method_exists($product, 'get_price')) { |
| 289 | 289 | $productPrice = $product->get_price(); |
| 290 | - $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0')); |
|
| 290 | + $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0')); |
|
| 291 | 291 | if ($validAmount) { |
| 292 | 292 | return true; |
| 293 | 293 | } |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | global $product; |
| 307 | 307 | if (method_exists($product, 'get_price')) { |
| 308 | 308 | $productPrice = $product->get_price(); |
| 309 | - $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0')); |
|
| 309 | + $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0')); |
|
| 310 | 310 | if ($validAmount) { |
| 311 | 311 | return true; |
| 312 | 312 | } |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | function getExtraConfig() |
| 326 | 326 | { |
| 327 | 327 | global $wpdb; |
| 328 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
| 328 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
| 329 | 329 | $response = array(); |
| 330 | 330 | $dbResult = $wpdb->get_results("select config, value from $tableName", ARRAY_A); |
| 331 | 331 | foreach ($dbResult as $value) { |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | function getModuleVersion() |
| 339 | 339 | { |
| 340 | 340 | |
| 341 | - $mainFile = plugin_dir_path(PG_WC_MAIN_FILE). '/WC_Pagantis.php'; |
|
| 341 | + $mainFile = plugin_dir_path(PG_WC_MAIN_FILE).'/WC_Pagantis.php'; |
|
| 342 | 342 | $version = get_file_data($mainFile, array('Version' => 'Version'), false); |
| 343 | 343 | return $version['Version']; |
| 344 | 344 | } |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | ); |
| 472 | 472 | |
| 473 | 473 | foreach ($metaKeys as $key) { |
| 474 | - $date = empty($customer->get_meta($key)) ? $customer->get_meta($key) : get_user_meta( $customerID, '_automatewoo_birthday_full', true ); |
|
| 474 | + $date = empty($customer->get_meta($key)) ? $customer->get_meta($key) : get_user_meta($customerID, '_automatewoo_birthday_full', true); |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | } |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | $metaProduct = get_post_meta($product_id); |
| 490 | 490 | |
| 491 | 491 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) |
| 492 | - && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
| 492 | + && $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | /** |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | $promotedAmount = 0; |
| 501 | 501 | foreach (WC()->cart->get_cart() as $key => $item) { |
| 502 | 502 | $promotedProduct = isProductPromoted($item['product_id']); |
| 503 | - if ($promotedProduct == 'true') { |
|
| 503 | + if ($promotedProduct=='true') { |
|
| 504 | 504 | $promotedAmount += $item['line_total'] + $item['line_tax']; |
| 505 | 505 | } |
| 506 | 506 | } |
@@ -514,24 +514,24 @@ discard block |
||
| 514 | 514 | * @param $urlToken |
| 515 | 515 | * @param $methodID |
| 516 | 516 | */ |
| 517 | -function addOrderToProcessingQueue($pagantisOrderId, $wcOrderID, $urlToken ,$methodID) |
|
| 517 | +function addOrderToProcessingQueue($pagantisOrderId, $wcOrderID, $urlToken, $methodID) |
|
| 518 | 518 | { |
| 519 | 519 | global $wpdb; |
| 520 | 520 | checkCartProcessTable(); |
| 521 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
| 521 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
| 522 | 522 | |
| 523 | 523 | //Check if id exists |
| 524 | 524 | $resultsSelect = $wpdb->get_results("SELECT * FROM $tableName WHERE id='$pagantisOrderId'"); |
| 525 | 525 | $countResults = count($resultsSelect); |
| 526 | 526 | |
| 527 | - if ($countResults == 0) { |
|
| 527 | + if ($countResults==0) { |
|
| 528 | 528 | $wpdb->insert($tableName, array( |
| 529 | 529 | 'order_id' => $pagantisOrderId, |
| 530 | 530 | 'wc_order_id' => $wcOrderID, |
| 531 | 531 | 'token' => $urlToken |
| 532 | 532 | ), array('%s', '%s', '%s')); |
| 533 | 533 | |
| 534 | - $logEntry = "Cart Added to Processing Queue" . |
|
| 534 | + $logEntry = "Cart Added to Processing Queue". |
|
| 535 | 535 | " cart hash: ".WC()->cart->get_cart_hash(). |
| 536 | 536 | " Merchant order id: ".$wcOrderID. |
| 537 | 537 | " Pagantis order id: ".$pagantisOrderId. |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | insertLogEntry(null, $logEntry); |
| 541 | 541 | } else { |
| 542 | 542 | $wpdb->update($tableName, |
| 543 | - array('order_id' => $pagantisOrderId,'token' => $urlToken), |
|
| 543 | + array('order_id' => $pagantisOrderId, 'token' => $urlToken), |
|
| 544 | 544 | array('wc_order_id' => $wcOrderID), |
| 545 | 545 | array('%s,%s'), |
| 546 | 546 | array('%s')); |
@@ -551,8 +551,8 @@ discard block |
||
| 551 | 551 | function alterCartProcessTable() |
| 552 | 552 | { |
| 553 | 553 | global $wpdb; |
| 554 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
| 555 | - if (! $wpdb->get_var( "SHOW COLUMNS FROM `{$tableName}` LIKE 'token';" ) ) { |
|
| 554 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
| 555 | + if (!$wpdb->get_var("SHOW COLUMNS FROM `{$tableName}` LIKE 'token';")) { |
|
| 556 | 556 | $wpdb->query("ALTER TABLE $tableName ADD COLUMN `token` VARCHAR(32) NOT NULL AFTER `order_id`"); |
| 557 | 557 | $wpdb->query("ALTER TABLE $tableName DROP PRIMARY KEY, ADD PRIMARY KEY(order_id)"); |
| 558 | 558 | // OLDER VERSIONS OF MODULE USE UNIQUE KEY ON `id` MEANING THIS VALUE WAS NULLABLE |
@@ -566,9 +566,9 @@ discard block |
||
| 566 | 566 | function checkCartProcessTable() |
| 567 | 567 | { |
| 568 | 568 | global $wpdb; |
| 569 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
| 569 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
| 570 | 570 | |
| 571 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
| 571 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
| 572 | 572 | |
| 573 | 573 | $charset_collate = $wpdb->get_charset_collate(); |
| 574 | 574 | $sql = "CREATE TABLE IF NOT EXISTS $tableName( |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | PRIMARY KEY (`id`, `order_id`) |
| 580 | 580 | )$charset_collate"; |
| 581 | 581 | |
| 582 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 582 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 583 | 583 | dbDelta($sql); |
| 584 | 584 | } |
| 585 | 585 | } |
@@ -622,7 +622,7 @@ discard block |
||
| 622 | 622 | 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
| 623 | 623 | )); |
| 624 | 624 | foreach ($customer_orders as $customer_order) { |
| 625 | - if (trim($sign_up) == '' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) { |
|
| 625 | + if (trim($sign_up)=='' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) { |
|
| 626 | 626 | $sign_up = substr($customer_order->post_date, 0, 10); |
| 627 | 627 | } |
| 628 | 628 | } |