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;
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,

View File

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

View File

@ -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;
}