Check for connected JP+WCS and non-ShipStation country for shipping defaults. (https://github.com/woocommerce/woocommerce-admin/pull/5320)

Fix UK country code too.
This commit is contained in:
Jeff Stieler 2020-10-09 16:28:41 -04:00 committed by GitHub
parent b8adfaaa94
commit 8a0f580d1b
2 changed files with 34 additions and 7 deletions

View File

@ -94,12 +94,6 @@ export function getAllTasks( {
purchaseAndInstallText = sprintf( purchaseAndInstallFormat, itemName );
}
const shippingCompleted =
shippingZonesCount > 0 &&
isJetpackConnected &&
activePlugins.includes( 'woocommerce-services' ) &&
! [ 'AU', 'NZ', 'UK' ].includes( countryCode );
const tasks = [
{
key: 'store_details',
@ -224,7 +218,7 @@ export function getAllTasks( {
} );
updateQueryString( { task: 'shipping' } );
},
completed: shippingCompleted,
completed: shippingZonesCount > 0,
visible:
( productTypes && productTypes.includes( 'physical' ) ) ||
hasPhysicalProducts,

View File

@ -25,6 +25,14 @@ class OnboardingSetUpShipping {
'on_onboarding_profile_completed',
)
);
add_action(
'jetpack_authorize_ending_authorized',
array(
__CLASS__,
'on_onboarding_profile_completed',
)
);
}
/**
@ -39,6 +47,31 @@ class OnboardingSetUpShipping {
return;
}
$country_code = WC()->countries->get_base_country();
// Corrolary to the logic in /client/task-list/tasks.js.
// Skip for countries we don't recommend WCS for.
if ( in_array( $country_code, array( 'AU', 'CA', 'GB' ), true ) ) {
return;
}
if (
! class_exists( '\Jetpack_Data' ) ||
! class_exists( '\WC_Connect_Loader' ) ||
! class_exists( '\WC_Connect_Options' )
) {
return;
}
$user_token = \Jetpack_Data::get_access_token( JETPACK_MASTER_USER );
$jetpack_connected = isset( $user_token->external_user_id );
$wcs_version = \WC_Connect_Loader::get_wcs_version();
$wcs_tos_accepted = \WC_Connect_Options::get_option( 'tos_accepted' );
if ( ! $jetpack_connected || ! $wcs_version || ! $wcs_tos_accepted ) {
return;
}
self::set_up_free_local_shipping();
Review_Shipping_Settings::possibly_add_note();
wc_admin_record_tracks_event( 'shipping_automatically_set_up' );