Fix country field is empty when navigating back to the store details tab (#34484)
* Add is_store_country_set to onboarding profile items * Fix country field is empty when navigating back to store details tab * Add changelog
This commit is contained in:
parent
9d23439136
commit
f813153ac5
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: add
|
||||||
|
|
||||||
|
Add is_store_country_set field to profileItems
|
|
@ -31,6 +31,7 @@ export const defaultState: OnboardingState = {
|
||||||
wccom_connected: null,
|
wccom_connected: null,
|
||||||
is_agree_marketing: null,
|
is_agree_marketing: null,
|
||||||
store_email: null,
|
store_email: null,
|
||||||
|
is_store_country_set: null,
|
||||||
},
|
},
|
||||||
emailPrefill: '',
|
emailPrefill: '',
|
||||||
paymentMethods: [],
|
paymentMethods: [],
|
||||||
|
|
|
@ -142,6 +142,7 @@ export type ProfileItems = {
|
||||||
wccom_connected?: boolean | null;
|
wccom_connected?: boolean | null;
|
||||||
is_agree_marketing?: boolean | null;
|
is_agree_marketing?: boolean | null;
|
||||||
store_email?: string | null;
|
store_email?: string | null;
|
||||||
|
is_store_country_set?: boolean | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldLocale = {
|
export type FieldLocale = {
|
||||||
|
|
|
@ -166,6 +166,9 @@ export class StoreDetails extends Component {
|
||||||
const profileItemsToUpdate = {
|
const profileItemsToUpdate = {
|
||||||
is_agree_marketing: values.isAgreeMarketing,
|
is_agree_marketing: values.isAgreeMarketing,
|
||||||
store_email: values.storeEmail,
|
store_email: values.storeEmail,
|
||||||
|
is_store_country_set:
|
||||||
|
typeof values.countryState === 'string' &&
|
||||||
|
values.countryState !== '',
|
||||||
};
|
};
|
||||||
|
|
||||||
const region = getCurrencyRegion( values.countryState );
|
const region = getCurrencyRegion( values.countryState );
|
||||||
|
@ -464,12 +467,12 @@ export default compose(
|
||||||
errorsRef.current = {
|
errorsRef.current = {
|
||||||
settings: getSettingsError( 'general' ),
|
settings: getSettingsError( 'general' ),
|
||||||
};
|
};
|
||||||
// Check if a store address is set so that we don't default
|
// Check if a store country is set so that we don't default
|
||||||
// to WooCommerce's default country of the UK.
|
// to WooCommerce's default country of the US:CA.
|
||||||
const countryState =
|
const countryState = profileItems.is_store_country_set
|
||||||
( settings.woocommerce_store_address &&
|
? settings.woocommerce_default_country
|
||||||
settings.woocommerce_default_country ) ||
|
: '';
|
||||||
'';
|
|
||||||
getCountries();
|
getCountries();
|
||||||
getLocales();
|
getLocales();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Fix country field is empty when navigating back to "Store Details" tab
|
|
@ -261,21 +261,21 @@ class OnboardingProfile extends \WC_REST_Data_Controller {
|
||||||
*/
|
*/
|
||||||
public static function get_profile_properties() {
|
public static function get_profile_properties() {
|
||||||
$properties = array(
|
$properties = array(
|
||||||
'completed' => array(
|
'completed' => array(
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => __( 'Whether or not the profile was completed.', 'woocommerce' ),
|
'description' => __( 'Whether or not the profile was completed.', 'woocommerce' ),
|
||||||
'context' => array( 'view' ),
|
'context' => array( 'view' ),
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
'validate_callback' => 'rest_validate_request_arg',
|
'validate_callback' => 'rest_validate_request_arg',
|
||||||
),
|
),
|
||||||
'skipped' => array(
|
'skipped' => array(
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => __( 'Whether or not the profile was skipped.', 'woocommerce' ),
|
'description' => __( 'Whether or not the profile was skipped.', 'woocommerce' ),
|
||||||
'context' => array( 'view' ),
|
'context' => array( 'view' ),
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
'validate_callback' => 'rest_validate_request_arg',
|
'validate_callback' => 'rest_validate_request_arg',
|
||||||
),
|
),
|
||||||
'industry' => array(
|
'industry' => array(
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'description' => __( 'Industry.', 'woocommerce' ),
|
'description' => __( 'Industry.', 'woocommerce' ),
|
||||||
'context' => array( 'view' ),
|
'context' => array( 'view' ),
|
||||||
|
@ -285,7 +285,7 @@ class OnboardingProfile extends \WC_REST_Data_Controller {
|
||||||
'type' => 'object',
|
'type' => 'object',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'product_types' => array(
|
'product_types' => array(
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'description' => __( 'Types of products sold.', 'woocommerce' ),
|
'description' => __( 'Types of products sold.', 'woocommerce' ),
|
||||||
'context' => array( 'view' ),
|
'context' => array( 'view' ),
|
||||||
|
@ -297,7 +297,7 @@ class OnboardingProfile extends \WC_REST_Data_Controller {
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'product_count' => array(
|
'product_count' => array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __( 'Number of products to be added.', 'woocommerce' ),
|
'description' => __( 'Number of products to be added.', 'woocommerce' ),
|
||||||
'context' => array( 'view' ),
|
'context' => array( 'view' ),
|
||||||
|
@ -311,7 +311,7 @@ class OnboardingProfile extends \WC_REST_Data_Controller {
|
||||||
'1000+',
|
'1000+',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'selling_venues' => array(
|
'selling_venues' => array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __( 'Other places the store is selling products.', 'woocommerce' ),
|
'description' => __( 'Other places the store is selling products.', 'woocommerce' ),
|
||||||
'context' => array( 'view' ),
|
'context' => array( 'view' ),
|
||||||
|
@ -325,7 +325,7 @@ class OnboardingProfile extends \WC_REST_Data_Controller {
|
||||||
'other-woocommerce',
|
'other-woocommerce',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'number_employees' => array(
|
'number_employees' => array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __( 'Number of employees of the store.', 'woocommerce' ),
|
'description' => __( 'Number of employees of the store.', 'woocommerce' ),
|
||||||
'context' => array( 'view' ),
|
'context' => array( 'view' ),
|
||||||
|
@ -340,7 +340,7 @@ class OnboardingProfile extends \WC_REST_Data_Controller {
|
||||||
'not specified',
|
'not specified',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'revenue' => array(
|
'revenue' => array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __( 'Current annual revenue of the store.', 'woocommerce' ),
|
'description' => __( 'Current annual revenue of the store.', 'woocommerce' ),
|
||||||
'context' => array( 'view' ),
|
'context' => array( 'view' ),
|
||||||
|
@ -356,7 +356,7 @@ class OnboardingProfile extends \WC_REST_Data_Controller {
|
||||||
'rather-not-say',
|
'rather-not-say',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'other_platform' => array(
|
'other_platform' => array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __( 'Name of other platform used to sell.', 'woocommerce' ),
|
'description' => __( 'Name of other platform used to sell.', 'woocommerce' ),
|
||||||
'context' => array( 'view' ),
|
'context' => array( 'view' ),
|
||||||
|
@ -374,14 +374,14 @@ class OnboardingProfile extends \WC_REST_Data_Controller {
|
||||||
'other',
|
'other',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'other_platform_name' => array(
|
'other_platform_name' => array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __( 'Name of other platform used to sell (not listed).', 'woocommerce' ),
|
'description' => __( 'Name of other platform used to sell (not listed).', 'woocommerce' ),
|
||||||
'context' => array( 'view' ),
|
'context' => array( 'view' ),
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
'validate_callback' => 'rest_validate_request_arg',
|
'validate_callback' => 'rest_validate_request_arg',
|
||||||
),
|
),
|
||||||
'business_extensions' => array(
|
'business_extensions' => array(
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'description' => __( 'Extra business extensions to install.', 'woocommerce' ),
|
'description' => __( 'Extra business extensions to install.', 'woocommerce' ),
|
||||||
'context' => array( 'view' ),
|
'context' => array( 'view' ),
|
||||||
|
@ -402,7 +402,7 @@ class OnboardingProfile extends \WC_REST_Data_Controller {
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'theme' => array(
|
'theme' => array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __( 'Selected store theme.', 'woocommerce' ),
|
'description' => __( 'Selected store theme.', 'woocommerce' ),
|
||||||
'context' => array( 'view' ),
|
'context' => array( 'view' ),
|
||||||
|
@ -410,34 +410,41 @@ class OnboardingProfile extends \WC_REST_Data_Controller {
|
||||||
'sanitize_callback' => 'sanitize_title_with_dashes',
|
'sanitize_callback' => 'sanitize_title_with_dashes',
|
||||||
'validate_callback' => 'rest_validate_request_arg',
|
'validate_callback' => 'rest_validate_request_arg',
|
||||||
),
|
),
|
||||||
'setup_client' => array(
|
'setup_client' => array(
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => __( 'Whether or not this store was setup for a client.', 'woocommerce' ),
|
'description' => __( 'Whether or not this store was setup for a client.', 'woocommerce' ),
|
||||||
'context' => array( 'view' ),
|
'context' => array( 'view' ),
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
'validate_callback' => 'rest_validate_request_arg',
|
'validate_callback' => 'rest_validate_request_arg',
|
||||||
),
|
),
|
||||||
'wccom_connected' => array(
|
'wccom_connected' => array(
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => __( 'Whether or not the store was connected to WooCommerce.com during the extension flow.', 'woocommerce' ),
|
'description' => __( 'Whether or not the store was connected to WooCommerce.com during the extension flow.', 'woocommerce' ),
|
||||||
'context' => array( 'view' ),
|
'context' => array( 'view' ),
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
'validate_callback' => 'rest_validate_request_arg',
|
'validate_callback' => 'rest_validate_request_arg',
|
||||||
),
|
),
|
||||||
'is_agree_marketing' => array(
|
'is_agree_marketing' => array(
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => __( 'Whether or not this store agreed to receiving marketing contents from WooCommerce.com.', 'woocommerce' ),
|
'description' => __( 'Whether or not this store agreed to receiving marketing contents from WooCommerce.com.', 'woocommerce' ),
|
||||||
'context' => array( 'view' ),
|
'context' => array( 'view' ),
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
'validate_callback' => 'rest_validate_request_arg',
|
'validate_callback' => 'rest_validate_request_arg',
|
||||||
),
|
),
|
||||||
'store_email' => array(
|
'store_email' => array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __( 'Store email address.', 'woocommerce' ),
|
'description' => __( 'Store email address.', 'woocommerce' ),
|
||||||
'context' => array( 'view' ),
|
'context' => array( 'view' ),
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
'validate_callback' => array( __CLASS__, 'rest_validate_marketing_email' ),
|
'validate_callback' => array( __CLASS__, 'rest_validate_marketing_email' ),
|
||||||
),
|
),
|
||||||
|
'is_store_country_set' => array(
|
||||||
|
'type' => 'boolean',
|
||||||
|
'description' => __( 'Whether or not this store country is set via onboarding profiler.', 'woocommerce' ),
|
||||||
|
'context' => array( 'view' ),
|
||||||
|
'readonly' => true,
|
||||||
|
'validate_callback' => array( __CLASS__, 'rest_validate_request_arg' ),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
return apply_filters( 'woocommerce_rest_onboarding_profile_properties', $properties );
|
return apply_filters( 'woocommerce_rest_onboarding_profile_properties', $properties );
|
||||||
|
|
|
@ -107,7 +107,7 @@ class WC_Admin_Tests_API_Onboarding_Profiles extends WC_REST_Unit_Test_Case {
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
$properties = $data['schema']['properties'];
|
$properties = $data['schema']['properties'];
|
||||||
|
|
||||||
$this->assertCount( 16, $properties );
|
$this->assertCount( 17, $properties );
|
||||||
$this->assertArrayHasKey( 'completed', $properties );
|
$this->assertArrayHasKey( 'completed', $properties );
|
||||||
$this->assertArrayHasKey( 'skipped', $properties );
|
$this->assertArrayHasKey( 'skipped', $properties );
|
||||||
$this->assertArrayHasKey( 'industry', $properties );
|
$this->assertArrayHasKey( 'industry', $properties );
|
||||||
|
@ -124,6 +124,7 @@ class WC_Admin_Tests_API_Onboarding_Profiles extends WC_REST_Unit_Test_Case {
|
||||||
$this->assertArrayHasKey( 'setup_client', $properties );
|
$this->assertArrayHasKey( 'setup_client', $properties );
|
||||||
$this->assertArrayHasKey( 'is_agree_marketing', $properties );
|
$this->assertArrayHasKey( 'is_agree_marketing', $properties );
|
||||||
$this->assertArrayHasKey( 'store_email', $properties );
|
$this->assertArrayHasKey( 'store_email', $properties );
|
||||||
|
$this->assertArrayHasKey( 'is_store_country_set', $properties );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue