From 0f311f0cbab119cae0c8ec61ec342c9cb99919e0 Mon Sep 17 00:00:00 2001 From: Allen Snook Date: Mon, 19 Jun 2017 12:22:05 -0700 Subject: [PATCH] Add address, address 2, city and postcode to setup wizard --- .../admin/class-wc-admin-setup-wizard.php | 64 ++++++++++++++++--- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/includes/admin/class-wc-admin-setup-wizard.php b/includes/admin/class-wc-admin-setup-wizard.php index 4d7ec407f1d..45bb518b9fe 100644 --- a/includes/admin/class-wc-admin-setup-wizard.php +++ b/includes/admin/class-wc-admin-setup-wizard.php @@ -308,10 +308,19 @@ class WC_Admin_Setup_Wizard { * Location and Tax settings. */ public function wc_setup_location() { - $user_location = WC_Geolocation::geolocate_ip(); - $country = ! empty( $user_location['country'] ) ? $user_location['country'] : 'US'; - $state = ! empty( $user_location['state'] ) ? $user_location['state'] : '*'; - $state = 'US' === $country && '*' === $state ? 'AL' : $state; + $address = WC()->countries->get_base_address(); + $address_2 = WC()->countries->get_base_address_2(); + $city = WC()->countries->get_base_city(); + $state = WC()->countries->get_base_state(); + $country = WC()->countries->get_base_country(); + $postcode = WC()->countries->get_base_postcode(); + + if ( empty( $country ) ) { + $user_location = WC_Geolocation::geolocate_ip(); + $country = ! empty( $user_location['country'] ) ? $user_location['country'] : 'US'; + $state = ! empty( $user_location['state'] ) ? $user_location['state'] : '*'; + $state = 'US' === $country && '*' === $state ? 'AL' : $state; + } // Defaults $currency = get_option( 'woocommerce_currency', 'GBP' ); @@ -324,11 +333,40 @@ class WC_Admin_Setup_Wizard {
- + + + + + + + + + + + + + + + + + @@ -423,14 +461,24 @@ class WC_Admin_Setup_Wizard { public function wc_setup_location_save() { check_admin_referer( 'wc-setup' ); + $address = sanitize_text_field( $_POST['store_address'] ); + $address_2 = sanitize_text_field( $_POST['store_address_2'] ); + $city = sanitize_text_field( $_POST['store_city'] ); $store_location = sanitize_text_field( $_POST['store_location'] ); + $postcode = sanitize_text_field( $_POST['store_postcode'] ); + $currency_code = sanitize_text_field( $_POST['currency_code'] ); $currency_pos = sanitize_text_field( $_POST['currency_pos'] ); $decimal_sep = sanitize_text_field( $_POST['decimal_sep'] ); $num_decimals = sanitize_text_field( $_POST['num_decimals'] ); $thousand_sep = sanitize_text_field( $_POST['thousand_sep'] ); + update_option( 'woocommerce_store_address', $address ); + update_option( 'woocommerce_store_address_2', $address_2 ); + update_option( 'woocommerce_store_city', $city ); update_option( 'woocommerce_default_country', $store_location ); + update_option( 'woocommerce_store_postcode', $postcode ); + update_option( 'woocommerce_currency', $currency_code ); update_option( 'woocommerce_currency_pos', $currency_pos ); update_option( 'woocommerce_price_decimal_sep', $decimal_sep );
+ + +
  + + +
  + + +
  + + +
  - + +