Local Pickup: set prefersCollection to false if we don't have shipping.

This commit is contained in:
Mike Jolley 2022-12-15 15:26:14 +00:00 committed by Nadir Seghir
parent d9fbaa5ec3
commit 963c8dcebe
1 changed files with 3 additions and 0 deletions

View File

@ -77,6 +77,9 @@ export const isCalculating = ( state: CheckoutState ) => {
export const prefersCollection = ( state: CheckoutState ) => {
if ( state.prefersCollection === undefined ) {
const shippingRates = select( cartStoreKey ).getShippingRates();
if ( ! shippingRates || ! shippingRates.length ) {
return false;
}
const selectedRate = shippingRates[ 0 ].shipping_rates.find(
( rate ) => rate.selected
);