Fix "Add store details" task fails to mark as completed for selecting Nigeria based address (#38181)

* Fix "add store details" task fails to mark as completed for selecting Nigeria based address while OBW

* Add changelog

* Remove empty line

* Fix lint
This commit is contained in:
Chi-Hsuan Huang 2023-05-10 17:08:33 +08:00 committed by GitHub
parent c3d06ad05f
commit fa658a0e94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix "Add store details" task fails to mark as completed for selecting Nigeria based address

View File

@ -69,6 +69,16 @@ class StoreDetails extends Task {
* @return bool
*/
public function is_complete() {
$country = WC()->countries->get_base_country();
$country_locale = WC()->countries->get_country_locale();
$locale = $country_locale[ $country ] ?? array();
$hide_postcode = $locale['postcode']['hidden'] ?? false;
// If postcode is hidden, just check that the store address and city are set.
if ( $hide_postcode ) {
return get_option( 'woocommerce_store_address', '' ) !== '' && get_option( 'woocommerce_store_city', '' ) !== '';
}
// Mark as completed if the store address, city and postcode are set. We don't need to check the country because it's set by default.
return get_option( 'woocommerce_store_address', '' ) !== '' && get_option( 'woocommerce_store_city', '' ) !== '' &&
get_option( 'woocommerce_store_postcode', '' ) !== '';