From 5b1281b1d31e63781540332060955f396192c435 Mon Sep 17 00:00:00 2001 From: Thomas Roberts Date: Tue, 2 Aug 2022 11:20:41 +0100 Subject: [PATCH 1/4] Check package length >= 1 to show package name --- .../components/cart-checkout/shipping-rates-control/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx b/assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx index 405f7b218f3..cb91cc82cce 100644 --- a/assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx +++ b/assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx @@ -66,7 +66,7 @@ const Packages = ( { collapsible={ collapsible } collapse={ collapse } showItems={ - showItems || packageData?.shipping_rates?.length > 1 + showItems || packageData?.shipping_rates?.length >= 1 } noResultsMessage={ noResultsMessage } renderOption={ renderOption } From b8e3b8ae4294773413195ebe290391fbae7e74e2 Mon Sep 17 00:00:00 2001 From: Thomas Roberts Date: Tue, 2 Aug 2022 11:53:58 +0100 Subject: [PATCH 2/4] Check shipping rates length in order shipping packages slot --- packages/checkout/components/order-shipping-packages/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/checkout/components/order-shipping-packages/index.js b/packages/checkout/components/order-shipping-packages/index.js index d07a6e95884..220e15e1127 100644 --- a/packages/checkout/components/order-shipping-packages/index.js +++ b/packages/checkout/components/order-shipping-packages/index.js @@ -23,9 +23,10 @@ const Slot = ( { cart, components, context, + shippingRates, } ) => { const { fills } = useSlot( slotName ); - const hasMultiplePackages = fills.length > 1; + const hasMultiplePackages = fills.length > 1 || shippingRates?.length > 1; return ( Date: Tue, 2 Aug 2022 11:54:16 +0100 Subject: [PATCH 3/4] Fix TS error where boolean value could be undefined --- .../components/cart-checkout/shipping-rates-control/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx b/assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx index cb91cc82cce..c70c1acbf6e 100644 --- a/assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx +++ b/assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx @@ -63,8 +63,8 @@ const Packages = ( { key={ packageId } packageId={ packageId } packageData={ packageData } - collapsible={ collapsible } - collapse={ collapse } + collapsible={ !! collapsible } + collapse={ !! collapse } showItems={ showItems || packageData?.shipping_rates?.length >= 1 } From 5125973a1f44000da9960ce5ecaf4801c74c6d55 Mon Sep 17 00:00:00 2001 From: Thomas Roberts Date: Tue, 2 Aug 2022 11:55:10 +0100 Subject: [PATCH 4/4] Show items if there is more than one shipping rate --- .../components/cart-checkout/shipping-rates-control/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx b/assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx index c70c1acbf6e..eea684b19ff 100644 --- a/assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx +++ b/assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx @@ -66,7 +66,7 @@ const Packages = ( { collapsible={ !! collapsible } collapse={ !! collapse } showItems={ - showItems || packageData?.shipping_rates?.length >= 1 + showItems || packageData?.shipping_rates?.length > 1 } noResultsMessage={ noResultsMessage } renderOption={ renderOption } @@ -167,6 +167,7 @@ const ShippingRatesControl = ( { ShippingRatesControlPackage, }, context, + shippingRates, }; const { isEditor } = useEditorContext(); @@ -192,6 +193,7 @@ const ShippingRatesControl = ( { /> 1 } packages={ shippingRates } noResultsMessage={ noResultsMessage } renderOption={ renderOption }