2022-06-23 01:54:38 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { useSelect } from '@wordpress/data';
|
|
|
|
|
|
|
|
import {
|
|
|
|
PLUGINS_STORE_NAME,
|
|
|
|
SETTINGS_STORE_NAME,
|
|
|
|
ONBOARDING_STORE_NAME,
|
|
|
|
} from '@woocommerce/data';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { getCountryCode } from '~/dashboard/utils';
|
|
|
|
import WooCommerceServicesItem from './experimental-woocommerce-services-item';
|
|
|
|
import { ShippingRecommendationsList } from './shipping-recommendations';
|
|
|
|
import './shipping-recommendations.scss';
|
2022-08-29 09:25:24 +00:00
|
|
|
import { ShippingTour } from '../guided-tours/shipping-tour';
|
2022-06-23 01:54:38 +00:00
|
|
|
|
|
|
|
const ShippingRecommendations: React.FC = () => {
|
|
|
|
const {
|
|
|
|
activePlugins,
|
|
|
|
installedPlugins,
|
|
|
|
countryCode,
|
|
|
|
isJetpackConnected,
|
|
|
|
isSellingDigitalProductsOnly,
|
|
|
|
} = useSelect( ( select ) => {
|
2022-08-08 05:25:46 +00:00
|
|
|
const settings = select( SETTINGS_STORE_NAME ).getSettings( 'general' );
|
2022-06-23 01:54:38 +00:00
|
|
|
|
|
|
|
const {
|
|
|
|
getActivePlugins,
|
|
|
|
getInstalledPlugins,
|
|
|
|
isJetpackConnected: _isJetpackConnected,
|
|
|
|
} = select( PLUGINS_STORE_NAME );
|
|
|
|
|
|
|
|
const profileItems = select( ONBOARDING_STORE_NAME ).getProfileItems()
|
|
|
|
.product_types;
|
|
|
|
|
|
|
|
return {
|
|
|
|
activePlugins: getActivePlugins(),
|
|
|
|
installedPlugins: getInstalledPlugins(),
|
|
|
|
countryCode: getCountryCode(
|
|
|
|
settings.general?.woocommerce_default_country
|
|
|
|
),
|
|
|
|
isJetpackConnected: _isJetpackConnected(),
|
|
|
|
isSellingDigitalProductsOnly:
|
|
|
|
profileItems?.length === 1 && profileItems[ 0 ] === 'downloads',
|
|
|
|
};
|
|
|
|
} );
|
|
|
|
|
|
|
|
if (
|
|
|
|
activePlugins.includes( 'woocommerce-services' ) &&
|
|
|
|
isJetpackConnected
|
|
|
|
) {
|
2022-08-29 09:25:24 +00:00
|
|
|
return <ShippingTour showShippingRecommendationsStep={ false } />;
|
2022-06-23 01:54:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( countryCode !== 'US' || isSellingDigitalProductsOnly ) {
|
2022-08-29 09:25:24 +00:00
|
|
|
return <ShippingTour showShippingRecommendationsStep={ false } />;
|
2022-06-23 01:54:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2022-08-29 09:25:24 +00:00
|
|
|
<>
|
|
|
|
<ShippingTour showShippingRecommendationsStep={ true } />
|
|
|
|
<ShippingRecommendationsList>
|
|
|
|
<WooCommerceServicesItem
|
|
|
|
isWCSInstalled={ installedPlugins.includes(
|
|
|
|
'woocommerce-services'
|
|
|
|
) }
|
|
|
|
/>
|
|
|
|
</ShippingRecommendationsList>
|
|
|
|
</>
|
2022-06-23 01:54:38 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ShippingRecommendations;
|