From d191ecc275c8654efbb11409a6f1002c3dacafff Mon Sep 17 00:00:00 2001 From: RJ <27843274+rjchow@users.noreply.github.com> Date: Mon, 12 Sep 2022 11:46:40 +0800 Subject: [PATCH] fix: set shipping defaults when address details not filled out (#34610) --- ...fix-shipping-defaults-when-address-not-set | 4 ++++ .../src/Internal/Admin/Homescreen.php | 19 +++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 plugins/woocommerce/changelog/fix-shipping-defaults-when-address-not-set diff --git a/plugins/woocommerce/changelog/fix-shipping-defaults-when-address-not-set b/plugins/woocommerce/changelog/fix-shipping-defaults-when-address-not-set new file mode 100644 index 00000000000..1f99b6f5bd0 --- /dev/null +++ b/plugins/woocommerce/changelog/fix-shipping-defaults-when-address-not-set @@ -0,0 +1,4 @@ +Significance: minor +Type: fix + +Shipping defaults is now set when the user completes onboarding profiler, even if they did not set their address details diff --git a/plugins/woocommerce/src/Internal/Admin/Homescreen.php b/plugins/woocommerce/src/Internal/Admin/Homescreen.php index cac3656d4fc..9c3d0c230f0 100644 --- a/plugins/woocommerce/src/Internal/Admin/Homescreen.php +++ b/plugins/woocommerce/src/Internal/Admin/Homescreen.php @@ -97,9 +97,15 @@ class Homescreen { return $settings; } - $user_skipped_obw = $settings['onboarding']['profile']['skipped'] ?? false; - $store_address = $settings['preloadSettings']['general']['woocommerce_store_address'] ?? ''; - $product_types = $settings['onboarding']['profile']['product_types'] ?? array(); + $user_skipped_obw = $settings['onboarding']['profile']['skipped'] ?? false; + $store_address = $settings['preloadSettings']['general']['woocommerce_store_address'] ?? ''; + $product_types = $settings['onboarding']['profile']['product_types'] ?? array(); + $user_has_set_store_country = $settings['onboarding']['profile']['is_store_country_set'] ?? false; + + // Do not proceed if user has not filled out their country in the onboarding profiler. + if ( ! $user_has_set_store_country ) { + return $settings; + } // If user skipped the obw or has not completed the store_details // then we assume the user is going to sell physical products. @@ -114,13 +120,6 @@ class Homescreen { $country_code = wc_format_country_state_string( $settings['preloadSettings']['general']['woocommerce_default_country'] )['country']; $country_name = WC()->countries->get_countries()[ $country_code ] ?? null; - // we also need to make sure woocommerce_store_address is not empty - // to make sure store country is set by an actual user - // since woocommerce_store_address is set to US:CA by default. - if ( '' === $country_code || null === $country_name || '' === $store_address ) { - return $settings; - } - $is_jetpack_installed = in_array( 'jetpack', $settings['plugins']['installedPlugins'] ?? array(), true ); $is_wcs_installed = in_array( 'woocommerce-services', $settings['plugins']['installedPlugins'] ?? array(), true );