From 07222c08ffc9650d69c196370958e4e2cea4501f Mon Sep 17 00:00:00 2001 From: Bec Scott Date: Mon, 15 Jun 2020 09:20:52 +1000 Subject: [PATCH] Don't show store location in the tax and shipping tasks if it's already been provided (https://github.com/woocommerce/woocommerce-admin/pull/4507) Co-authored-by: Rebecca Scott --- .../client/task-list/tasks/shipping/index.js | 15 ++++++++++++++- .../client/task-list/tasks/tax.js | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/plugins/woocommerce-admin/client/task-list/tasks/shipping/index.js b/plugins/woocommerce-admin/client/task-list/tasks/shipping/index.js index f3f18a74f0f..7801c475fa2 100644 --- a/plugins/woocommerce-admin/client/task-list/tasks/shipping/index.js +++ b/plugins/woocommerce-admin/client/task-list/tasks/shipping/index.js @@ -111,7 +111,12 @@ class Shipping extends Component { } componentDidUpdate( prevProps, prevState ) { - const { countryCode } = this.props; + const { countryCode, settings } = this.props; + const { + woocommerce_store_address: storeAddress, + woocommerce_default_country: defaultCountry, + woocommerce_store_postcode: storePostCode, + } = settings; const { step } = this.state; if ( @@ -121,6 +126,14 @@ class Shipping extends Component { ) { this.fetchShippingZones(); } + + const isCompleteAddress = Boolean( + storeAddress && defaultCountry && storePostCode + ); + + if ( step === 'store_location' && isCompleteAddress ) { + this.completeStep(); + } } completeStep() { diff --git a/plugins/woocommerce-admin/client/task-list/tasks/tax.js b/plugins/woocommerce-admin/client/task-list/tasks/tax.js index 763e206a67a..c266a7b3b13 100644 --- a/plugins/woocommerce-admin/client/task-list/tasks/tax.js +++ b/plugins/woocommerce-admin/client/task-list/tasks/tax.js @@ -95,7 +95,12 @@ class Tax extends Component { taxSettings, isGeneralSettingsRequesting, } = this.props; - const { woocommerce_calc_taxes: calcTaxes } = generalSettings; + const { + woocommerce_calc_taxes: calcTaxes, + woocommerce_store_address: storeAddress, + woocommerce_default_country: defaultCountry, + woocommerce_store_postcode: storePostCode, + } = generalSettings; const { stepIndex } = this.state; const currentStep = this.getSteps()[ stepIndex ]; const currentStepKey = currentStep && currentStep.key; @@ -132,6 +137,14 @@ class Tax extends Component { this.completeStep(); } + const isCompleteAddress = Boolean( + storeAddress && defaultCountry && storePostCode + ); + + if ( currentStepKey === 'store_location' && isCompleteAddress ) { + this.completeStep(); + } + const { woocommerce_calc_taxes: prevCalcTaxes, } = prevProps.generalSettings;