Skip to content
This repository was archived by the owner on Oct 4, 2019. It is now read-only.

Commit e6a4ce0

Browse files
authored
Merge pull request #13 from woocommerce/add/12-store-street-level-address
Filter in new settings for store address, address_2, city and postcode
2 parents cf39631 + 1f353c2 commit e6a4ce0

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

api/class-wc-rest-dev-setting-options-controller.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,57 @@
1414
exit;
1515
}
1616

17+
/**
18+
* Filters new address settings into the settings general endpoint
19+
*
20+
* These new settings are being added to WC 3.x in
21+
* pull request https://github.com/woocommerce/woocommerce/pull/15636
22+
* This filter is used to insert them if not present.
23+
*
24+
* THIS FILTER SHOULD NOT BE PORTED TO WOOCOMMERCE CORE as the above PR
25+
* already takes care of this in WooCommerce core.
26+
*/
27+
function wc_rest_dev_add_address_settings_to_settings_general( $settings ) {
28+
$new_settings = array(
29+
array(
30+
'id' => 'woocommerce_store_address',
31+
'type' => 'text',
32+
'option_key' => 'woocommerce_store_address',
33+
'default' => '',
34+
),
35+
array(
36+
'id' => 'woocommerce_store_address_2',
37+
'type' => 'text',
38+
'option_key' => 'woocommerce_store_address_2',
39+
'default' => '',
40+
),
41+
array(
42+
'id' => 'woocommerce_store_city',
43+
'type' => 'text',
44+
'option_key' => 'woocommerce_store_city',
45+
'default' => '',
46+
),
47+
array(
48+
'id' => 'woocommerce_store_postcode',
49+
'type' => 'text',
50+
'option_key' => 'woocommerce_store_postcode',
51+
'default' => '',
52+
),
53+
);
54+
55+
// For each of the new settings, make sure the setting id doesn't
56+
// already exist in the settings array and then add it
57+
$ids = array_column( $settings, 'id' );
58+
foreach ( $new_settings as $new_setting ) {
59+
if ( ! in_array( $new_setting['id'], $ids ) ) {
60+
$settings[] = $new_setting;
61+
}
62+
}
63+
64+
return $settings;
65+
}
66+
add_filter( 'woocommerce_settings-general', 'wc_rest_dev_add_address_settings_to_settings_general', 999 );
67+
1768
/**
1869
* REST API Setting Options controller class.
1970
*

0 commit comments

Comments
 (0)