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,
|
||||
is_agree_marketing: null,
|
||||
store_email: null,
|
||||
is_store_country_set: null,
|
||||
},
|
||||
emailPrefill: '',
|
||||
paymentMethods: [],
|
||||
|
|
|
@ -142,6 +142,7 @@ export type ProfileItems = {
|
|||
wccom_connected?: boolean | null;
|
||||
is_agree_marketing?: boolean | null;
|
||||
store_email?: string | null;
|
||||
is_store_country_set?: boolean | null;
|
||||
};
|
||||
|
||||
export type FieldLocale = {
|
||||
|
|
|
@ -166,6 +166,9 @@ export class StoreDetails extends Component {
|
|||
const profileItemsToUpdate = {
|
||||
is_agree_marketing: values.isAgreeMarketing,
|
||||
store_email: values.storeEmail,
|
||||
is_store_country_set:
|
||||
typeof values.countryState === 'string' &&
|
||||
values.countryState !== '',
|
||||
};
|
||||
|
||||
const region = getCurrencyRegion( values.countryState );
|
||||
|
@ -464,12 +467,12 @@ export default compose(
|
|||
errorsRef.current = {
|
||||
settings: getSettingsError( 'general' ),
|
||||
};
|
||||
// Check if a store address is set so that we don't default
|
||||
// to WooCommerce's default country of the UK.
|
||||
const countryState =
|
||||
( settings.woocommerce_store_address &&
|
||||
settings.woocommerce_default_country ) ||
|
||||
'';
|
||||
// Check if a store country is set so that we don't default
|
||||
// to WooCommerce's default country of the US:CA.
|
||||
const countryState = profileItems.is_store_country_set
|
||||
? settings.woocommerce_default_country
|
||||
: '';
|
||||
|
||||
getCountries();
|
||||
getLocales();
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Fix country field is empty when navigating back to "Store Details" tab
|
|
@ -438,6 +438,13 @@ class OnboardingProfile extends \WC_REST_Data_Controller {
|
|||
'readonly' => true,
|
||||
'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 );
|
||||
|
|
|
@ -107,7 +107,7 @@ class WC_Admin_Tests_API_Onboarding_Profiles extends WC_REST_Unit_Test_Case {
|
|||
$data = $response->get_data();
|
||||
$properties = $data['schema']['properties'];
|
||||
|
||||
$this->assertCount( 16, $properties );
|
||||
$this->assertCount( 17, $properties );
|
||||
$this->assertArrayHasKey( 'completed', $properties );
|
||||
$this->assertArrayHasKey( 'skipped', $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( 'is_agree_marketing', $properties );
|
||||
$this->assertArrayHasKey( 'store_email', $properties );
|
||||
$this->assertArrayHasKey( 'is_store_country_set', $properties );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue