Remove Active Shipping Zones check for displaying shipping calculator on Cart Page (#49214)

* Remove active shipping zones check for displaying shipping calculator

- Remove active shipping zones check for displaying shipping calculator on Cart Page

* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce

---------

Co-authored-by: Tarun Vijwani <tarun.vijwani@automattic.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
This commit is contained in:
Tarun Vijwani 2024-08-06 13:41:26 +04:00 committed by GitHub
parent c410610c62
commit 5e5378e444
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 29 deletions

View File

@ -3,11 +3,7 @@
*/
import { __ } from '@wordpress/i18n';
import { formatShippingAddress } from '@woocommerce/base-utils';
import { useEditorContext } from '@woocommerce/base-context';
import {
ShippingAddress as ShippingAddressType,
getSetting,
} from '@woocommerce/settings';
import { ShippingAddress as ShippingAddressType } from '@woocommerce/settings';
import PickupLocation from '@woocommerce/base-components/cart-checkout/pickup-location';
import { CHECKOUT_STORE_KEY } from '@woocommerce/block-data';
import { useSelect } from '@wordpress/data';
@ -25,41 +21,18 @@ export interface ShippingAddressProps {
shippingAddress: ShippingAddressType;
}
export type ActiveShippingZones = {
description: string;
}[];
export const ShippingAddress = ( {
showCalculator,
isShippingCalculatorOpen,
setIsShippingCalculatorOpen,
shippingAddress,
}: ShippingAddressProps ): JSX.Element | null => {
const { isEditor } = useEditorContext();
const prefersCollection = useSelect( ( select ) =>
select( CHECKOUT_STORE_KEY ).prefersCollection()
);
const activeShippingZones: ActiveShippingZones = getSetting(
'activeShippingZones'
);
const hasMultipleAndDefaultZone =
activeShippingZones.length > 1 &&
activeShippingZones.some(
( zone: { description: string } ) =>
zone.description === 'Everywhere' ||
zone.description === 'Locations outside all other zones'
);
const hasFormattedAddress = !! formatShippingAddress( shippingAddress );
// If there is no default customer location set in the store,
// and the customer hasn't provided their address,
// and only one default shipping method is available for all locations,
// then the shipping calculator will be hidden to avoid confusion.
if ( ! hasFormattedAddress && ! isEditor && ! hasMultipleAndDefaultZone ) {
return null;
}
const label = hasFormattedAddress
? __( 'Change address', 'woocommerce' )
: __( 'Calculate shipping for your location', 'woocommerce' );

View File

@ -0,0 +1,4 @@
Significance: minor
Type: fix
Remove Active Shipping Zones check for displaying shipping calculator on the Cart Page.

View File

@ -245,7 +245,6 @@ class Cart extends AbstractBlock {
$this->asset_data_registry->add( 'hasDarkEditorStyleSupport', current_theme_supports( 'dark-editor-style' ) );
$this->asset_data_registry->register_page_id( isset( $attributes['checkoutPageId'] ) ? $attributes['checkoutPageId'] : 0 );
$this->asset_data_registry->add( 'isBlockTheme', wc_current_theme_is_fse_theme() );
$this->asset_data_registry->add( 'activeShippingZones', CartCheckoutUtils::get_shipping_zones() );
$pickup_location_settings = LocalPickupUtils::get_local_pickup_settings();
$this->asset_data_registry->add( 'localPickupEnabled', $pickup_location_settings['enabled'] );