@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! defined('ABSPATH')) { |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | 4 | exit; |
5 | 5 | } |
6 | 6 | |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | { |
25 | 25 | $ajax_events = array('pagantis_checkout'); |
26 | 26 | foreach ($ajax_events as $ajax_event => $nopriv) { |
27 | - add_action('wp_ajax_woocommerce_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
27 | + add_action('wp_ajax_woocommerce_'.$ajax_event, array(__CLASS__, $ajax_event)); |
|
28 | 28 | if ($nopriv) { |
29 | 29 | add_action( |
30 | - 'wp_ajax_nopriv_woocommerce_' . $ajax_event, |
|
30 | + 'wp_ajax_nopriv_woocommerce_'.$ajax_event, |
|
31 | 31 | array(__CLASS__, $ajax_event) |
32 | 32 | ); |
33 | 33 | // WC AJAX can be used for frontend ajax requests. |
34 | - add_action('wc_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
34 | + add_action('wc_ajax_'.$ajax_event, array(__CLASS__, $ajax_event)); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | } |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | public function __construct() |
37 | 37 | { |
38 | 38 | |
39 | - require_once dirname(__FILE__) . '/../includes/class-wc-pagantis-config.php'; |
|
40 | - require_once dirname(__FILE__) . '/../includes/functions.php'; |
|
39 | + require_once dirname(__FILE__).'/../includes/class-wc-pagantis-config.php'; |
|
40 | + require_once dirname(__FILE__).'/../includes/functions.php'; |
|
41 | 41 | $this->settings = get_option('woocommerce_pagantis_settings'); |
42 | 42 | $this->extraConfig = WC_Pagantis_Config::getExtraConfig(); |
43 | 43 | $this->allowed_currencies = array('EUR'); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | if (!pg_wc_is_screen_correct()) { |
56 | 56 | return; |
57 | 57 | } |
58 | - if ($this->settings['enabled'] !== 'yes') { |
|
58 | + if ($this->settings['enabled']!=='yes') { |
|
59 | 59 | WC_Admin_Notices::add_custom_notice( |
60 | 60 | PAGANTIS_PLUGIN_ID, |
61 | 61 | sprintf( |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | ); |
67 | 67 | } |
68 | 68 | |
69 | - if ($this->settings['pagantis_public_key'] === '' xor $this->settings['pagantis_private_key'] === '' |
|
70 | - || $this->settings['enabled'] === 'yes' |
|
69 | + if ($this->settings['pagantis_public_key']==='' xor $this->settings['pagantis_private_key']==='' |
|
70 | + || $this->settings['enabled']==='yes' |
|
71 | 71 | ) { |
72 | 72 | WC_Admin_Notices::add_custom_notice( |
73 | 73 | PAGANTIS_PLUGIN_ID.'keys_setup', |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | |
83 | - if ($this->settings['pagantis_public_key'] === '' xor $this->settings['pagantis_private_key'] === '') { |
|
83 | + if ($this->settings['pagantis_public_key']==='' xor $this->settings['pagantis_private_key']==='') { |
|
84 | 84 | WC_Admin_Notices::add_custom_notice( |
85 | 85 | PAGANTIS_PLUGIN_ID, |
86 | 86 | sprintf( |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | ); |
92 | 92 | } |
93 | 93 | |
94 | - if ($this->settings['pagantis_public_key'] === '' || $this->settings['pagantis_private_key'] === '') { |
|
94 | + if ($this->settings['pagantis_public_key']==='' || $this->settings['pagantis_private_key']==='') { |
|
95 | 95 | WC_Admin_Notices::add_custom_notice( |
96 | 96 | PAGANTIS_PLUGIN_ID.'keys_error', |
97 | 97 | sprintf( |
@@ -102,15 +102,15 @@ discard block |
||
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
105 | - if ($this->settings['pagantis_public_key'] !== '' xor $this->settings['pagantis_private_key'] !== '') { |
|
105 | + if ($this->settings['pagantis_public_key']!=='' xor $this->settings['pagantis_private_key']!=='') { |
|
106 | 106 | WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID.'keys_setup'); |
107 | 107 | } |
108 | 108 | |
109 | - if ($this->settings['pagantis_public_key'] !== '' || $this->settings['pagantis_private_key'] !== '') { |
|
109 | + if ($this->settings['pagantis_public_key']!=='' || $this->settings['pagantis_private_key']!=='') { |
|
110 | 110 | WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID.'keys_error'); |
111 | 111 | } |
112 | 112 | |
113 | - if (! in_array(get_woocommerce_currency(), $this->allowed_currencies, true)) { |
|
113 | + if (!in_array(get_woocommerce_currency(), $this->allowed_currencies, true)) { |
|
114 | 114 | WC_Admin_Settings::add_error(__('Error: Pagantis only can be used in Euros.', 'pagantis')); |
115 | 115 | $this->settings['enabled'] = 'no'; |
116 | 116 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | include_once('class-wc-pagantis-logger.php'); |
17 | 17 | $config = self::getExtraConfig(); |
18 | 18 | $value = $config[$key]; |
19 | - if ($unSerialized === true) { |
|
19 | + if ($unSerialized===true) { |
|
20 | 20 | return unserialize($value); |
21 | 21 | } else { |
22 | 22 | return $value; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | public static function getExtraConfig() |
63 | 63 | { |
64 | 64 | global $wpdb; |
65 | - $tableName = $wpdb->prefix . PAGANTIS_CONFIG_TABLE; |
|
65 | + $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE; |
|
66 | 66 | $response = array(); |
67 | 67 | $dbResult = $wpdb->get_results("select config, value from $tableName", ARRAY_A); |
68 | 68 | foreach ($dbResult as $value) { |
@@ -3,12 +3,12 @@ discard block |
||
3 | 3 | |
4 | 4 | use Pagantis\ModuleUtils\Model\Log\LogEntry; |
5 | 5 | |
6 | -require_once dirname(__FILE__) . '/class-wc-pagantis-config.php'; |
|
6 | +require_once dirname(__FILE__).'/class-wc-pagantis-config.php'; |
|
7 | 7 | |
8 | 8 | function pg_areKeysSet() |
9 | 9 | { |
10 | 10 | $settings = pg_get_plugin_settings(); |
11 | - if ($settings['pagantis_public_key'] == '' || $settings['pagantis_private_key'] == '') { |
|
11 | + if ($settings['pagantis_public_key']=='' || $settings['pagantis_private_key']=='') { |
|
12 | 12 | return false; |
13 | 13 | } |
14 | 14 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | { |
20 | 20 | $settings = pg_get_plugin_settings(); |
21 | 21 | |
22 | - if ($settings['simulator'] !== 'yes') { |
|
22 | + if ($settings['simulator']!=='yes') { |
|
23 | 23 | WC_Admin_Settings::add_error(__('Error: PG Simulator is not enabled', 'pagantis')); |
24 | 24 | |
25 | 25 | return false; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $allowedCountries = WC_Pagantis_Config::getAllowedCountriesSerialized(); |
35 | 35 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
36 | 36 | |
37 | - if (! $allowedCountry) { |
|
37 | + if (!$allowedCountry) { |
|
38 | 38 | return false; |
39 | 39 | } |
40 | 40 | |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | $minAmount = WC_Pagantis_Config::getValueOfKey('PAGANTIS_DISPLAY_MIN_AMOUNT'); |
51 | 51 | $maxAmount = WC_Pagantis_Config::getValueOfKey('PAGANTIS_DISPLAY_MAX_AMOUNT'); |
52 | 52 | $totalPrice = $product->get_price(); |
53 | - $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount == '0')); |
|
54 | - if (! $validAmount) { |
|
53 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
54 | + if (!$validAmount) { |
|
55 | 55 | return false; |
56 | 56 | } |
57 | 57 | |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | $minAmount = WC_Pagantis_Config::getValueOfKey('PAGANTIS_DISPLAY_MIN_AMOUNT'); |
84 | 84 | $maxAmount = WC_Pagantis_Config::getValueOfKey('PAGANTIS_DISPLAY_MAX_AMOUNT'); |
85 | 85 | $totalPrice = $product->get_price(); |
86 | - $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount == '0')); |
|
87 | - if ($settings['enabled'] !== 'yes' || pg_areKeysSet() || pg_isSimulatorSettingEnabled() |
|
88 | - || ! pg_IsCountryAllowed() |
|
89 | - || ! pg_IsAmountValid() |
|
86 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
87 | + if ($settings['enabled']!=='yes' || pg_areKeysSet() || pg_isSimulatorSettingEnabled() |
|
88 | + || !pg_IsCountryAllowed() |
|
89 | + || !pg_IsAmountValid() |
|
90 | 90 | ) { |
91 | 91 | return; |
92 | 92 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $metaProduct = get_post_meta($product_id); |
103 | 103 | |
104 | 104 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) |
105 | - && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
105 | + && $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | */ |
125 | 125 | function preparePriceSelector($css_price_selector) |
126 | 126 | { |
127 | - if ($css_price_selector === 'default' || $css_price_selector === '') { |
|
128 | - $css_price_selector === $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
|
129 | - } elseif (! unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
|
127 | + if ($css_price_selector==='default' || $css_price_selector==='') { |
|
128 | + $css_price_selector===$this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
|
129 | + } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
|
130 | 130 | $css_price_selector = serialize(array($css_price_selector)); |
131 | 131 | } |
132 | 132 | |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | function pg_wc_is_screen_correct() |
137 | 137 | { |
138 | 138 | $current_screen = get_current_screen(); |
139 | - if ('shop_order' === $current_screen->id || 'plugins' === $current_screen->id |
|
140 | - || 'woocommerce_page_wc-settings' === $current_screen->id |
|
139 | + if ('shop_order'===$current_screen->id || 'plugins'===$current_screen->id |
|
140 | + || 'woocommerce_page_wc-settings'===$current_screen->id |
|
141 | 141 | ) { |
142 | 142 | return true; |
143 | 143 | } |
@@ -157,12 +157,12 @@ discard block |
||
157 | 157 | function pg_wc_check_db_log_table() |
158 | 158 | { |
159 | 159 | global $wpdb; |
160 | - $tableName = $wpdb->prefix . PAGANTIS_LOGS_TABLE; |
|
161 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") !== $tableName) { |
|
160 | + $tableName = $wpdb->prefix.PAGANTIS_LOGS_TABLE; |
|
161 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!==$tableName) { |
|
162 | 162 | $charset_collate = $wpdb->get_charset_collate(); |
163 | 163 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
164 | 164 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
165 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
165 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
166 | 166 | dbDelta($sql); |
167 | 167 | } |
168 | 168 | |
@@ -180,5 +180,5 @@ discard block |
||
180 | 180 | { |
181 | 181 | $shop_page = wc_get_page_permalink('shop'); |
182 | 182 | |
183 | - return (is_ssl() && 'https' === substr($shop_page, 0, 5)); |
|
183 | + return (is_ssl() && 'https'===substr($shop_page, 0, 5)); |
|
184 | 184 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public static function writeLog($message, $start_time = null, $end_time = null) |
24 | 24 | { |
25 | - if (! class_exists('WC_Logger')) { |
|
25 | + if (!class_exists('WC_Logger')) { |
|
26 | 26 | return; |
27 | 27 | } |
28 | 28 | |
@@ -31,31 +31,31 @@ discard block |
||
31 | 31 | self::$logger = wc_get_logger(); |
32 | 32 | } |
33 | 33 | |
34 | - $isDebugLogEnabled = 'yes' === WC_Admin_Settings::get_option('debug', 'no'); |
|
34 | + $isDebugLogEnabled = 'yes'===WC_Admin_Settings::get_option('debug', 'no'); |
|
35 | 35 | $settings = get_option('woocommerce_pagantis_settings'); |
36 | 36 | |
37 | 37 | if (empty($settings) || isset($settings['debug']) && $isDebugLogEnabled) { |
38 | 38 | return; |
39 | 39 | } |
40 | 40 | |
41 | - if (! is_null($start_time)) { |
|
42 | - $formatted_start_time = date_i18n(get_option('date_format') . ' g:ia', $start_time); |
|
41 | + if (!is_null($start_time)) { |
|
42 | + $formatted_start_time = date_i18n(get_option('date_format').' g:ia', $start_time); |
|
43 | 43 | $end_time = is_null($end_time) ? current_time('timestamp') : $end_time; |
44 | - $formatted_end_time = date_i18n(get_option('date_format') . ' g:ia', $end_time); |
|
44 | + $formatted_end_time = date_i18n(get_option('date_format').' g:ia', $end_time); |
|
45 | 45 | $elapsed_time = round(abs($end_time - $start_time) / 60, 2); |
46 | 46 | |
47 | - $log_entry = "\n" . '====Pagantis Version: ' . PAGANTIS_VERSION . '====' . "\n"; |
|
48 | - $log_entry .= '====Start Log ' . $formatted_start_time . '====' . "\n" . $message . "\n"; |
|
49 | - $log_entry .= '====End Log ' . $formatted_end_time . ' (' . $elapsed_time . ')====' . "\n\n"; |
|
47 | + $log_entry = "\n".'====Pagantis Version: '.PAGANTIS_VERSION.'===='."\n"; |
|
48 | + $log_entry .= '====Start Log '.$formatted_start_time.'===='."\n".$message."\n"; |
|
49 | + $log_entry .= '====End Log '.$formatted_end_time.' ('.$elapsed_time.')===='."\n\n"; |
|
50 | 50 | } else { |
51 | - $log_entry = "\n" . '====Pagantis Version: ' . PAGANTIS_VERSION . '====' . "\n"; |
|
52 | - $log_entry .= '====Start Log====' . "\n" . $message . "\n" . '====End Log====' . "\n\n"; |
|
51 | + $log_entry = "\n".'====Pagantis Version: '.PAGANTIS_VERSION.'===='."\n"; |
|
52 | + $log_entry .= '====Start Log===='."\n".$message."\n".'====End Log===='."\n\n"; |
|
53 | 53 | } |
54 | 54 | if (defined('WP_DEBUG') && WP_DEBUG) { |
55 | 55 | error_log($log_entry); |
56 | 56 | } |
57 | 57 | print_r($log_entry); |
58 | - self::$logger->debug($log_entry, array( 'source' => self::WC_LOG_FILENAME )); |
|
58 | + self::$logger->debug($log_entry, array('source' => self::WC_LOG_FILENAME)); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | } else { |
88 | 88 | $logEntry = $logEntry->info($message); |
89 | 89 | } |
90 | - $tableName = $wpdb->prefix . PAGANTIS_LOGS_TABLE; |
|
90 | + $tableName = $wpdb->prefix.PAGANTIS_LOGS_TABLE; |
|
91 | 91 | $wpdb->insert($tableName, array('log' => $logEntry->toJson())); |
92 | 92 | } |
93 | 93 | } |
@@ -241,17 +241,17 @@ discard block |
||
241 | 241 | ->setAddress($shippingAddress['address_1'] . ' ' . $shippingAddress['address_2']); |
242 | 242 | $orderShippingAddress = new Address(); |
243 | 243 | $orderShippingAddress->setZipCode($shippingAddress['postcode'])->setFullName($shippingAddress['first_name'] |
244 | - . ' ' |
|
244 | + . ' ' |
|
245 | 245 | . $shippingAddress['last_name']) |
246 | 246 | ->setCountryCode($shippingAddress['country'] !== '' |
247 | 247 | ? strtoupper($shippingAddress['country']) : strtoupper($this->language)) |
248 | 248 | ->setCity($shippingAddress['city'])->setAddress($shippingAddress['address_1'] . ' ' |
249 | 249 | . $shippingAddress['address_2']) |
250 | - ->setFixPhone($shippingAddress['phone'])->setMobilePhone($shippingAddress['phone']) |
|
251 | - ->setNationalId($national_id)->setTaxId($tax_id); |
|
250 | + ->setFixPhone($shippingAddress['phone'])->setMobilePhone($shippingAddress['phone']) |
|
251 | + ->setNationalId($national_id)->setTaxId($tax_id); |
|
252 | 252 | $orderBillingAddress = new Address(); |
253 | 253 | $orderBillingAddress->setZipCode($billingAddress['postcode'])->setFullName($billingAddress['first_name'] |
254 | - . ' ' |
|
254 | + . ' ' |
|
255 | 255 | . $billingAddress['last_name']) |
256 | 256 | ->setCountryCode($billingAddress['country'] !== '' |
257 | 257 | ? strtoupper($billingAddress['country']) : strtoupper($this->language)) |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | $orderUser = new User(); |
263 | 263 | $orderUser->setAddress($userAddress)->setFullName($billingAddress['first_name'] . ' ' |
264 | 264 | . $billingAddress['last_name']) |
265 | - ->setBillingAddress($orderBillingAddress)->setEmail($billingAddress['email']) |
|
266 | - ->setFixPhone($billingAddress['phone'])->setMobilePhone($billingAddress['phone']) |
|
267 | - ->setShippingAddress($orderShippingAddress)->setNationalId($national_id)->setTaxId($tax_id); |
|
265 | + ->setBillingAddress($orderBillingAddress)->setEmail($billingAddress['email']) |
|
266 | + ->setFixPhone($billingAddress['phone'])->setMobilePhone($billingAddress['phone']) |
|
267 | + ->setShippingAddress($orderShippingAddress)->setNationalId($national_id)->setTaxId($tax_id); |
|
268 | 268 | |
269 | 269 | $previousOrders = $this->getOrders($order->get_user(), $billingAddress['email']); |
270 | 270 | foreach ($previousOrders as $previousOrder) { |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $orderElement = wc_get_order($previousOrder); |
273 | 273 | $orderCreated = $orderElement->get_date_created(); |
274 | 274 | $orderHistory->setAmount(intval(100 * $orderElement->get_total())) |
275 | - ->setDate(new \DateTime($orderCreated->date('Y-m-d H:i:s'))); |
|
275 | + ->setDate(new \DateTime($orderCreated->date('Y-m-d H:i:s'))); |
|
276 | 276 | $orderUser->addOrderHistory($orderHistory); |
277 | 277 | } |
278 | 278 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | |
322 | 322 | $orderShoppingCart = new ShoppingCart(); |
323 | 323 | $orderShoppingCart->setDetails($details)->setOrderReference($order->get_id()) |
324 | - ->setPromotedAmount($promotedAmount)->setTotalAmount(intval(strval(100 * $order->total))); |
|
324 | + ->setPromotedAmount($promotedAmount)->setTotalAmount(intval(strval(100 * $order->total))); |
|
325 | 325 | $orderConfigurationUrls = new Urls(); |
326 | 326 | $cancelUrl = $this->getKoUrl($order); |
327 | 327 | $callback_arg = array( |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | $callback_url_notif = add_query_arg($callback_arg_notif, home_url('/')); |
341 | 341 | |
342 | 342 | $orderConfigurationUrls->setCancel($cancelUrl)->setKo($callback_url_user) |
343 | - ->setAuthorizedNotificationCallback($callback_url_notif) |
|
344 | - ->setRejectedNotificationCallback(null)->setOk($callback_url_user); |
|
343 | + ->setAuthorizedNotificationCallback($callback_url_notif) |
|
344 | + ->setRejectedNotificationCallback(null)->setOk($callback_url_user); |
|
345 | 345 | $orderChannel = new Channel(); |
346 | 346 | $orderChannel->setAssistedSale(false)->setType(Channel::ONLINE); |
347 | 347 | |
@@ -355,11 +355,11 @@ discard block |
||
355 | 355 | |
356 | 356 | $orderConfiguration = new Configuration(); |
357 | 357 | $orderConfiguration->setChannel($orderChannel)->setUrls($orderConfigurationUrls) |
358 | - ->setPurchaseCountry($purchaseCountry); |
|
358 | + ->setPurchaseCountry($purchaseCountry); |
|
359 | 359 | |
360 | 360 | $orderApiClient = new Order(); |
361 | 361 | $orderApiClient->setConfiguration($orderConfiguration)->setMetadata($metadataOrder) |
362 | - ->setShoppingCart($orderShoppingCart)->setUser($orderUser); |
|
362 | + ->setShoppingCart($orderShoppingCart)->setUser($orderUser); |
|
363 | 363 | |
364 | 364 | if ($this->pagantis_public_key === '' || $this->pagantis_private_key === '') { |
365 | 365 | throw new \Exception('Public and Secret Key not found'); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | use Pagantis\OrdersApiClient\Model\Order; |
17 | 17 | use Pagantis\ModuleUtils\Model\Log\LogEntry; |
18 | 18 | |
19 | -if (! defined('ABSPATH')) { |
|
19 | +if (!defined('ABSPATH')) { |
|
20 | 20 | exit; |
21 | 21 | } |
22 | 22 | |
@@ -54,19 +54,19 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function __construct() |
56 | 56 | { |
57 | - require_once dirname(__FILE__) . '/../includes/class-wc-pagantis-config.php'; |
|
58 | - require_once dirname(__FILE__) . '/../includes/class-wc-pagantis-logger.php'; |
|
59 | - require_once dirname(__FILE__) . '/../includes/functions.php'; |
|
57 | + require_once dirname(__FILE__).'/../includes/class-wc-pagantis-config.php'; |
|
58 | + require_once dirname(__FILE__).'/../includes/class-wc-pagantis-logger.php'; |
|
59 | + require_once dirname(__FILE__).'/../includes/functions.php'; |
|
60 | 60 | //Mandatory vars for plugin |
61 | 61 | $this->id = PAGANTIS_PLUGIN_ID; |
62 | 62 | $this->has_fields = true; |
63 | 63 | $this->method_title = ucfirst($this->id); |
64 | 64 | //Useful vars |
65 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/'; |
|
65 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/'; |
|
66 | 66 | |
67 | 67 | $this->allowed_currencies = array('EUR'); |
68 | 68 | $this->language = strstr(get_locale(), '_', true); |
69 | - if ($this->language === '') { |
|
69 | + if ($this->language==='') { |
|
70 | 70 | $this->language = 'ES'; |
71 | 71 | } |
72 | 72 | $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
@@ -84,18 +84,18 @@ discard block |
||
84 | 84 | $this->set_payment_urls(); |
85 | 85 | //Hooks |
86 | 86 | add_action( |
87 | - 'woocommerce_update_options_payment_gateways_' . $this->id, |
|
87 | + 'woocommerce_update_options_payment_gateways_'.$this->id, |
|
88 | 88 | array($this, 'process_admin_options') |
89 | 89 | ); //Save plugin options |
90 | 90 | add_action( |
91 | 91 | 'admin_notices', |
92 | 92 | array($this, 'check_plugin_settings') |
93 | - ); //Check config fields |
|
93 | + ); //Check config fields |
|
94 | 94 | add_action( |
95 | - 'woocommerce_receipt_' . $this->id, |
|
95 | + 'woocommerce_receipt_'.$this->id, |
|
96 | 96 | array($this, 'get_wc_order_received_page') |
97 | - ); //Pagantis form |
|
98 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
97 | + ); //Pagantis form |
|
98 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
99 | 99 | add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3); |
100 | 100 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
101 | 101 | //add_action('wp_enqueue_scripts', array($this, 'enqueue_ajax_scripts')); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | public function enqueue_ajax_scripts() |
105 | 105 | { |
106 | - if ($this->enabled !== 'yes' || ! is_checkout() || is_order_received_page() |
|
106 | + if ($this->enabled!=='yes' || !is_checkout() || is_order_received_page() |
|
107 | 107 | || is_wc_endpoint_url('order-pay') |
108 | 108 | ) { |
109 | 109 | return; |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function loadPagantisTranslation($mofile, $domain) |
140 | 140 | { |
141 | - if ('pagantis' === $domain) { |
|
142 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
141 | + if ('pagantis'===$domain) { |
|
142 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | return $mofile; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function init_form_fields() |
154 | 154 | { |
155 | - $this->form_fields = include(plugin_dir_path(__FILE__) . '../includes/settings-pagantis.php'); |
|
155 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /*********** |
@@ -168,13 +168,13 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function check_plugin_settings() |
170 | 170 | { |
171 | - if (! pg_wc_is_screen_correct()) { |
|
171 | + if (!pg_wc_is_screen_correct()) { |
|
172 | 172 | return; |
173 | 173 | } |
174 | 174 | |
175 | - if ($this->settings['enabled'] !== 'yes') { |
|
175 | + if ($this->settings['enabled']!=='yes') { |
|
176 | 176 | WC_Admin_Notices::add_custom_notice( |
177 | - PAGANTIS_PLUGIN_ID . 'first_setup', |
|
177 | + PAGANTIS_PLUGIN_ID.'first_setup', |
|
178 | 178 | sprintf(// translators: 1: URL to WP plugin page. |
179 | 179 | __( |
180 | 180 | 'Activate Pagantis to start offering comfortable payments in installments to your clients. <a class="button button-primary" href="%1$s">Activate Pagantis now!</a>', |
@@ -184,15 +184,15 @@ discard block |
||
184 | 184 | ) |
185 | 185 | ); |
186 | 186 | } |
187 | - if (WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID . 'first_setup') && $this->settings['enabled'] === 'yes') { |
|
188 | - WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID . 'first_setup'); |
|
187 | + if (WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID.'first_setup') && $this->settings['enabled']==='yes') { |
|
188 | + WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID.'first_setup'); |
|
189 | 189 | } |
190 | 190 | |
191 | - if ($this->settings['pagantis_public_key'] === '' xor $this->settings['pagantis_private_key'] === '' |
|
192 | - && $this->settings['enabled'] === 'yes' |
|
191 | + if ($this->settings['pagantis_public_key']==='' xor $this->settings['pagantis_private_key']==='' |
|
192 | + && $this->settings['enabled']==='yes' |
|
193 | 193 | ) { |
194 | 194 | WC_Admin_Notices::add_custom_notice( |
195 | - PAGANTIS_PLUGIN_ID . 'keys_setup', |
|
195 | + PAGANTIS_PLUGIN_ID.'keys_setup', |
|
196 | 196 | sprintf(// translators: 1: URL to WP plugin page. |
197 | 197 | __( |
198 | 198 | 'Set your Pagantis merchant keys to start offering comfortable payments in installments <a class="button button-primary" href="%1$s">Go to keys setup</a></p>', |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | ); |
204 | 204 | } |
205 | 205 | |
206 | - if ($this->settings['pagantis_public_key'] === '' xor $this->settings['pagantis_private_key'] === '' |
|
207 | - || $this->settings['enabled'] === 'yes' |
|
206 | + if ($this->settings['pagantis_public_key']==='' xor $this->settings['pagantis_private_key']==='' |
|
207 | + || $this->settings['enabled']==='yes' |
|
208 | 208 | ) { |
209 | 209 | WC_Admin_Notices::add_custom_notice( |
210 | - PAGANTIS_PLUGIN_ID . 'keys_check', |
|
210 | + PAGANTIS_PLUGIN_ID.'keys_check', |
|
211 | 211 | sprintf(// translators: 1: URL to WP plugin page. |
212 | 212 | __( |
213 | 213 | 'Set your Pagantis merchant Api keys to start offering comfortable payments in installments. <a class="button button-primary" href="%1$s">Go to keys setup</a>', |
@@ -218,11 +218,11 @@ discard block |
||
218 | 218 | ); |
219 | 219 | } |
220 | 220 | |
221 | - if ($this->settings['pagantis_public_key'] !== '' && $this->settings['pagantis_private_key'] !== '' |
|
222 | - || $this->settings['enabled'] === 'no' |
|
221 | + if ($this->settings['pagantis_public_key']!=='' && $this->settings['pagantis_private_key']!=='' |
|
222 | + || $this->settings['enabled']==='no' |
|
223 | 223 | ) { |
224 | 224 | WC_Admin_Notices::add_custom_notice( |
225 | - PAGANTIS_PLUGIN_ID . 'finish_setup', |
|
225 | + PAGANTIS_PLUGIN_ID.'finish_setup', |
|
226 | 226 | sprintf(// translators: 1: URL to WP plugin page. |
227 | 227 | __( |
228 | 228 | 'It seems that your merchant keys are setup but the plugin is not active Activate the Pagantis plugin to start offering comfortable payments in installments to your clients. <a class="button button-primary" href="%1$s">Go to Pagantis settings</a>', |
@@ -232,32 +232,32 @@ discard block |
||
232 | 232 | ) |
233 | 233 | ); |
234 | 234 | } |
235 | - if (WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID . 'keys_check' |
|
236 | - && $this->settings['pagantis_public_key'] !== '' |
|
237 | - && $this->settings['pagantis_private_key'] !== '' |
|
238 | - && $this->settings['enabled'] === 'yes') |
|
235 | + if (WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID.'keys_check' |
|
236 | + && $this->settings['pagantis_public_key']!=='' |
|
237 | + && $this->settings['pagantis_private_key']!=='' |
|
238 | + && $this->settings['enabled']==='yes') |
|
239 | 239 | ) { |
240 | - WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID . 'keys_setup'); |
|
240 | + WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID.'keys_setup'); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
244 | - if (WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID . 'first_setup' |
|
245 | - && $this->settings['pagantis_public_key'] === '' |
|
246 | - && $this->settings['pagantis_private_key'] === '') |
|
244 | + if (WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID.'first_setup' |
|
245 | + && $this->settings['pagantis_public_key']==='' |
|
246 | + && $this->settings['pagantis_private_key']==='') |
|
247 | 247 | ) { |
248 | - WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID . 'keys_setup'); |
|
248 | + WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID.'keys_setup'); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | |
252 | - if (WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID . 'keys_check') xor WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID . 'first_setup') |
|
253 | - && $this->settings['pagantis_public_key'] !== '' |
|
254 | - || $this->settings['pagantis_private_key'] !== '' |
|
252 | + if (WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID.'keys_check') xor WC_Admin_Notices::has_notice(PAGANTIS_PLUGIN_ID.'first_setup') |
|
253 | + && $this->settings['pagantis_public_key']!=='' |
|
254 | + || $this->settings['pagantis_private_key']!=='' |
|
255 | 255 | ) { |
256 | - WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID . 'first_setup'); |
|
257 | - WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID . 'keys_check'); |
|
256 | + WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID.'first_setup'); |
|
257 | + WC_Admin_Notices::remove_notice(PAGANTIS_PLUGIN_ID.'keys_check'); |
|
258 | 258 | } |
259 | 259 | |
260 | - if (! in_array(get_woocommerce_currency(), $this->allowed_currencies, true)) { |
|
260 | + if (!in_array(get_woocommerce_currency(), $this->allowed_currencies, true)) { |
|
261 | 261 | WC_Admin_Settings::add_error(__('Error: Pagantis only can be used in Euros.', 'pagantis')); |
262 | 262 | $this->settings['enabled'] = 'no'; |
263 | 263 | } |
@@ -344,19 +344,19 @@ discard block |
||
344 | 344 | public function get_wc_order_received_page($order_id) |
345 | 345 | { |
346 | 346 | try { |
347 | - require_once(__ROOT__ . '/vendor/autoload.php'); |
|
347 | + require_once(__ROOT__.'/vendor/autoload.php'); |
|
348 | 348 | global $woocommerce; |
349 | 349 | $order = wc_get_order($order_id); |
350 | 350 | $order->set_payment_method(ucfirst($this->id)); |
351 | 351 | $order->save(); |
352 | 352 | |
353 | - if (! isset($order)) { |
|
353 | + if (!isset($order)) { |
|
354 | 354 | throw new Exception(__('Order not found', 'pagantis')); |
355 | 355 | } |
356 | 356 | |
357 | 357 | $shippingAddress = $order->get_address('shipping'); |
358 | 358 | $billingAddress = $order->get_address('billing'); |
359 | - if ($shippingAddress['address_1'] === '') { |
|
359 | + if ($shippingAddress['address_1']==='') { |
|
360 | 360 | $shippingAddress = $billingAddress; |
361 | 361 | } |
362 | 362 | |
@@ -364,18 +364,18 @@ discard block |
||
364 | 364 | $tax_id = $this->getTaxId($order); |
365 | 365 | |
366 | 366 | $userAddress = new Address(); |
367 | - $userAddress->setZipCode($shippingAddress['postcode'])->setFullName($shippingAddress['first_name'] . ' ' |
|
367 | + $userAddress->setZipCode($shippingAddress['postcode'])->setFullName($shippingAddress['first_name'].' ' |
|
368 | 368 | . $shippingAddress['last_name']) |
369 | - ->setCountryCode($shippingAddress['country'] !== '' ? strtoupper($shippingAddress['country']) |
|
369 | + ->setCountryCode($shippingAddress['country']!=='' ? strtoupper($shippingAddress['country']) |
|
370 | 370 | : strtoupper($this->language))->setCity($shippingAddress['city']) |
371 | - ->setAddress($shippingAddress['address_1'] . ' ' . $shippingAddress['address_2']); |
|
371 | + ->setAddress($shippingAddress['address_1'].' '.$shippingAddress['address_2']); |
|
372 | 372 | $orderShippingAddress = new Address(); |
373 | 373 | $orderShippingAddress->setZipCode($shippingAddress['postcode'])->setFullName($shippingAddress['first_name'] |
374 | 374 | . ' ' |
375 | 375 | . $shippingAddress['last_name']) |
376 | - ->setCountryCode($shippingAddress['country'] !== '' |
|
376 | + ->setCountryCode($shippingAddress['country']!=='' |
|
377 | 377 | ? strtoupper($shippingAddress['country']) : strtoupper($this->language)) |
378 | - ->setCity($shippingAddress['city'])->setAddress($shippingAddress['address_1'] . ' ' |
|
378 | + ->setCity($shippingAddress['city'])->setAddress($shippingAddress['address_1'].' ' |
|
379 | 379 | . $shippingAddress['address_2']) |
380 | 380 | ->setFixPhone($shippingAddress['phone'])->setMobilePhone($shippingAddress['phone']) |
381 | 381 | ->setNationalId($national_id)->setTaxId($tax_id); |
@@ -383,14 +383,14 @@ discard block |
||
383 | 383 | $orderBillingAddress->setZipCode($billingAddress['postcode'])->setFullName($billingAddress['first_name'] |
384 | 384 | . ' ' |
385 | 385 | . $billingAddress['last_name']) |
386 | - ->setCountryCode($billingAddress['country'] !== '' |
|
386 | + ->setCountryCode($billingAddress['country']!=='' |
|
387 | 387 | ? strtoupper($billingAddress['country']) : strtoupper($this->language)) |
388 | - ->setCity($billingAddress['city'])->setAddress($billingAddress['address_1'] . ' ' |
|
388 | + ->setCity($billingAddress['city'])->setAddress($billingAddress['address_1'].' ' |
|
389 | 389 | . $billingAddress['address_2']) |
390 | 390 | ->setFixPhone($billingAddress['phone'])->setMobilePhone($billingAddress['phone']) |
391 | 391 | ->setNationalId($national_id)->setTaxId($tax_id); |
392 | 392 | $orderUser = new User(); |
393 | - $orderUser->setAddress($userAddress)->setFullName($billingAddress['first_name'] . ' ' |
|
393 | + $orderUser->setAddress($userAddress)->setFullName($billingAddress['first_name'].' ' |
|
394 | 394 | . $billingAddress['last_name']) |
395 | 395 | ->setBillingAddress($orderBillingAddress)->setEmail($billingAddress['email']) |
396 | 396 | ->setFixPhone($billingAddress['phone'])->setMobilePhone($billingAddress['phone']) |
@@ -439,11 +439,11 @@ discard block |
||
439 | 439 | $details->addProduct($product); |
440 | 440 | |
441 | 441 | $promotedProduct = $this->isPromoted($item->get_product_id()); |
442 | - if ($promotedProduct === 'true') { |
|
442 | + if ($promotedProduct==='true') { |
|
443 | 443 | $promotedAmount += $product->getAmount(); |
444 | 444 | $promotedMessage = |
445 | - 'Promoted Item: ' . $wcProduct->get_name() . ' - Price: ' . $item->get_total() . ' - Qty: ' |
|
446 | - . $product->getQuantity() . ' - Item ID: ' . $item['id_product']; |
|
445 | + 'Promoted Item: '.$wcProduct->get_name().' - Price: '.$item->get_total().' - Qty: ' |
|
446 | + . $product->getQuantity().' - Item ID: '.$item['id_product']; |
|
447 | 447 | $promotedMessage = substr($promotedMessage, 0, 999); |
448 | 448 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
449 | 449 | } |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | $orderApiClient->setConfiguration($orderConfiguration)->setMetadata($metadataOrder) |
494 | 494 | ->setShoppingCart($orderShoppingCart)->setUser($orderUser); |
495 | 495 | |
496 | - if ($this->pagantis_public_key === '' || $this->pagantis_private_key === '') { |
|
496 | + if ($this->pagantis_public_key==='' || $this->pagantis_private_key==='') { |
|
497 | 497 | throw new \Exception('Public and Secret Key not found'); |
498 | 498 | } |
499 | 499 | $orderClient = new Client($this->pagantis_public_key, $this->pagantis_private_key); |
@@ -505,9 +505,9 @@ discard block |
||
505 | 505 | throw new OrderNotFoundException(); |
506 | 506 | } |
507 | 507 | |
508 | - if ($url === '') { |
|
508 | + if ($url==='') { |
|
509 | 509 | throw new Exception(__('No ha sido posible obtener una respuesta de Pagantis', 'pagantis')); |
510 | - } elseif ($this->extraConfig['PAGANTIS_FORM_DISPLAY_TYPE'] === '0') { |
|
510 | + } elseif ($this->extraConfig['PAGANTIS_FORM_DISPLAY_TYPE']==='0') { |
|
511 | 511 | wp_redirect($url); |
512 | 512 | exit; |
513 | 513 | } else { |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | wc_get_template('iframe.php', $template_fields, '', $this->template_path); |
519 | 519 | } |
520 | 520 | } catch (\Exception $exception) { |
521 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); |
|
521 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); |
|
522 | 522 | WC_Pagantis_Logger::insert_log_entry_in_wpdb($exception); |
523 | 523 | $checkout_url = get_permalink(wc_get_page_id('checkout')); |
524 | 524 | wp_redirect($checkout_url); |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | public function pagantisNotification() |
533 | 533 | { |
534 | 534 | try { |
535 | - $origin = ($_SERVER['REQUEST_METHOD'] === 'POST') ? 'Notify' : 'Order'; |
|
535 | + $origin = ($_SERVER['REQUEST_METHOD']==='POST') ? 'Notify' : 'Order'; |
|
536 | 536 | |
537 | 537 | include_once('class-pg-notification-handler.php'); |
538 | 538 | $notify = new WC_PG_Notification_Handler(); |
@@ -575,10 +575,10 @@ discard block |
||
575 | 575 | */ |
576 | 576 | public function pagantisCompleteStatus($status, $order_id, $order) |
577 | 577 | { |
578 | - if ($order->get_payment_method() === PAGANTIS_PLUGIN_ID) { |
|
579 | - if ($order->get_status() === 'failed') { |
|
578 | + if ($order->get_payment_method()===PAGANTIS_PLUGIN_ID) { |
|
579 | + if ($order->get_status()==='failed') { |
|
580 | 580 | $status = 'processing'; |
581 | - } elseif ($order->get_status() === 'pending' && $status === 'completed') { |
|
581 | + } elseif ($order->get_status()==='pending' && $status==='completed') { |
|
582 | 582 | $status = 'processing'; |
583 | 583 | } |
584 | 584 | } |
@@ -603,8 +603,8 @@ discard block |
||
603 | 603 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
604 | 604 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
605 | 605 | $totalPrice = (int) $this->get_order_total(); |
606 | - $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount === '0')); |
|
607 | - if ($this->enabled === 'yes' && $this->pagantis_public_key !== '' && $this->pagantis_private_key !== '' |
|
606 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount==='0')); |
|
607 | + if ($this->enabled==='yes' && $this->pagantis_public_key!=='' && $this->pagantis_private_key!=='' |
|
608 | 608 | && $validAmount |
609 | 609 | && $allowedCountry |
610 | 610 | ) { |
@@ -637,8 +637,8 @@ discard block |
||
637 | 637 | $order = new WC_Order($order_id); |
638 | 638 | |
639 | 639 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
640 | - if (strpos($redirectUrl, 'order-pay=') === false) { |
|
641 | - $redirectUrl .= '&order-pay=' . $order_id; |
|
640 | + if (strpos($redirectUrl, 'order-pay=')===false) { |
|
641 | + $redirectUrl .= '&order-pay='.$order_id; |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | return array( |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | 'redirect' => $redirectUrl, |
647 | 647 | ); |
648 | 648 | } catch (Exception $e) { |
649 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); |
|
649 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); |
|
650 | 650 | |
651 | 651 | return array(); |
652 | 652 | } |
@@ -696,10 +696,10 @@ discard block |
||
696 | 696 | private function set_payment_urls() |
697 | 697 | { |
698 | 698 | $this->settings['ok_url'] = |
699 | - ($this->extraConfig['PAGANTIS_URL_OK'] !== '') ? $this->extraConfig['PAGANTIS_URL_OK'] |
|
699 | + ($this->extraConfig['PAGANTIS_URL_OK']!=='') ? $this->extraConfig['PAGANTIS_URL_OK'] |
|
700 | 700 | : $this->generateOkUrl(); |
701 | 701 | $this->settings['ko_url'] = |
702 | - ($this->extraConfig['PAGANTIS_URL_KO'] !== '') ? $this->extraConfig['PAGANTIS_URL_KO'] |
|
702 | + ($this->extraConfig['PAGANTIS_URL_KO']!=='') ? $this->extraConfig['PAGANTIS_URL_KO'] |
|
703 | 703 | : $this->generateKoUrl(); |
704 | 704 | foreach ($this->settings as $setting_key => $setting_value) { |
705 | 705 | $this->$setting_key = $setting_value; |
@@ -733,12 +733,12 @@ discard block |
||
733 | 733 | private function generateUrl($url) |
734 | 734 | { |
735 | 735 | $parsed_url = parse_url($url); |
736 | - if ($parsed_url !== false) { |
|
737 | - $parsed_url['query'] = ! isset($parsed_url['query']) ? '' : $parsed_url['query']; |
|
736 | + if ($parsed_url!==false) { |
|
737 | + $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
|
738 | 738 | parse_str($parsed_url['query'], $arrayParams); |
739 | 739 | foreach ($arrayParams as $keyParam => $valueParam) { |
740 | - if ($valueParam === '') { |
|
741 | - $arrayParams[$keyParam] = '{{' . $keyParam . '}}'; |
|
740 | + if ($valueParam==='') { |
|
741 | + $arrayParams[$keyParam] = '{{'.$keyParam.'}}'; |
|
742 | 742 | } |
743 | 743 | } |
744 | 744 | $parsed_url['query'] = http_build_query($arrayParams); |
@@ -784,13 +784,13 @@ discard block |
||
784 | 784 | */ |
785 | 785 | private function getKeysUrl($order, $url) |
786 | 786 | { |
787 | - $defaultFields = (get_class($order) === 'WC_Order') ? array( |
|
787 | + $defaultFields = (get_class($order)==='WC_Order') ? array( |
|
788 | 788 | 'order-received' => $order->get_id(), |
789 | 789 | 'key' => $order->get_order_key() |
790 | 790 | ) : array(); |
791 | 791 | |
792 | 792 | $parsedUrl = parse_url($url); |
793 | - if ($parsedUrl !== false) { |
|
793 | + if ($parsedUrl!==false) { |
|
794 | 794 | //Replace parameters from url |
795 | 795 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
796 | 796 | |
@@ -858,14 +858,14 @@ discard block |
||
858 | 858 | */ |
859 | 859 | private function get_unparsed_url($parsed_url) |
860 | 860 | { |
861 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
861 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
862 | 862 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
863 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
864 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
865 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
863 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
864 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
865 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
866 | 866 | $path = $parsed_url['path']; |
867 | 867 | |
868 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
868 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
869 | 869 | } |
870 | 870 | |
871 | 871 | /** |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
905 | 905 | )); |
906 | 906 | foreach ($customer_orders as $customer_order) { |
907 | - if (trim($sign_up) === '' |
|
907 | + if (trim($sign_up)==='' |
|
908 | 908 | || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up) |
909 | 909 | ) { |
910 | 910 | $sign_up = substr($customer_order->post_date, 0, 10); |
@@ -928,12 +928,12 @@ discard block |
||
928 | 928 | { |
929 | 929 | global $wpdb; |
930 | 930 | $this->check_if_wc_orders_db_table_exist(); |
931 | - $tableName = $wpdb->prefix . PAGANTIS_WC_ORDERS_TABLE; |
|
931 | + $tableName = $wpdb->prefix.PAGANTIS_WC_ORDERS_TABLE; |
|
932 | 932 | |
933 | 933 | //Check if id exists |
934 | 934 | $resultsSelect = $wpdb->get_results("SELECT * FROM $tableName WHERE id='$wc_order_id'"); |
935 | 935 | $countResults = count($resultsSelect); |
936 | - if ($countResults === 0) { |
|
936 | + if ($countResults===0) { |
|
937 | 937 | $wpdb->insert($tableName, array('id' => $wc_order_id, 'order_id' => $pg_order_id), array('%d', '%s')); |
938 | 938 | } else { |
939 | 939 | $wpdb->update( |
@@ -954,14 +954,14 @@ discard block |
||
954 | 954 | private function check_if_wc_orders_db_table_exist() |
955 | 955 | { |
956 | 956 | global $wpdb; |
957 | - $tableName = $wpdb->prefix . PAGANTIS_WC_ORDERS_TABLE; |
|
957 | + $tableName = $wpdb->prefix.PAGANTIS_WC_ORDERS_TABLE; |
|
958 | 958 | |
959 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") !== $tableName) { |
|
959 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!==$tableName) { |
|
960 | 960 | $charset_collate = $wpdb->get_charset_collate(); |
961 | 961 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
962 | 962 | UNIQUE KEY id (id)) $charset_collate"; |
963 | 963 | |
964 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
964 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
965 | 965 | dbDelta($sql); |
966 | 966 | } |
967 | 967 | } |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | { |
977 | 977 | foreach ((array) $order->get_meta_data() as $mdObject) { |
978 | 978 | $data = $mdObject->get_data(); |
979 | - if ($data['key'] === 'vat_number') { |
|
979 | + if ($data['key']==='vat_number') { |
|
980 | 980 | return $data['value']; |
981 | 981 | } |
982 | 982 | } |
@@ -993,7 +993,7 @@ discard block |
||
993 | 993 | { |
994 | 994 | foreach ((array) $order->get_meta_data() as $mdObject) { |
995 | 995 | $data = $mdObject->get_data(); |
996 | - if ($data['key'] === 'billing_cfpiva') { |
|
996 | + if ($data['key']==='billing_cfpiva') { |
|
997 | 997 | return $data['value']; |
998 | 998 | } |
999 | 999 | } |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | $metaProduct = get_post_meta($product_id); |
1038 | 1038 | |
1039 | 1039 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) |
1040 | - && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
1040 | + && $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | /** |
@@ -1050,7 +1050,7 @@ discard block |
||
1050 | 1050 | $promotedAmount = 0; |
1051 | 1051 | foreach ($items as $key => $item) { |
1052 | 1052 | $promotedProduct = $this->isPromoted($item['product_id']); |
1053 | - if ($promotedProduct === 'true') { |
|
1053 | + if ($promotedProduct==='true') { |
|
1054 | 1054 | $promotedAmount += $item['line_total'] + $item['line_tax']; |
1055 | 1055 | } |
1056 | 1056 | } |
@@ -22,58 +22,58 @@ discard block |
||
22 | 22 | class WC_PG_Notification_Handler extends WC_Pagantis_Gateway |
23 | 23 | { |
24 | 24 | /** |
25 | - * Concurrency table name |
|
26 | - */ |
|
25 | + * Concurrency table name |
|
26 | + */ |
|
27 | 27 | const CONCURRENCY_TABLE = 'pagantis_concurrency'; |
28 | 28 | |
29 | 29 | /** |
30 | - * Seconds to expire a locked request |
|
31 | - */ |
|
30 | + * Seconds to expire a locked request |
|
31 | + */ |
|
32 | 32 | const CONCURRENCY_TIMEOUT = 5; |
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Pagantis Order Number |
36 | 36 | * |
37 | - * @var mixed $pagantisOrder |
|
38 | - */ |
|
37 | + * @var mixed $pagantisOrder |
|
38 | + */ |
|
39 | 39 | protected $pagantisOrder; |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Origin of Order |
43 | 43 | * |
44 | - * @var $string $origin |
|
45 | - */ |
|
44 | + * @var $string $origin |
|
45 | + */ |
|
46 | 46 | public $origin; |
47 | 47 | |
48 | 48 | /** |
49 | 49 | * WC_Order object |
50 | 50 | * |
51 | - * @var $string |
|
52 | - */ |
|
51 | + * @var $string |
|
52 | + */ |
|
53 | 53 | public $order; |
54 | 54 | |
55 | 55 | /** |
56 | - * @var mixed $woocommerceOrderId |
|
57 | - */ |
|
56 | + * @var mixed $woocommerceOrderId |
|
57 | + */ |
|
58 | 58 | protected $woocommerceOrderId = ''; |
59 | 59 | |
60 | 60 | /** |
61 | - * @var mixed $cfg |
|
62 | - */ |
|
61 | + * @var mixed $cfg |
|
62 | + */ |
|
63 | 63 | protected $cfg; |
64 | 64 | |
65 | 65 | /** |
66 | - * @var Client $orderClient |
|
66 | + * @var Client $orderClient |
|
67 | 67 | */ |
68 | 68 | protected $orderClient; |
69 | 69 | |
70 | 70 | /** |
71 | - * @var WC_Order $woocommerceOrder |
|
71 | + * @var WC_Order $woocommerceOrder |
|
72 | 72 | */ |
73 | 73 | protected $woocommerceOrder; |
74 | 74 | |
75 | 75 | /** |
76 | - * @var mixed $pagantisOrderId |
|
76 | + * @var mixed $pagantisOrderId |
|
77 | 77 | */ |
78 | 78 | protected $pagantisOrderId = ''; |
79 | 79 | |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | |
227 | 227 | if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM |
228 | 228 | $logMessage = 'WARNING checkMerchantOrderStatus.' . |
229 | - ' Merchant order id:'.$this->woocommerceOrder->get_id(). |
|
230 | - ' Merchant order status:'.$this->woocommerceOrder->get_status(). |
|
231 | - ' Pagantis order id:'.$this->pagantisOrder->getStatus(). |
|
232 | - ' Pagantis order status:'.$this->pagantisOrder->getId(); |
|
229 | + ' Merchant order id:'.$this->woocommerceOrder->get_id(). |
|
230 | + ' Merchant order status:'.$this->woocommerceOrder->get_status(). |
|
231 | + ' Pagantis order id:'.$this->pagantisOrder->getStatus(). |
|
232 | + ' Pagantis order status:'.$this->pagantisOrder->getId(); |
|
233 | 233 | |
234 | 234 | WC_Pagantis_Logger::insert_log_entry_in_wpdb(null, $logMessage); |
235 | 235 | $this->woocommerceOrder->add_order_note($logMessage); |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * UTILS FUNCTIONS |
288 | 288 | */ |
289 | 289 | /** |
290 | - * STEP 1 CC - Check concurrency |
|
290 | + * STEP 1 CC - Check concurrency |
|
291 | 291 | */ |
292 | 292 | /** |
293 | 293 | * Check if orders table exists |
@@ -327,16 +327,16 @@ discard block |
||
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
330 | - * STEP 2 GMO - Get Merchant Order |
|
330 | + * STEP 2 GMO - Get Merchant Order |
|
331 | 331 | */ |
332 | 332 | /** |
333 | - * STEP 3 GPOI - Get Pagantis OrderId |
|
333 | + * STEP 3 GPOI - Get Pagantis OrderId |
|
334 | 334 | */ |
335 | 335 | /** |
336 | - * STEP 4 GPO - Get Pagantis Order |
|
336 | + * STEP 4 GPO - Get Pagantis Order |
|
337 | 337 | */ |
338 | 338 | /** |
339 | - * STEP 5 COS - Check Order Status |
|
339 | + * STEP 5 COS - Check Order Status |
|
340 | 340 | */ |
341 | 341 | |
342 | 342 | /** |
@@ -367,13 +367,13 @@ discard block |
||
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
370 | - * STEP 6 CMOS - Check Merchant Order Status |
|
370 | + * STEP 6 CMOS - Check Merchant Order Status |
|
371 | 371 | */ |
372 | 372 | /** |
373 | - * STEP 7 VA - Validate Amount |
|
373 | + * STEP 7 VA - Validate Amount |
|
374 | 374 | */ |
375 | 375 | /** |
376 | - * STEP 8 PMO - Process Merchant Order |
|
376 | + * STEP 8 PMO - Process Merchant Order |
|
377 | 377 | */ |
378 | 378 | /** |
379 | 379 | * @throws \Exception |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
429 | - * STEP 9 CPO - Confirmation Pagantis Order |
|
430 | - */ |
|
429 | + * STEP 9 CPO - Confirmation Pagantis Order |
|
430 | + */ |
|
431 | 431 | private function rollbackMerchantOrder() |
432 | 432 | { |
433 | 433 | $this->woocommerceOrder->update_status('pending', __('Pending payment', 'woocommerce')); // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function processInformation() |
87 | 87 | { |
88 | - require_once dirname(__FILE__) . '/../includes/class-wc-pagantis-logger.php'; |
|
89 | - require_once dirname(__FILE__) . '/../includes/functions.php'; |
|
88 | + require_once dirname(__FILE__).'/../includes/class-wc-pagantis-logger.php'; |
|
89 | + require_once dirname(__FILE__).'/../includes/functions.php'; |
|
90 | 90 | try { |
91 | 91 | require_once(__ROOT__.'/vendor/autoload.php'); |
92 | 92 | try { |
93 | - if ($_SERVER['REQUEST_METHOD'] === 'GET' && $_GET['origin'] === 'notification') { |
|
93 | + if ($_SERVER['REQUEST_METHOD']==='GET' && $_GET['origin']==='notification') { |
|
94 | 94 | return $this->buildResponse(); |
95 | 95 | } |
96 | 96 | $this->checkConcurrency(); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | private function checkConcurrency() |
139 | 139 | { |
140 | 140 | $this->woocommerceOrderId = $_GET['order-received']; |
141 | - if ($this->woocommerceOrderId === '') { |
|
141 | + if ($this->woocommerceOrderId==='') { |
|
142 | 142 | throw new QuoteNotFoundException(); |
143 | 143 | } |
144 | 144 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $queryResult = $wpdb->get_row("select order_id from $tableName where id='".$this->woocommerceOrderId."'"); |
171 | 171 | $this->pagantisOrderId = $queryResult->order_id; |
172 | 172 | |
173 | - if ($this->pagantisOrderId === '') { |
|
173 | + if ($this->pagantisOrderId==='') { |
|
174 | 174 | throw new NoIdentificationException(); |
175 | 175 | } |
176 | 176 | } |
@@ -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'; |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | global $wpdb; |
298 | 298 | $tableName = $wpdb->prefix.PAGANTIS_WC_ORDERS_TABLE; |
299 | 299 | |
300 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
300 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
301 | 301 | $charset_collate = $wpdb->get_charset_collate(); |
302 | 302 | $sql = "CREATE TABLE $tableName (id int, order_id varchar(50), wc_order_id varchar(50), |
303 | 303 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | global $wpdb; |
316 | 316 | $tableName = $wpdb->prefix.PAGANTIS_LOGS_TABLE; |
317 | 317 | |
318 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
318 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
319 | 319 | $charset_collate = $wpdb->get_charset_collate(); |
320 | 320 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
321 | 321 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -386,12 +386,12 @@ discard block |
||
386 | 386 | $metadataOrder = $this->pagantisOrder->getMetadata(); |
387 | 387 | $metadataInfo = null; |
388 | 388 | foreach ($metadataOrder as $metadataKey => $metadataValue) { |
389 | - if ($metadataKey === 'promotedProduct') { |
|
389 | + if ($metadataKey==='promotedProduct') { |
|
390 | 390 | $metadataInfo .= "/Producto promocionado = $metadataValue"; |
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
394 | - if ($metadataInfo != null) { |
|
394 | + if ($metadataInfo!=null) { |
|
395 | 395 | $this->woocommerceOrder->add_order_note($metadataInfo); |
396 | 396 | } |
397 | 397 | |
@@ -462,13 +462,13 @@ discard block |
||
462 | 462 | { |
463 | 463 | global $wpdb; |
464 | 464 | $tableName = $wpdb->prefix.PAGANTIS_CONCURRENCY_TABLE; |
465 | - if ($orderId === null) { |
|
465 | + if ($orderId===null) { |
|
466 | 466 | $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT.' SECOND)'; |
467 | 467 | } else { |
468 | 468 | $query = "DELETE FROM $tableName WHERE order_id = $orderId"; |
469 | 469 | } |
470 | 470 | $resultDelete = $wpdb->query($query); |
471 | - if ($resultDelete === false) { |
|
471 | + if ($resultDelete===false) { |
|
472 | 472 | throw new ConcurrencyException(); |
473 | 473 | } |
474 | 474 | } |
@@ -483,11 +483,11 @@ discard block |
||
483 | 483 | global $wpdb; |
484 | 484 | $tableName = $wpdb->prefix.PAGANTIS_CONCURRENCY_TABLE; |
485 | 485 | $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId)); |
486 | - if ($insertResult === false) { |
|
487 | - if ($this->getOrigin() === 'Notify') { |
|
486 | + if ($insertResult===false) { |
|
487 | + if ($this->getOrigin()==='Notify') { |
|
488 | 488 | throw new ConcurrencyException(); |
489 | 489 | } else { |
490 | - $query = sprintf( |
|
490 | + $query = sprintf( |
|
491 | 491 | 'SELECT TIMESTAMPDIFF(SECOND,NOW()-INTERVAL %s SECOND, createdAt) as rest FROM %s WHERE %s', |
492 | 492 | self::CONCURRENCY_TIMEOUT, |
493 | 493 | $tableName, |
@@ -495,8 +495,8 @@ discard block |
||
495 | 495 | ); |
496 | 496 | $resultSeconds = $wpdb->get_row($query); |
497 | 497 | $restSeconds = isset($resultSeconds) ? ($resultSeconds->rest) : 0; |
498 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
499 | - sleep($secondsToExpire+1); |
|
498 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
499 | + sleep($secondsToExpire + 1); |
|
500 | 500 | |
501 | 501 | $logMessage = sprintf( |
502 | 502 | 'User waiting %s seconds, default seconds %s, bd time to expire %s seconds', |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | { |
520 | 520 | $this->unblockConcurrency($this->woocommerceOrderId); |
521 | 521 | |
522 | - if ($exception === null) { |
|
522 | + if ($exception===null) { |
|
523 | 523 | $jsonResponse = new JsonSuccessResponse(); |
524 | 524 | } else { |
525 | 525 | $jsonResponse = new JsonExceptionResponse(); |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | $jsonResponse->setMerchantOrderId($this->woocommerceOrderId); |
530 | 530 | $jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
531 | 531 | |
532 | - if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
|
532 | + if ($_SERVER['REQUEST_METHOD']==='POST') { |
|
533 | 533 | $jsonResponse->printResponse(); |
534 | 534 | } else { |
535 | 535 | return $jsonResponse; |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | //namespace Gateways; |
13 | 13 | |
14 | 14 | |
15 | -if (! defined('ABSPATH')) { |
|
15 | +if (!defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | define('PAGANTIS_VERSION', '8.3.7'); |
@@ -63,22 +63,22 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function __construct() |
65 | 65 | { |
66 | - require_once(plugin_dir_path(__FILE__) . 'vendor/autoload.php'); |
|
67 | - require_once dirname(__FILE__) . '/includes/class-wc-pagantis-config.php'; |
|
68 | - require_once dirname(__FILE__) . '/includes/functions.php'; |
|
66 | + require_once(plugin_dir_path(__FILE__).'vendor/autoload.php'); |
|
67 | + require_once dirname(__FILE__).'/includes/class-wc-pagantis-config.php'; |
|
68 | + require_once dirname(__FILE__).'/includes/functions.php'; |
|
69 | 69 | |
70 | - $this->template_path = plugin_dir_path(__FILE__) . 'templates/'; |
|
70 | + $this->template_path = plugin_dir_path(__FILE__).'templates/'; |
|
71 | 71 | |
72 | 72 | $this->prepare_wpdb_tables(); |
73 | 73 | $this->initialConfig = WC_Pagantis_Config::getDefaultConfig(); |
74 | 74 | |
75 | 75 | $this->extraConfig = WC_Pagantis_Config::getExtraConfig(); |
76 | 76 | add_action('plugins_loaded', array($this, 'bootstrap')); |
77 | - load_plugin_textdomain('pagantis', false, basename(dirname(__FILE__)) . '/languages'); |
|
77 | + load_plugin_textdomain('pagantis', false, basename(dirname(__FILE__)).'/languages'); |
|
78 | 78 | add_filter('woocommerce_payment_gateways', array($this, 'add_pagantis_gateway')); |
79 | 79 | add_filter('woocommerce_available_payment_gateways', array($this, 'check_if_pg_is_in_available_gateways'), 9999); |
80 | 80 | add_filter('plugin_row_meta', array($this, 'get_plugin_row_meta_links'), 10, 2); |
81 | - add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'get_plugin_action_links')); |
|
81 | + add_filter('plugin_action_links_'.plugin_basename(__FILE__), array($this, 'get_plugin_action_links')); |
|
82 | 82 | |
83 | 83 | add_action('wp_enqueue_scripts', 'add_pagantis_widget_js'); |
84 | 84 | add_action('rest_api_init', array($this, 'register_pg_rest_routes')); //Endpoint |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public static function get_instance() |
101 | 101 | { |
102 | - if (null === self::$instance) { |
|
102 | + if (null===self::$instance) { |
|
103 | 103 | self::$instance = new self(); |
104 | 104 | } |
105 | 105 | |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | throw new Exception(__('Pagantis requires WooCommerce version 3.0 or greater', 'pagantis')); |
145 | 145 | } |
146 | 146 | |
147 | - if (! function_exists('curl_init')) { |
|
147 | + if (!function_exists('curl_init')) { |
|
148 | 148 | throw new Exception(__('Pagantis requires cURL to be installed on your server', 'pagantis')); |
149 | 149 | } |
150 | - if (! version_compare(phpversion(), '5.3.0', '>=')) { |
|
150 | + if (!version_compare(phpversion(), '5.3.0', '>=')) { |
|
151 | 151 | throw new Exception(__('Pagantis requires PHP 5.3 or greater to be installed on your server', 'pagantis')); |
152 | 152 | } |
153 | 153 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | { |
177 | 177 | $post_id = $product->get_id(); |
178 | 178 | $pagantis_promoted_value = $_REQUEST['pagantis_promoted']; |
179 | - if ($pagantis_promoted_value === 'on') { |
|
179 | + if ($pagantis_promoted_value==='on') { |
|
180 | 180 | $pagantis_promoted_value = 'yes'; |
181 | 181 | } else { |
182 | 182 | $pagantis_promoted_value = 'no'; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | public function pagantisPromotedVarSave($post_id) |
210 | 210 | { |
211 | 211 | $pagantis_promoted_value = $_POST['pagantis_promoted']; |
212 | - if ($pagantis_promoted_value === null) { |
|
212 | + if ($pagantis_promoted_value===null) { |
|
213 | 213 | $pagantis_promoted_value = 'no'; |
214 | 214 | } |
215 | 215 | update_post_meta($post_id, 'custom_product_pagantis_promoted', esc_attr($pagantis_promoted_value)); |
@@ -222,8 +222,8 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function loadPagantisTranslation($mofile, $domain) |
224 | 224 | { |
225 | - if ('pagantis' === $domain) { |
|
226 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
225 | + if ('pagantis'===$domain) { |
|
226 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | return $mofile; |
@@ -236,19 +236,19 @@ discard block |
||
236 | 236 | { |
237 | 237 | global $wpdb; |
238 | 238 | |
239 | - $tableName = $wpdb->prefix . PAGANTIS_CONCURRENCY_TABLE; |
|
240 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") !== $tableName) { |
|
239 | + $tableName = $wpdb->prefix.PAGANTIS_CONCURRENCY_TABLE; |
|
240 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!==$tableName) { |
|
241 | 241 | $charset_collate = $wpdb->get_charset_collate(); |
242 | 242 | $sql = "CREATE TABLE $tableName ( order_id int NOT NULL, |
243 | 243 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate"; |
244 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
244 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
245 | 245 | dbDelta($sql); |
246 | 246 | } |
247 | 247 | |
248 | - $tableName = $wpdb->prefix . PAGANTIS_CONFIG_TABLE; |
|
248 | + $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE; |
|
249 | 249 | |
250 | 250 | //Check if table exists |
251 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") !== $tableName; |
|
251 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!==$tableName; |
|
252 | 252 | if ($tableExists) { |
253 | 253 | $charset_collate = $wpdb->get_charset_collate(); |
254 | 254 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -257,13 +257,13 @@ discard block |
||
257 | 257 | value varchar(1000) NOT NULL, |
258 | 258 | UNIQUE KEY id(id)) $charset_collate"; |
259 | 259 | |
260 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
260 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
261 | 261 | dbDelta($sql); |
262 | 262 | } else { |
263 | 263 | //Updated value field to adapt to new length < v8.0.1 |
264 | 264 | $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'"; |
265 | 265 | $results = $wpdb->get_results($query, ARRAY_A); |
266 | - if ($results['0']['COLUMN_TYPE'] === 'varchar(100)') { |
|
266 | + if ($results['0']['COLUMN_TYPE']==='varchar(100)') { |
|
267 | 267 | $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)"; |
268 | 268 | $wpdb->query($sql); |
269 | 269 | } |
@@ -273,9 +273,9 @@ discard block |
||
273 | 273 | or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
274 | 274 | $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A); |
275 | 275 | foreach ($dbCurrentConfig as $item) { |
276 | - if ($item['config'] === 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
276 | + if ($item['config']==='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
277 | 277 | $css_price_selector = $this->preparePriceSelector($item['value']); |
278 | - if ($item['value'] !== $css_price_selector) { |
|
278 | + if ($item['value']!==$css_price_selector) { |
|
279 | 279 | $wpdb->update( |
280 | 280 | $tableName, |
281 | 281 | array('value' => stripslashes($css_price_selector)), |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | array('%s') |
285 | 285 | ); |
286 | 286 | } |
287 | - } elseif ($item['config'] === 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
287 | + } elseif ($item['config']==='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
288 | 288 | $css_quantity_selector = $this->prepareQuantitySelector($item['value']); |
289 | - if ($item['value'] !== $css_quantity_selector) { |
|
289 | + if ($item['value']!==$css_quantity_selector) { |
|
290 | 290 | $wpdb->update( |
291 | 291 | $tableName, |
292 | 292 | array('value' => stripslashes($css_quantity_selector)), |
@@ -300,10 +300,10 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | //Adapting selector to array < v8.2.2 |
303 | - $tableName = $wpdb->prefix . PAGANTIS_CONFIG_TABLE; |
|
303 | + $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE; |
|
304 | 304 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
305 | 305 | $results = $wpdb->get_results($query, ARRAY_A); |
306 | - if (count($results) === 0) { |
|
306 | + if (count($results)===0) { |
|
307 | 307 | $wpdb->insert( |
308 | 308 | $tableName, |
309 | 309 | array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value' => '.'), |
@@ -317,18 +317,18 @@ discard block |
||
317 | 317 | } |
318 | 318 | |
319 | 319 | //Adding new selector < v8.3.0 |
320 | - $tableName = $wpdb->prefix . PAGANTIS_CONFIG_TABLE; |
|
320 | + $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE; |
|
321 | 321 | $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'"; |
322 | 322 | $results = $wpdb->get_results($query, ARRAY_A); |
323 | - if (count($results) === 0) { |
|
323 | + if (count($results)===0) { |
|
324 | 324 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value' => '0'), array('%s', '%s')); |
325 | 325 | } |
326 | 326 | |
327 | 327 | //Adding new selector < v8.3.2 |
328 | - $tableName = $wpdb->prefix . PAGANTIS_CONFIG_TABLE; |
|
328 | + $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE; |
|
329 | 329 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'"; |
330 | 330 | $results = $wpdb->get_results($query, ARRAY_A); |
331 | - if (count($results) === 0) { |
|
331 | + if (count($results)===0) { |
|
332 | 332 | $wpdb->insert( |
333 | 333 | $tableName, |
334 | 334 | array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value' => 'default'), |
@@ -342,10 +342,10 @@ discard block |
||
342 | 342 | } |
343 | 343 | |
344 | 344 | //Adding new selector < v8.3.3 |
345 | - $tableName = $wpdb->prefix . PAGANTIS_CONFIG_TABLE; |
|
345 | + $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE; |
|
346 | 346 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'"; |
347 | 347 | $results = $wpdb->get_results($query, ARRAY_A); |
348 | - if (count($results) === 0) { |
|
348 | + if (count($results)===0) { |
|
349 | 349 | $wpdb->insert($tableName, array( |
350 | 350 | 'config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', |
351 | 351 | 'value' => 'sdk.simulator.types.CHECKOUT_PAGE', |
@@ -361,10 +361,10 @@ discard block |
||
361 | 361 | |
362 | 362 | //Adapting to variable selector < v8.3.6 |
363 | 363 | $variableSelector = 'div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price'; |
364 | - $tableName = $wpdb->prefix . PAGANTIS_CONFIG_TABLE; |
|
364 | + $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE; |
|
365 | 365 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'"; |
366 | 366 | $results = $wpdb->get_results($query, ARRAY_A); |
367 | - if (count($results) === 0) { |
|
367 | + if (count($results)===0) { |
|
368 | 368 | $wpdb->update( |
369 | 369 | $tableName, |
370 | 370 | array('value' => $variableSelector), |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | $simpleDbConfigs[$config['config']] = $config['value']; |
383 | 383 | } |
384 | 384 | $newConfigs = array_diff_key(WC_Pagantis_Config::getDefaultConfig(), $simpleDbConfigs); |
385 | - if (! empty($newConfigs)) { |
|
385 | + if (!empty($newConfigs)) { |
|
386 | 386 | foreach ($newConfigs as $key => $value) { |
387 | 387 | $wpdb->insert($tableName, array('config' => $key, 'value' => $value), array('%s', '%s')); |
388 | 388 | } |
@@ -391,12 +391,12 @@ discard block |
||
391 | 391 | //Current plugin config: pagantis_public_key => New field --- public_key => Old field |
392 | 392 | $settings = get_option('woocommerce_pagantis_settings'); |
393 | 393 | |
394 | - if (! isset($settings['pagantis_public_key']) && $settings['public_key']) { |
|
394 | + if (!isset($settings['pagantis_public_key']) && $settings['public_key']) { |
|
395 | 395 | $settings['pagantis_public_key'] = $settings['public_key']; |
396 | 396 | unset($settings['public_key']); |
397 | 397 | } |
398 | 398 | |
399 | - if (! isset($settings['pagantis_private_key']) && $settings['secret_key']) { |
|
399 | + if (!isset($settings['pagantis_private_key']) && $settings['secret_key']) { |
|
400 | 400 | $settings['pagantis_private_key'] = $settings['secret_key']; |
401 | 401 | unset($settings['secret_key']); |
402 | 402 | } |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | |
408 | 408 | public function enqueue_simulator_scripts() |
409 | 409 | { |
410 | - if (! pg_isPluginActive()) { |
|
410 | + if (!pg_isPluginActive()) { |
|
411 | 411 | return; |
412 | 412 | } |
413 | 413 | |
@@ -488,11 +488,11 @@ discard block |
||
488 | 488 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
489 | 489 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
490 | 490 | $totalPrice = $product->get_price(); |
491 | - $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount === '0')); |
|
492 | - if ($cfg['enabled'] !== 'yes' || $cfg['pagantis_public_key'] === '' || $cfg['pagantis_private_key'] === '' |
|
493 | - || $cfg['simulator'] !== 'yes' |
|
494 | - || ! $allowedCountry |
|
495 | - || ! $validAmount |
|
491 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount==='0')); |
|
492 | + if ($cfg['enabled']!=='yes' || $cfg['pagantis_public_key']==='' || $cfg['pagantis_private_key']==='' |
|
493 | + || $cfg['simulator']!=='yes' |
|
494 | + || !$allowedCountry |
|
495 | + || !$validAmount |
|
496 | 496 | ) { |
497 | 497 | return; |
498 | 498 | } |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | */ |
535 | 535 | public function add_pagantis_gateway($methods) |
536 | 536 | { |
537 | - if (! class_exists('WC_Payment_Gateway')) { |
|
537 | + if (!class_exists('WC_Payment_Gateway')) { |
|
538 | 538 | return $methods; |
539 | 539 | } |
540 | 540 | |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | public function check_if_pg_is_in_available_gateways($methods) |
555 | 555 | { |
556 | 556 | $pagantis = new WC_Pagantis_Gateway(); |
557 | - if (! $pagantis->is_available()) { |
|
557 | + if (!$pagantis->is_available()) { |
|
558 | 558 | unset($methods['pagantis']); |
559 | 559 | } |
560 | 560 | |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | { |
574 | 574 | $setting_link = $this->get_setting_link(); |
575 | 575 | $plugin_links = array( |
576 | - '<a href="' . $setting_link . '">' . __('Settings', 'pagantis') . '</a>', |
|
576 | + '<a href="'.$setting_link.'">'.__('Settings', 'pagantis').'</a>', |
|
577 | 577 | ); |
578 | 578 | |
579 | 579 | return array_merge($plugin_links, $links); |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | { |
585 | 585 | $section_slug = 'pagantis'; |
586 | 586 | |
587 | - return admin_url('admin.php?page=wc-settings&tab=checkout§ion=' . $section_slug); |
|
587 | + return admin_url('admin.php?page=wc-settings&tab=checkout§ion='.$section_slug); |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | /** |
@@ -598,10 +598,10 @@ discard block |
||
598 | 598 | */ |
599 | 599 | public function get_plugin_row_meta_links($links, $file) |
600 | 600 | { |
601 | - if ($file === plugin_basename(__FILE__)) { |
|
602 | - $links[] = '<a href="' . PAGANTIS_GIT_HUB_URL . '" target="_blank">' . __('Documentation', 'pagantis') . '</a>'; |
|
603 | - $links[] = '<a href="' . PAGANTIS_DOC_URL . '" target="_blank">' . __('API documentation', 'pagantis') . '</a>'; |
|
604 | - $links[] = '<a href="' . PAGANTIS_SUPPORT_EMAIL . '">' . __('Support', 'pagantis') . '</a>'; |
|
601 | + if ($file===plugin_basename(__FILE__)) { |
|
602 | + $links[] = '<a href="'.PAGANTIS_GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
|
603 | + $links[] = '<a href="'.PAGANTIS_DOC_URL.'" target="_blank">'.__('API documentation', 'pagantis').'</a>'; |
|
604 | + $links[] = '<a href="'.PAGANTIS_SUPPORT_EMAIL.'">'.__('Support', 'pagantis').'</a>'; |
|
605 | 605 | |
606 | 606 | return $links; |
607 | 607 | } |
@@ -626,10 +626,10 @@ discard block |
||
626 | 626 | $to = $filters['to']; |
627 | 627 | $cfg = get_option('woocommerce_pagantis_settings'); |
628 | 628 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
629 | - $tableName = $wpdb->prefix . PAGANTIS_LOGS_TABLE; |
|
629 | + $tableName = $wpdb->prefix.PAGANTIS_LOGS_TABLE; |
|
630 | 630 | $query = "SELECT * FROM $tableName WHERE createdAt>$from AND createdAt<$to ORDER BY createdAt DESC"; |
631 | 631 | $results = $wpdb->get_results($query); |
632 | - if (isset($results) && $privateKey === $secretKey) { |
|
632 | + if (isset($results) && $privateKey===$secretKey) { |
|
633 | 633 | foreach ($results as $key => $result) { |
634 | 634 | $response[$key]['timestamp'] = $result->createdAt; |
635 | 635 | $response[$key]['log'] = json_decode($result->log); |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | $response = json_encode($response); |
641 | 641 | header('HTTP/1.1 200', true, 200); |
642 | 642 | header('Content-Type: application/json', true); |
643 | - header('Content-Length: ' . strlen($response)); |
|
643 | + header('Content-Length: '.strlen($response)); |
|
644 | 644 | echo($response); |
645 | 645 | exit(); |
646 | 646 | } |
@@ -653,20 +653,20 @@ discard block |
||
653 | 653 | public function updateExtraConfig($data) |
654 | 654 | { |
655 | 655 | global $wpdb; |
656 | - $tableName = $wpdb->prefix . PAGANTIS_CONFIG_TABLE; |
|
656 | + $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE; |
|
657 | 657 | $response = array('status' => null); |
658 | 658 | |
659 | 659 | $filters = ($data->get_params()); |
660 | 660 | $secretKey = $filters['secret']; |
661 | 661 | $cfg = get_option('woocommerce_pagantis_settings'); |
662 | 662 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
663 | - if ($privateKey !== $secretKey) { |
|
663 | + if ($privateKey!==$secretKey) { |
|
664 | 664 | $response['status'] = 401; |
665 | 665 | $response['result'] = 'Unauthorized'; |
666 | - } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { |
|
666 | + } elseif ($_SERVER['REQUEST_METHOD']==='POST') { |
|
667 | 667 | if (count($_POST)) { |
668 | 668 | foreach ($_POST as $config => $value) { |
669 | - if (isset($this->initialConfig[$config]) && $response['status'] === null) { |
|
669 | + if (isset($this->initialConfig[$config]) && $response['status']===null) { |
|
670 | 670 | $wpdb->update( |
671 | 671 | $tableName, |
672 | 672 | array('value' => stripslashes($value)), |
@@ -685,8 +685,8 @@ discard block |
||
685 | 685 | } |
686 | 686 | } |
687 | 687 | |
688 | - if ($response['status'] === null) { |
|
689 | - $tableName = $wpdb->prefix . PAGANTIS_CONFIG_TABLE; |
|
688 | + if ($response['status']===null) { |
|
689 | + $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE; |
|
690 | 690 | $dbResult = $wpdb->get_results("select config, value from $tableName", ARRAY_A); |
691 | 691 | foreach ($dbResult as $value) { |
692 | 692 | $formattedResult[$value['config']] = $value['value']; |
@@ -695,9 +695,9 @@ discard block |
||
695 | 695 | } |
696 | 696 | |
697 | 697 | $result = json_encode($response['result']); |
698 | - header('HTTP/1.1 ' . $response['status'], true, $response['status']); |
|
698 | + header('HTTP/1.1 '.$response['status'], true, $response['status']); |
|
699 | 699 | header('Content-Type: application/json', true); |
700 | - header('Content-Length: ' . strlen($result)); |
|
700 | + header('Content-Length: '.strlen($result)); |
|
701 | 701 | echo($result); |
702 | 702 | exit(); |
703 | 703 | } |
@@ -718,14 +718,14 @@ discard block |
||
718 | 718 | $method = ($filters['method']) ? ($filters['method']) : 'Pagantis'; |
719 | 719 | $cfg = get_option('woocommerce_pagantis_settings'); |
720 | 720 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
721 | - $tableName = $wpdb->prefix . PAGANTIS_WC_ORDERS_TABLE; |
|
722 | - $tableNameInner = $wpdb->prefix . 'postmeta'; |
|
721 | + $tableName = $wpdb->prefix.PAGANTIS_WC_ORDERS_TABLE; |
|
722 | + $tableNameInner = $wpdb->prefix.'postmeta'; |
|
723 | 723 | $query = "SELECT * FROM $tableName tn INNER JOIN $tableNameInner tn2 ON tn2.post_id = tn.id |
724 | - WHERE tn.post_type='shop_order' AND tn.post_date>'" . $from->format('Y-m-d') . "' |
|
725 | - AND tn.post_date<'" . $to->format('Y-m-d') . "' ORDER BY tn.post_date DESC"; |
|
724 | + WHERE tn.post_type='shop_order' AND tn.post_date>'".$from->format('Y-m-d')."' |
|
725 | + AND tn.post_date<'" . $to->format('Y-m-d')."' ORDER BY tn.post_date DESC"; |
|
726 | 726 | $results = $wpdb->get_results($query); |
727 | 727 | |
728 | - if (isset($results) && $privateKey === $secretKey) { |
|
728 | + if (isset($results) && $privateKey===$secretKey) { |
|
729 | 729 | foreach ($results as $result) { |
730 | 730 | $key = $result->ID; |
731 | 731 | $response['message'][$key]['timestamp'] = $result->post_date; |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | $response = json_encode($response); |
739 | 739 | header('HTTP/1.1 200', true, 200); |
740 | 740 | header('Content-Type: application/json', true); |
741 | - header('Content-Length: ' . strlen($response)); |
|
741 | + header('Content-Length: '.strlen($response)); |
|
742 | 742 | echo($response); |
743 | 743 | exit(); |
744 | 744 | } |
@@ -783,9 +783,9 @@ discard block |
||
783 | 783 | */ |
784 | 784 | private function prepareQuantitySelector($css_quantity_selector) |
785 | 785 | { |
786 | - if ($css_quantity_selector === 'default' || $css_quantity_selector === '') { |
|
786 | + if ($css_quantity_selector==='default' || $css_quantity_selector==='') { |
|
787 | 787 | $css_quantity_selector = $this->initialConfig['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
788 | - } elseif (! unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
|
788 | + } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
|
789 | 789 | $css_quantity_selector = serialize(array($css_quantity_selector)); |
790 | 790 | } |
791 | 791 | |
@@ -799,9 +799,9 @@ discard block |
||
799 | 799 | */ |
800 | 800 | private function preparePriceSelector($css_price_selector) |
801 | 801 | { |
802 | - if ($css_price_selector === 'default' || $css_price_selector === '') { |
|
802 | + if ($css_price_selector==='default' || $css_price_selector==='') { |
|
803 | 803 | $css_price_selector = $this->initialConfig['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
804 | - } elseif (! unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
|
804 | + } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
|
805 | 805 | $css_price_selector = serialize(array($css_price_selector)); |
806 | 806 | } |
807 | 807 |