fix: shipping tour should not show usps/dhl to non-us merchants (#44765)

* fix: shipping tour should not show usps/dhl to non-us merchants

* lint
This commit is contained in:
RJ 2024-02-20 14:33:01 +09:00 committed by GitHub
parent 2f6818772e
commit 7f01490fd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 2 deletions

View File

@ -13,6 +13,10 @@ import {
} from '@wordpress/element';
import { OPTIONS_STORE_NAME } from '@woocommerce/data';
import { recordEvent } from '@woocommerce/tracks';
/**
* Internal dependencies
*/
import { getCountryCode } from '~/dashboard/utils';
const REVIEWED_DEFAULTS_OPTION =
'woocommerce_admin_reviewed_default_shipping_zones';
@ -37,6 +41,7 @@ const useShowShippingTour = () => {
const {
hasCreatedDefaultShippingZones,
hasReviewedDefaultShippingOptions,
businessCountry,
isLoading,
} = useSelect( ( select ) => {
const { hasFinishedResolution, getOption } =
@ -49,11 +54,17 @@ const useShowShippingTour = () => {
] ) &&
! hasFinishedResolution( 'getOption', [
REVIEWED_DEFAULTS_OPTION,
] ) &&
! hasFinishedResolution( 'getOption', [
'woocommerce_default_country',
] ),
hasCreatedDefaultShippingZones:
getOption( CREATED_DEFAULTS_OPTION ) === 'yes',
hasReviewedDefaultShippingOptions:
getOption( REVIEWED_DEFAULTS_OPTION ) === 'yes',
businessCountry: getCountryCode(
getOption( 'woocommerce_default_country' ) as string
),
};
} );
@ -64,6 +75,7 @@ const useShowShippingTour = () => {
! isLoading &&
hasCreatedDefaultShippingZones &&
! hasReviewedDefaultShippingOptions,
isUspsDhlEligible: businessCountry === 'US',
};
};
@ -203,7 +215,7 @@ export const ShippingTour: React.FC< {
showShippingRecommendationsStep: boolean;
} > = ( { showShippingRecommendationsStep } ) => {
const { updateOptions } = useDispatch( OPTIONS_STORE_NAME );
const { show: showTour } = useShowShippingTour();
const { show: showTour, isUspsDhlEligible } = useShowShippingTour();
const [ step, setStepNumber ] = useState( 0 );
const { createNotice } = useDispatch( 'core/notices' );
@ -326,7 +338,7 @@ export const ShippingTour: React.FC< {
const isWcsSectionPresent = document.querySelector( WCS_LINK_SELECTOR );
if ( isWcsSectionPresent ) {
if ( isWcsSectionPresent && isUspsDhlEligible ) {
tourConfig.steps.push( {
referenceElements: {
desktop: WCS_LINK_SELECTOR,

View File

@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: Fixed shipping tour so that it doesn't show USPS/DHL for non-US customers