diff --git a/plugins/woocommerce-blocks/assets/js/base/context/hooks/use-checkout-address.ts b/plugins/woocommerce-blocks/assets/js/base/context/hooks/use-checkout-address.ts index 543fc8e23fd..c60534e7d73 100644 --- a/plugins/woocommerce-blocks/assets/js/base/context/hooks/use-checkout-address.ts +++ b/plugins/woocommerce-blocks/assets/js/base/context/hooks/use-checkout-address.ts @@ -34,6 +34,7 @@ interface CheckoutAddress { forcedBillingAddress: boolean; useBillingAsShipping: boolean; needsShipping: boolean; + showShippingMethods: boolean; } /** @@ -98,6 +99,7 @@ export const useCheckoutAddress = (): CheckoutAddress => { needsShipping, showShippingFields: ! forcedBillingAddress && needsShipping && ! prefersCollection, + showShippingMethods: needsShipping && ! prefersCollection, showBillingFields: ! needsShipping || ! useShippingAsBilling || prefersCollection, forcedBillingAddress, diff --git a/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/edit.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/edit.tsx index 6ae76c5394a..750a395d2fd 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/edit.tsx +++ b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/edit.tsx @@ -46,9 +46,9 @@ export const Edit = ( { 'activeShippingZones' ) as shippingAdminLink[]; - const { showShippingFields } = useCheckoutAddress(); + const { showShippingMethods } = useCheckoutAddress(); - if ( ! showShippingFields ) { + if ( ! showShippingMethods ) { return null; } diff --git a/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/frontend.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/frontend.tsx index be64d60c887..dd67d39fba5 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/frontend.tsx +++ b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/frontend.tsx @@ -32,18 +32,12 @@ const FrontendBlock = ( { children: JSX.Element; className?: string; } ) => { - const { checkoutIsProcessing, prefersCollection } = useSelect( - ( select ) => { - const checkoutStore = select( CHECKOUT_STORE_KEY ); - return { - checkoutIsProcessing: checkoutStore.isProcessing(), - prefersCollection: checkoutStore.prefersCollection(), - }; - } + const checkoutIsProcessing = useSelect( ( select ) => + select( CHECKOUT_STORE_KEY ).isProcessing() ); - const { needsShipping } = useCheckoutAddress(); + const { showShippingMethods } = useCheckoutAddress(); - if ( ! needsShipping || prefersCollection ) { + if ( ! showShippingMethods ) { return null; }