PluginProbe
MultiSafepay plugin for WooCommerce / trunk
MultiSafepay plugin for WooCommerce vtrunk
6.11.1 6.12.0 6.13.0 6.2.0 6.2.1 6.3.0 6.3.1 6.4.0 6.4.1 6.4.2 6.4.3 6.5.0 6.5.1 6.6.0 6.6.1 6.6.2 6.7.0 6.7.1 6.7.2 6.7.3 6.8.0 6.8.1 6.8.2 6.8.3 6.9.0 All 84 releases
multisafepay / src / Settings / SystemReport.php

SystemReport.php in MultiSafepay plugin for WooCommerce trunk, at src/Settings/SystemReport.php

619 lines 28.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php declare(strict_types=1);
2
3 namespace MultiSafepay\WooCommerce\Settings;
4
5 use MultiSafepay\Util\Version;
6 use MultiSafepay\WooCommerce\PaymentMethods\Base\BasePaymentMethod;
7 use MultiSafepay\WooCommerce\Services\PaymentMethodService;
8 use WC_Countries;
9 use WC_Tax;
10 use WP_Error;
11
12 /**
13 * Defines all the functionalities needed on the system report page
14 *
15 * Class SystemReport
16 *
17 * @package MultiSafepay\WooCommerce\Settings
18 */
19 class SystemReport {
20
21 /**
22 * The WC Report
23 *
24 * @var array
25 */
26 private $report;
27
28 /**
29 * Initialize the class and set its properties.
30 */
31 public function __construct() {
32 $this->report = $this->get_woocommerce_system_status_report();
33 }
34
35 /**
36 * Return the status report from the API
37 *
38 * @return array|WP_Error
39 */
40 private function get_woocommerce_system_status_report() {
41 if ( class_exists( \Automattic\WooCommerce\Utilities\RestApiUtil::class ) ) {
42 return wc_get_container()->get( \Automattic\WooCommerce\Utilities\RestApiUtil::class )->get_endpoint_data( '/wc/v3/system_status' );
43 }
44
45 if ( class_exists( \WC_API::class ) ) {
46 $wc_api = new \WC_API();
47 $report = $wc_api->get_endpoint_data( '/wc/v3/system_status' );
48 return $report;
49 }
50
51 return array();
52 }
53
54 /**
55 * Return an array with all the information required
56 *
57 * @return array
58 */
59 public function get_multisafepay_system_status_report() {
60 if ( empty( $this->report ) ) {
61 return array();
62 }
63
64 $status_report = array(
65 'wordpress_environment' => $this->get_system_report_wordpress_environment(),
66 'server_environment' => $this->get_system_report_server_environment(),
67 'woocommerce_settings' => $this->get_system_report_woocommerce_settings(),
68 'woocommerce_tax_rules' => $this->get_system_report_woocommerce_tax_rules(),
69 'theme_settings' => $this->get_system_report_theme_settings(),
70 'templates_settings' => $this->get_system_report_templates_settings(),
71 'multisafepay_settings' => $this->get_system_report_multisafepay_settings(),
72 'multisafepay_gateways_settings' => $this->get_system_report_multisafepay_gateways_settings(),
73 'active_plugins ' => $this->get_system_report_active_plugins(),
74 );
75 return $status_report;
76 }
77
78 /**
79 * Return an array with information about WordPress environment
80 *
81 * @return array
82 */
83 public function get_system_report_wordpress_environment(): array {
84 $environment = $this->report['environment'];
85 $wordpress_environment = array(
86 'title' => __( 'WordPress environment', 'multisafepay' ),
87 'settings' => array(
88 'site_url' => array(
89 'label' => __( 'Site URL', 'multisafepay' ),
90 'value' => $environment['site_url'],
91 ),
92 'home_url' => array(
93 'label' => __( 'Home URL', 'multisafepay' ),
94 'value' => $environment['home_url'],
95 ),
96 'woocommerce_version' => array(
97 'label' => __( 'WooCommerce version', 'multisafepay' ),
98 'value' => $environment['version'],
99 ),
100 'is_writable_log_directory' => array(
101 'label' => __( 'Log directory writable', 'multisafepay' ),
102 'value' => $environment['log_directory_writable'] ? __( 'Enabled', 'multisafepay' ) : __( 'Disabled', 'multisafepay' ),
103 ),
104 'wordpress_version' => array(
105 'label' => __( 'WordPress version', 'multisafepay' ),
106 'value' => $environment['wp_version'],
107 ),
108 'wordpress_multisite' => array(
109 'label' => __( 'WordPress multisite', 'multisafepay' ),
110 'value' => $environment['wp_multisite'] ? __( 'Enabled', 'multisafepay' ) : __( 'Disabled', 'multisafepay' ),
111 ),
112 'wordpress_debug_mode' => array(
113 'label' => __( 'WordPress debug mode', 'multisafepay' ),
114 'value' => $environment['wp_multisite'] ? __( 'Enabled', 'multisafepay' ) : __( 'Disabled', 'multisafepay' ),
115 ),
116 ),
117 );
118 return $wordpress_environment;
119 }
120
121 /**
122 * Return an array with information about the server environment
123 *
124 * @return array
125 */
126 public function get_system_report_server_environment(): array {
127 $environment = $this->report['environment'];
128 $server_environment = array(
129 'title' => __( 'Server environment', 'multisafepay' ),
130 'settings' => array(
131 'server_info' => array(
132 'label' => __( 'Server info', 'multisafepay' ),
133 'value' => $environment['server_info'],
134 ),
135 'php_version' => array(
136 'label' => __( 'PHP version', 'multisafepay' ),
137 'value' => $environment['php_version'],
138 ),
139 ),
140 );
141 return $server_environment;
142 }
143
144 /**
145 * Return an array with information about WooCommerce settings
146 *
147 * @return array
148 */
149 public function get_system_report_woocommerce_settings(): array {
150 $settings = $this->report['settings'];
151 $woocommerce_settings = array(
152 'title' => __( 'WooCommerce Settings', 'multisafepay' ),
153 'settings' => array(
154 'currency' => array(
155 'label' => __( 'Currency', 'multisafepay' ),
156 'value' => $settings['currency'] . ' (' . $settings['currency_symbol'] . ')',
157 ),
158 'currency_position' => array(
159 'label' => __( 'Currency position', 'multisafepay' ),
160 'value' => $settings['currency_position'],
161 ),
162 'thousand_separator' => array(
163 'label' => __( 'Thousand separator', 'multisafepay' ),
164 'value' => $settings['thousand_separator'],
165 ),
166 'decimal_separator' => array(
167 'label' => __( 'Decimal separator', 'multisafepay' ),
168 'value' => $settings['decimal_separator'],
169 ),
170 'number_of_decimals' => array(
171 'label' => __( 'Number of decimals', 'multisafepay' ),
172 'value' => $settings['number_of_decimals'],
173 ),
174 'product_types_taxonomies' => array(
175 'label' => __( 'Product types taxonomies', 'multisafepay' ),
176 'value' => $this->get_product_taxonomies( $settings['taxonomies'] ),
177 ),
178 'taxes_enable_in_the_store' => array(
179 'label' => __( 'Store-wide taxes', 'multisafepay' ),
180 'value' => wc_tax_enabled() ? __( 'Enabled', 'multisafepay' ) : __( 'Disabled', 'multisafepay' ),
181 ),
182 'round_taxes_at_subtotal' => array(
183 'label' => __( 'Round tax at subtotal level', 'multisafepay' ),
184 'value' => ( 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' ) ) ? __( 'Enabled', 'multisafepay' ) : __( 'Disabled', 'multisafepay' ),
185 ),
186 'taxes_based_on_store' => array(
187 'label' => __( 'Calculate tax based on', 'multisafepay' ),
188 'value' => ucfirst( get_option( 'woocommerce_tax_based_on' ) ),
189 ),
190 'store_location' => array(
191 'label' => __( 'Store Location', 'multisafepay' ),
192 'value' => implode( '. ', $this->get_base_store_information() ),
193 ),
194 'allowed_countries' => array(
195 'label' => __( 'Allowed countries', 'multisafepay' ),
196 'value' => implode( ', ', $this->get_allowed_countries() ),
197 ),
198 'taxes_display_at_checkout' => array(
199 'label' => __( 'Display tax totals', 'multisafepay' ),
200 'value' => ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) ? __( 'Itemized', 'multisafepay' ) : __( 'As a single total', 'multisafepay' ),
201 ),
202 'prices_includes_taxes' => array(
203 'label' => __( 'Prices entered with tax', 'multisafepay' ),
204 'value' => wc_prices_include_tax() ? __( 'Yes', 'multisafepay' ) : __( 'No', 'multisafepay' ),
205 ),
206 'coupons_applied_sequentially' => array(
207 'label' => __( 'Calculate coupon discounts sequentially', 'multisafepay' ),
208 'value' => ( 'yes' === get_option( 'woocommerce_calc_discounts_sequentially', 'no' ) ) ? __( 'Yes', 'multisafepay' ) : __( 'No', 'multisafepay' ),
209 ),
210 ),
211 );
212 return $woocommerce_settings;
213 }
214
215 /**
216 * Return an array with information about WooCommerce taxes
217 *
218 * @return array
219 */
220 public function get_system_report_woocommerce_tax_rules(): array {
221 $woocommerce_tax_rules_settings = array(
222 'title' => __( 'WooCommerce Tax Rules', 'multisafepay' ),
223 'settings' => array(
224 'standard_rates' => array(
225 'label' => __( 'Standard Rates', 'multisafepay' ),
226 'value' => $this->get_woocommerce_standard_rates(),
227 ),
228 ),
229 );
230 $non_standard_tax_rates = $this->get_non_standard_tax_rates();
231 foreach ( $non_standard_tax_rates as $key => $non_standard_tax_rate ) {
232 $woocommerce_tax_rules_settings['settings'][ $key ]['label'] = $non_standard_tax_rate['label'];
233 $woocommerce_tax_rules_settings['settings'][ $key ]['value'] = $non_standard_tax_rate['value'];
234 }
235 return $woocommerce_tax_rules_settings;
236 }
237
238 /**
239 * Return an array with information about the MultiSafepay gateway settings
240 *
241 * @return array
242 */
243 public function get_system_report_multisafepay_gateways_settings(): array {
244 $multisafepay_gateway_settings = array(
245 'title' => __( 'MultiSafepay Gateway Settings', 'multisafepay' ),
246 'settings' => array(),
247 );
248 /** @var BasePaymentMethod $woocommerce_payment_gateway */
249 foreach ( ( new PaymentMethodService() )->get_woocommerce_payment_gateways() as $woocommerce_payment_gateway ) {
250 $is_enable = $woocommerce_payment_gateway->enabled ? true : false;
251 if ( $is_enable ) {
252 $multisafepay_gateway_settings_value = '';
253 if ( ! empty( $woocommerce_payment_gateway->initial_order_status ) ) {
254 $multisafepay_gateway_settings_value .= __( 'Initial Order Status: ', 'multisafepay' ) . $woocommerce_payment_gateway->initial_order_status . '. ';
255 }
256 if ( ! empty( $woocommerce_payment_gateway->min_amount ) ) {
257 $multisafepay_gateway_settings_value .= __( 'Min Amount: ', 'multisafepay' ) . $woocommerce_payment_gateway->min_amount . '. ';
258 }
259 if ( ! empty( $woocommerce_payment_gateway->max_amount ) ) {
260 $multisafepay_gateway_settings_value .= __( 'Max Amount: ', 'multisafepay' ) . $woocommerce_payment_gateway->max_amount . '. ';
261 }
262 if ( ! empty( $woocommerce_payment_gateway->countries ) ) {
263 $multisafepay_gateway_settings_value .= __( 'Countries: ', 'multisafepay' ) . implode( ', ', $woocommerce_payment_gateway->countries ) . '. ';
264 }
265 if ( ! empty( $woocommerce_payment_gateway->is_payment_component_enabled() ) && ! empty( $woocommerce_payment_gateway->is_qr_enabled() ) ) {
266 $multisafepay_gateway_settings_value .= __( 'Payment Type: Payment Component with QR', 'multisafepay' ) . '. ';
267 }
268 if ( ! empty( $woocommerce_payment_gateway->is_payment_component_enabled() ) && ! empty( $woocommerce_payment_gateway->is_qr_only_enabled() ) ) {
269 $multisafepay_gateway_settings_value .= __( 'Payment Type: Payment Component with QR only', 'multisafepay' ) . '. ';
270 }
271 if ( ! empty( $woocommerce_payment_gateway->is_payment_component_enabled() ) && empty( $woocommerce_payment_gateway->is_qr_enabled() ) && empty( $woocommerce_payment_gateway->is_qr_only_enabled() ) ) {
272 $multisafepay_gateway_settings_value .= __( 'Payment Type: Payment Component', 'multisafepay' ) . '. ';
273 }
274 if ( ! empty( $woocommerce_payment_gateway->is_tokenization_enabled() ) ) {
275 $multisafepay_gateway_settings_value .= __( 'Recurring payments: ', 'multisafepay' ) . ( $woocommerce_payment_gateway->is_tokenization_enabled() ? __( 'Enabled', 'multisafepay' ) : __( 'Disabled', 'multisafepay' ) ) . '. ';
276 }
277 if ( ! empty( $woocommerce_payment_gateway->user_roles ) ) {
278 $multisafepay_gateway_settings_value .= __( 'User Roles: ', 'multisafepay' ) . implode( ', ', $woocommerce_payment_gateway->user_roles ) . '. ';
279 }
280 $multisafepay_gateway_settings['settings'][ $woocommerce_payment_gateway->id ]['label'] = $woocommerce_payment_gateway->get_payment_method_title();
281 $multisafepay_gateway_settings['settings'][ $woocommerce_payment_gateway->id ]['value'] = $multisafepay_gateway_settings_value;
282 }
283 }
284 return $multisafepay_gateway_settings;
285 }
286
287 /**
288 * Return an array with information about the MultiSafepay plugin settings
289 *
290 * @return array
291 */
292 public function get_system_report_multisafepay_settings(): array {
293 $multisafepay_settings = array(
294 'title' => __( 'MultiSafepay Settings', 'multisafepay' ),
295 'settings' => array(
296 'sdk_version' => array(
297 'label' => __( 'SDK version', 'multisafepay' ),
298 'value' => Version::SDK_VERSION,
299 ),
300 'test_mode' => array(
301 'label' => __( 'Test mode', 'multisafepay' ),
302 'value' => get_option( 'multisafepay_testmode', false ) ? __( 'Enabled', 'multisafepay' ) : __( 'Disabled', 'multisafepay' ),
303 ),
304 'debug_mode' => array(
305 'label' => __( 'Debug mode', 'multisafepay' ),
306 'value' => get_option( 'multisafepay_debugmode', false ) ? __( 'Enabled', 'multisafepay' ) : __( 'Disabled', 'multisafepay' ),
307 ),
308 'order_request_description' => array(
309 'label' => __( 'Order description', 'multisafepay' ),
310 'value' => get_option( 'multisafepay_order_request_description' ),
311 ),
312 'trigger_transaction_to_invoiced' => array(
313 'label' => __( 'Trigger to invoiced', 'multisafepay' ),
314 'value' => get_option( 'multisafepay_trigger_transaction_to_invoiced' ),
315 ),
316 'trigger_transaction_to_shipped' => array(
317 'label' => __( 'Trigger to shipped', 'multisafepay' ),
318 'value' => get_option( 'multisafepay_trigger_transaction_to_shipped' ),
319 ),
320 'final_order_status' => array(
321 'label' => __( 'Is completed the final order status?', 'multisafepay' ),
322 'value' => $this->get_final_order_status(),
323 ),
324 'redirect_after_cancel' => array(
325 'label' => __( 'Redirect after cancel', 'multisafepay' ),
326 'value' => ucfirst( get_option( 'multisafepay_redirect_after_cancel', 'cart' ) ) . ' page',
327 ),
328 'second_chance' => array(
329 'label' => __( 'Second chance', 'multisafepay' ),
330 'value' => (bool) get_option( 'multisafepay_second_chance', false ) ? __( 'Enabled', 'multisafepay' ) : __( 'Disabled', 'multisafepay' ),
331 ),
332 ),
333 );
334 $order_statuses = SettingsFields::get_multisafepay_order_statuses();
335 unset( $order_statuses['completed_status'] );
336 foreach ( $order_statuses as $key => $order_status ) {
337 $multisafepay_settings['settings'][ sanitize_title( $key ) ]['label'] = sprintf( __( 'Default order status for %s', 'multisafepay' ), $order_status['label'] ); // phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment
338 $multisafepay_settings['settings'][ sanitize_title( $key ) ]['value'] = get_option( 'multisafepay_' . $key, $order_status['default'] );
339 }
340
341 return $multisafepay_settings;
342 }
343
344 /**
345 * Return an array with information about the active theme in WordPress
346 *
347 * @return array
348 */
349 public function get_system_report_theme_settings(): array {
350 $theme = $this->report['theme'];
351 $theme_settings = array(
352 'title' => __( 'Theme settings', 'multisafepay' ),
353 'settings' => array(
354 'theme_name' => array(
355 'label' => __( 'Theme Name', 'multisafepay' ),
356 'value' => $theme['name'],
357 ),
358 'version' => array(
359 'label' => __( 'Version', 'multisafepay' ),
360 'value' => $theme['version'],
361 ),
362 'author_url' => array(
363 'label' => __( 'Author URL', 'multisafepay' ),
364 'value' => $theme['author_url'],
365 ),
366 'child_theme' => array(
367 'label' => __( 'Child theme', 'multisafepay' ),
368 'value' => $theme['is_child_theme'] ? 'Yes' : 'No',
369 ),
370 'woocommerce_support' => array(
371 'label' => __( 'WooCommerce support', 'multisafepay' ),
372 'value' => $theme['has_woocommerce_support'] ? 'Yes' : 'No',
373 ),
374 ),
375 );
376 if ( $theme['is_child_theme'] ) {
377 $theme_settings['settings']['parent_theme_name'] = array(
378 'label' => __( 'Parent theme name', 'multisafepay' ),
379 'value' => $theme['parent_name'],
380 );
381 $theme_settings['settings']['parent_theme_version'] = array(
382 'label' => __( 'Parent theme version', 'multisafepay' ),
383 'value' => $theme['parent_version'],
384 );
385 $theme_settings['settings']['parent_theme_author_url'] = array(
386 'label' => __( 'Parent theme author URL', 'multisafepay' ),
387 'value' => $theme['parent_author_url'],
388 );
389 }
390 return $theme_settings;
391 }
392
393 /**
394 * Return an array with information about the theme`s templates used by WooCommerce
395 *
396 * @return array
397 */
398 public function get_system_report_templates_settings(): array {
399 $theme = $this->report['theme'];
400 $template_settings = array(
401 'title' => __( 'Template settings', 'multisafepay' ),
402 'settings' => array(
403 'overrides' => array(
404 'label' => __( 'Overrides WooCommerce templates', 'multisafepay' ),
405 'value' => ( ! empty( $theme['overrides'] ) ) ? __( 'Yes', 'multisafepay' ) : __( 'No', 'multisafepay' ),
406 ),
407 ),
408 );
409 if ( ! empty( $this->get_overrided_templates() ) ) {
410 $template_settings['settings']['has_outdated_templates'] = array(
411 'label' => __( 'Has outdated templates', 'multisafepay' ),
412 'value' => $theme['has_outdated_templates'] ? __( 'Has outdated templates', 'multisafepay' ) : __( 'It does not have outdated templates', 'multisafepay' ),
413 );
414 $template_settings['settings']['templates_overwritten'] = array(
415 'label' => __( 'Templates overwritten', 'multisafepay' ),
416 'value' => $this->get_overrided_templates(),
417 );
418 }
419 return $template_settings;
420 }
421
422 /**
423 * Return an array with information about the active plugins
424 *
425 * @return array
426 */
427 public function get_system_report_active_plugins(): array {
428 $active_plugins = $this->report['active_plugins'];
429 $active_plugins_settings = array(
430 'title' => __( 'Active plugins', 'multisafepay' ),
431 'settings' => array(),
432
433 );
434 foreach ( $active_plugins as $active_plugin ) {
435 $active_plugins_settings['settings'][ sanitize_title( $active_plugin['name'] ) ]['label'] = $active_plugin['name'] . ' (version: ' . $active_plugin['version'] . ')';
436 $active_plugins_settings['settings'][ sanitize_title( $active_plugin['name'] ) ]['value'] = ( ! empty( $active_plugin['url'] ) ) ? $active_plugin['url'] : '';
437 }
438 return $active_plugins_settings;
439 }
440
441
442 /**
443 * Return a string with the product taxonomies
444 *
445 * @param array $taxonomies
446 * @return string
447 */
448 private function get_product_taxonomies( array $taxonomies ): string {
449 $display_terms = array();
450 foreach ( $taxonomies as $slug => $name ) {
451 $display_terms[] = strtolower( $name ) . ' (' . $slug . ')';
452 }
453 return implode( ', ', $display_terms );
454 }
455
456 /**
457 * Return an array with the countries in which the webshop sells.
458 *
459 * @return array
460 */
461 private function get_allowed_countries() {
462 $base = new WC_Countries();
463 return $base->get_allowed_countries();
464 }
465
466 /**
467 * Return a string with the information of each standard tax rate
468 *
469 * @return string
470 */
471 private function get_woocommerce_standard_rates() {
472 $standard_tax_rates = WC_Tax::get_rates_for_tax_class( '' );
473 if ( empty( $standard_tax_rates ) ) {
474 return __( 'There are not standard tax rates registered', 'multisafepay' );
475 }
476 $standard_rates = PHP_EOL;
477 foreach ( $standard_tax_rates as $standard_tax_rate ) {
478 if ( ! empty( $standard_tax_rate->tax_rate ) ) {
479 $standard_rates .= 'Tax rate: ' . $standard_tax_rate->tax_rate . '.';
480 }
481 if ( ! empty( $standard_tax_rate->tax_rate_name ) ) {
482 $standard_rates .= ' Rate name: ' . $standard_tax_rate->tax_rate_name . '.';
483 }
484 if ( ! empty( $standard_tax_rate->tax_rate_country ) ) {
485 $standard_rates .= ' Country: ' . $standard_tax_rate->tax_rate_country . '.';
486 }
487 if ( ! empty( $standard_tax_rate->tax_rate_state ) ) {
488 $standard_rates .= ' State: ' . $standard_tax_rate->tax_rate_state . '.';
489 }
490 if ( ! empty( $standard_tax_rate->tax_rate_priority ) ) {
491 $standard_rates .= ' Priority: ' . $standard_tax_rate->tax_rate_priority . '.';
492 }
493 if ( ! empty( $standard_tax_rate->tax_rate_compound ) ) {
494 $standard_rates .= ' Compound: ' . $standard_tax_rate->tax_rate_compound . '.';
495 }
496 if ( ! empty( $standard_tax_rate->tax_rate_shipping ) ) {
497 $standard_rates .= ' Shipping: ' . $standard_tax_rate->tax_rate_shipping . '.';
498 }
499 $standard_rates .= PHP_EOL;
500 }
501 return $standard_rates;
502 }
503
504 /**
505 * Return an array with the information of each non standard tax rate
506 *
507 * @return array
508 */
509 private function get_non_standard_tax_rates() {
510 $tax_classes = WC_Tax::get_tax_classes();
511 $non_standard_tax_rate = array();
512 foreach ( $tax_classes as $tax_class ) {
513 $tax_rates = WC_Tax::get_rates_for_tax_class( $tax_class );
514 if ( ! empty( $tax_rates ) ) {
515 $non_standard_tax_rate[ sanitize_title( $tax_class ) ]['label'] = $tax_class;
516 $non_standard_tax_rate[ sanitize_title( $tax_class ) ]['value'] = $this->extract_tax_rate_value( $tax_rates );
517 }
518 }
519 return $non_standard_tax_rate;
520 }
521
522 /**
523 * Returns a string with the information of tax the rates
524 *
525 * @param array $tax_rates
526 * @return string
527 */
528 public function extract_tax_rate_value( $tax_rates ): string {
529 $tax_rate_value = PHP_EOL;
530 foreach ( $tax_rates as $tax_rate ) {
531 if ( ! empty( $tax_rate->tax_rate ) ) {
532 $tax_rate_value .= 'Tax rate: ' . $tax_rate->tax_rate . '.';
533 }
534 if ( ! empty( $tax_rate->tax_rate_name ) ) {
535 $tax_rate_value .= ' Rate name: ' . $tax_rate->tax_rate_name . '.';
536 }
537 if ( ! empty( $tax_rate->tax_rate_country ) ) {
538 $tax_rate_value .= ' Country: ' . $tax_rate->tax_rate_country . '.';
539 }
540 if ( ! empty( $tax_rate->tax_rate_state ) ) {
541 $tax_rate_value .= ' State: ' . $tax_rate->tax_rate_state . '.';
542 }
543 if ( ! empty( $tax_rate->tax_rate_priority ) ) {
544 $tax_rate_value .= ' Priority: ' . $tax_rate->tax_rate_priority . '.';
545 }
546 if ( ! empty( $tax_rate->tax_rate_compound ) ) {
547 $tax_rate_value .= ' Compound: ' . $tax_rate->tax_rate_compound . '.';
548 }
549 if ( ! empty( $tax_rate->tax_rate_shipping ) ) {
550 $tax_rate_value .= ' Shipping: ' . $tax_rate->tax_rate_shipping . '.';
551 }
552 $tax_rate_value .= PHP_EOL;
553 }
554 return $tax_rate_value;
555 }
556
557 /**
558 * Return information about the base location of the webshop
559 *
560 * @return array
561 */
562 private function get_base_store_information() {
563 $base = new WC_Countries();
564 return array(
565 'country' => $base->get_base_country(),
566 'state' => $base->get_base_state(),
567 'city' => $base->get_base_city(),
568 'postcode' => $base->get_base_postcode(),
569 );
570 }
571
572 /**
573 * Return information about the overrided templates used by WooCommerce
574 *
575 * @return string
576 */
577 private function get_overrided_templates() {
578 $theme = $this->report['theme'];
579 $templates = array();
580 foreach ( $theme['overrides'] as $template ) {
581 $templates[] = $template['file'];
582 }
583 return implode( ', ', $templates );
584 }
585
586 /**
587 * Return the final order status, to be displayed in the system report.
588 *
589 * @return string
590 */
591 private function get_final_order_status(): string {
592 $final_order_statuses = get_option( 'multisafepay_final_order_status', false );
593 return empty( $final_order_statuses ) ? 'No' : 'Yes';
594 }
595
596 /**
597 * Return in plain text all the information to be displayed in a textarea read only section.
598 *
599 * @return string
600 */
601 public function get_plain_text_system_status_report() {
602 $status_report = $this->get_multisafepay_system_status_report();
603 $plain_text_status_report = '';
604 $plain_text_status_report .= '=================================' . PHP_EOL;
605 $plain_text_status_report .= PHP_EOL;
606 foreach ( $status_report as $status_report_section ) {
607 $plain_text_status_report .= $status_report_section['title'] . PHP_EOL;
608 foreach ( $status_report_section['settings'] as $key => $value ) {
609 $plain_text_status_report .= $value['label'] . ': ' . $value['value'] . PHP_EOL;
610 }
611 $plain_text_status_report .= PHP_EOL;
612 $plain_text_status_report .= '=================================' . PHP_EOL;
613 $plain_text_status_report .= PHP_EOL;
614 }
615 return $plain_text_status_report;
616 }
617
618 }
619