Ensure package names display correctly if only one item is in package (https://github.com/woocommerce/woocommerce-blocks/pull/6815)
* Check package length >= 1 to show package name * Check shipping rates length in order shipping packages slot * Fix TS error where boolean value could be undefined * Show items if there is more than one shipping rate
This commit is contained in:
parent
862477f9aa
commit
0fc1ee46bd
|
@ -63,8 +63,8 @@ const Packages = ( {
|
||||||
key={ packageId }
|
key={ packageId }
|
||||||
packageId={ packageId }
|
packageId={ packageId }
|
||||||
packageData={ packageData }
|
packageData={ packageData }
|
||||||
collapsible={ collapsible }
|
collapsible={ !! collapsible }
|
||||||
collapse={ collapse }
|
collapse={ !! collapse }
|
||||||
showItems={
|
showItems={
|
||||||
showItems || packageData?.shipping_rates?.length > 1
|
showItems || packageData?.shipping_rates?.length > 1
|
||||||
}
|
}
|
||||||
|
@ -167,6 +167,7 @@ const ShippingRatesControl = ( {
|
||||||
ShippingRatesControlPackage,
|
ShippingRatesControlPackage,
|
||||||
},
|
},
|
||||||
context,
|
context,
|
||||||
|
shippingRates,
|
||||||
};
|
};
|
||||||
const { isEditor } = useEditorContext();
|
const { isEditor } = useEditorContext();
|
||||||
|
|
||||||
|
@ -192,6 +193,7 @@ const ShippingRatesControl = ( {
|
||||||
/>
|
/>
|
||||||
<ExperimentalOrderShippingPackages>
|
<ExperimentalOrderShippingPackages>
|
||||||
<Packages
|
<Packages
|
||||||
|
showItems={ shippingRates.length > 1 }
|
||||||
packages={ shippingRates }
|
packages={ shippingRates }
|
||||||
noResultsMessage={ noResultsMessage }
|
noResultsMessage={ noResultsMessage }
|
||||||
renderOption={ renderOption }
|
renderOption={ renderOption }
|
||||||
|
|
|
@ -23,9 +23,10 @@ const Slot = ( {
|
||||||
cart,
|
cart,
|
||||||
components,
|
components,
|
||||||
context,
|
context,
|
||||||
|
shippingRates,
|
||||||
} ) => {
|
} ) => {
|
||||||
const { fills } = useSlot( slotName );
|
const { fills } = useSlot( slotName );
|
||||||
const hasMultiplePackages = fills.length > 1;
|
const hasMultiplePackages = fills.length > 1 || shippingRates?.length > 1;
|
||||||
return (
|
return (
|
||||||
<OrderShippingPackagesSlot
|
<OrderShippingPackagesSlot
|
||||||
className={ classnames(
|
className={ classnames(
|
||||||
|
|
Loading…
Reference in New Issue