Settings: Fix wsod when no actionable statuses are set. (https://github.com/woocommerce/woocommerce-admin/pull/2577)
* Fix wsod when no actionable statuses are set. * Updates per feedback.
This commit is contained in:
parent
ca7f706620
commit
995f26250e
|
@ -24,6 +24,19 @@ const defaultOrderStatuses = [
|
|||
'pending',
|
||||
'on-hold',
|
||||
];
|
||||
|
||||
const actionableOrderStatuses = Array.isArray(
|
||||
wcSettings.wcAdminSettings.woocommerce_actionable_order_statuses
|
||||
)
|
||||
? wcSettings.wcAdminSettings.woocommerce_actionable_order_statuses
|
||||
: [];
|
||||
|
||||
const excludedOrderStatuses = Array.isArray(
|
||||
wcSettings.wcAdminSettings.woocommerce_excluded_report_order_statuses
|
||||
)
|
||||
? wcSettings.wcAdminSettings.woocommerce_excluded_report_order_statuses
|
||||
: [];
|
||||
|
||||
const orderStatuses = Object.keys( wcSettings.orderStatuses )
|
||||
.filter( status => status !== 'refunded' )
|
||||
.map( key => {
|
||||
|
@ -63,8 +76,7 @@ export const analyticsSettings = applyFilters( SETTINGS_FILTER, [
|
|||
strong: <strong />,
|
||||
},
|
||||
} ),
|
||||
initialValue:
|
||||
[ ...wcSettings.wcAdminSettings.woocommerce_excluded_report_order_statuses ] || [],
|
||||
initialValue: [ ...excludedOrderStatuses ],
|
||||
defaultValue: [ 'pending', 'cancelled', 'failed' ],
|
||||
},
|
||||
{
|
||||
|
@ -87,7 +99,7 @@ export const analyticsSettings = applyFilters( SETTINGS_FILTER, [
|
|||
'These orders will show up in the Orders tab under the activity panel.',
|
||||
'woocommerce-admin'
|
||||
),
|
||||
initialValue: [ ...wcSettings.wcAdminSettings.woocommerce_actionable_order_statuses ] || [],
|
||||
initialValue: [ ...actionableOrderStatuses ],
|
||||
defaultValue: DEFAULT_ACTIONABLE_STATUSES,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -628,7 +628,7 @@ class WC_Admin_Loader {
|
|||
$settings['wcAdminSettings'] = array();
|
||||
|
||||
foreach ( $wc_admin_group_settings as $setting ) {
|
||||
if ( ! empty( $setting['id'] ) && ! empty( $setting['value'] ) ) {
|
||||
if ( ! empty( $setting['id'] ) ) {
|
||||
$settings['wcAdminSettings'][ $setting['id'] ] = $setting['value'];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue