@@ -27,33 +27,25 @@ class WooCommerceApi
27
27
public function __construct ()
28
28
{
29
29
try {
30
- $ this ->forStore ();
31
- } catch (\Exception $ e ) {
32
- throw new \Exception ($ e ->getMessage (), 1 );
33
- }
34
- }
35
-
36
- public function forStore (string $ store ="" )
37
- {
38
- if ( $ store !=="" ) {
39
- $ store = "multisite. " . $ store ;
40
- }
41
- $ this ->headers = [
42
- 'header_total ' => config ($ store .'.header_total ' ) ?? 'X-WP-Total ' ,
43
- 'header_total_pages ' => config ($ store .'.header_total_pages ' ) ?? 'X-WP-TotalPages ' ,
30
+ $ this ->headers = [
31
+ 'header_total ' => config ('woocommerce.header_total ' ) ?? 'X-WP-Total ' ,
32
+ 'header_total_pages ' => config ('woocommerce.header_total_pages ' ) ?? 'X-WP-TotalPages ' ,
44
33
];
45
34
46
35
$ this ->client = new Client (
47
- config ($ store . ' .store_url ' ),
48
- config ($ store . ' .consumer_key ' ),
49
- config ($ store . ' .consumer_secret ' ),
36
+ config (' woocommerce .store_url ' ),
37
+ config (' woocommerce .consumer_key ' ),
38
+ config (' woocommerce .consumer_secret ' ),
50
39
[
51
- 'version ' => 'wc/ ' .config ($ store . ' .api_version ' ),
52
- 'wp_api ' => config ($ store . ' .wp_api_integration ' ),
53
- 'verify_ssl ' => config ($ store . ' .verify_ssl ' ),
54
- 'query_string_auth ' => config ($ store . ' .query_string_auth ' ),
55
- 'timeout ' => config ($ store . ' .timeout ' ),
40
+ 'version ' => 'wc/ ' .config (' woocommerce .api_version ' ),
41
+ 'wp_api ' => config (' woocommerce .wp_api_integration ' ),
42
+ 'verify_ssl ' => config (' woocommerce .verify_ssl ' ),
43
+ 'query_string_auth ' => config (' woocommerce .query_string_auth ' ),
44
+ 'timeout ' => config (' woocommerce .timeout ' ),
56
45
]
57
46
);
47
+ } catch (\Exception $ e ) {
48
+ throw new \Exception ($ e ->getMessage (), 1 );
49
+ }
58
50
}
59
51
}
0 commit comments