1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* WC information for status report. |
4
|
|
|
* |
5
|
|
|
* @package WooCommerce/Utilities |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace WooCommerce\RestApi\Controllers\Version4\Utilities; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* WooEnvironment class. |
12
|
|
|
*/ |
13
|
|
|
class WooEnvironment { |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Get some setting values for the site that are useful for debugging |
17
|
|
|
* purposes. For full settings access, use the settings api. |
18
|
|
|
* |
19
|
|
|
* @return array |
20
|
|
|
*/ |
21
|
|
|
public function get_settings() { |
22
|
|
|
// Get a list of terms used for product/order taxonomies. |
23
|
|
|
$term_response = array(); |
24
|
|
|
$terms = get_terms( 'product_type', array( 'hide_empty' => 0 ) ); |
25
|
|
|
foreach ( $terms as $term ) { |
26
|
|
|
$term_response[ $term->slug ] = strtolower( $term->name ); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
// Get a list of terms used for product visibility. |
30
|
|
|
$product_visibility_terms = array(); |
31
|
|
|
$terms = get_terms( 'product_visibility', array( 'hide_empty' => 0 ) ); |
32
|
|
|
foreach ( $terms as $term ) { |
33
|
|
|
$product_visibility_terms[ $term->slug ] = strtolower( $term->name ); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
// Check if WooCommerce.com account is connected. |
37
|
|
|
$woo_com_connected = 'no'; |
38
|
|
|
$helper_options = get_option( 'woocommerce_helper_data', array() ); |
39
|
|
|
if ( array_key_exists( 'auth', $helper_options ) && ! empty( $helper_options['auth'] ) ) { |
|
|
|
|
40
|
|
|
$woo_com_connected = 'yes'; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
// Return array of useful settings for debugging. |
44
|
|
|
return array( |
45
|
|
|
'api_enabled' => 'yes' === get_option( 'woocommerce_api_enabled' ), |
46
|
|
|
'force_ssl' => 'yes' === get_option( 'woocommerce_force_ssl_checkout' ), |
47
|
|
|
'currency' => get_woocommerce_currency(), |
48
|
|
|
'currency_symbol' => get_woocommerce_currency_symbol(), |
49
|
|
|
'currency_position' => get_option( 'woocommerce_currency_pos' ), |
50
|
|
|
'thousand_separator' => wc_get_price_thousand_separator(), |
51
|
|
|
'decimal_separator' => wc_get_price_decimal_separator(), |
52
|
|
|
'number_of_decimals' => wc_get_price_decimals(), |
53
|
|
|
'geolocation_enabled' => in_array( get_option( 'woocommerce_default_customer_address' ), array( 'geolocation_ajax', 'geolocation' ) ), |
54
|
|
|
'taxonomies' => $term_response, |
55
|
|
|
'product_visibility_terms' => $product_visibility_terms, |
56
|
|
|
'woocommerce_com_connected' => $woo_com_connected, |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|