Local Pickup: hide regular shipping rates when Local pickup is selected.

This commit is contained in:
Mike Jolley 2023-01-12 11:55:54 +00:00 committed by Nadir Seghir
parent 7bfda113b0
commit 5076541597
3 changed files with 8 additions and 12 deletions

View File

@ -34,6 +34,7 @@ interface CheckoutAddress {
forcedBillingAddress: boolean; forcedBillingAddress: boolean;
useBillingAsShipping: boolean; useBillingAsShipping: boolean;
needsShipping: boolean; needsShipping: boolean;
showShippingMethods: boolean;
} }
/** /**
@ -98,6 +99,7 @@ export const useCheckoutAddress = (): CheckoutAddress => {
needsShipping, needsShipping,
showShippingFields: showShippingFields:
! forcedBillingAddress && needsShipping && ! prefersCollection, ! forcedBillingAddress && needsShipping && ! prefersCollection,
showShippingMethods: needsShipping && ! prefersCollection,
showBillingFields: showBillingFields:
! needsShipping || ! useShippingAsBilling || prefersCollection, ! needsShipping || ! useShippingAsBilling || prefersCollection,
forcedBillingAddress, forcedBillingAddress,

View File

@ -46,9 +46,9 @@ export const Edit = ( {
'activeShippingZones' 'activeShippingZones'
) as shippingAdminLink[]; ) as shippingAdminLink[];
const { showShippingFields } = useCheckoutAddress(); const { showShippingMethods } = useCheckoutAddress();
if ( ! showShippingFields ) { if ( ! showShippingMethods ) {
return null; return null;
} }

View File

@ -32,18 +32,12 @@ const FrontendBlock = ( {
children: JSX.Element; children: JSX.Element;
className?: string; className?: string;
} ) => { } ) => {
const { checkoutIsProcessing, prefersCollection } = useSelect( const checkoutIsProcessing = useSelect( ( select ) =>
( select ) => { select( CHECKOUT_STORE_KEY ).isProcessing()
const checkoutStore = select( CHECKOUT_STORE_KEY );
return {
checkoutIsProcessing: checkoutStore.isProcessing(),
prefersCollection: checkoutStore.prefersCollection(),
};
}
); );
const { needsShipping } = useCheckoutAddress(); const { showShippingMethods } = useCheckoutAddress();
if ( ! needsShipping || prefersCollection ) { if ( ! showShippingMethods ) {
return null; return null;
} }