From 5e5378e444527df7dc5bf794899aa9399c7c38ab Mon Sep 17 00:00:00 2001 From: Tarun Vijwani <11503784+tarunvijwani@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:41:26 +0400 Subject: [PATCH] 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 Co-authored-by: github-actions Co-authored-by: Seghir Nadir --- .../totals/shipping/shipping-address.tsx | 29 +------------------ ...emove-active-shipping-zone-check-cart-page | 4 +++ .../src/Blocks/BlockTypes/Cart.php | 1 - 3 files changed, 5 insertions(+), 29 deletions(-) create mode 100644 plugins/woocommerce/changelog/49214-fix-remove-active-shipping-zone-check-cart-page diff --git a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/shipping/shipping-address.tsx b/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/shipping/shipping-address.tsx index dd9eb92adf7..2c3e645eabb 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/shipping/shipping-address.tsx +++ b/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/shipping/shipping-address.tsx @@ -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' ); diff --git a/plugins/woocommerce/changelog/49214-fix-remove-active-shipping-zone-check-cart-page b/plugins/woocommerce/changelog/49214-fix-remove-active-shipping-zone-check-cart-page new file mode 100644 index 00000000000..985ae712a88 --- /dev/null +++ b/plugins/woocommerce/changelog/49214-fix-remove-active-shipping-zone-check-cart-page @@ -0,0 +1,4 @@ +Significance: minor +Type: fix + +Remove Active Shipping Zones check for displaying shipping calculator on the Cart Page. \ No newline at end of file diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/Cart.php b/plugins/woocommerce/src/Blocks/BlockTypes/Cart.php index b3cabefb20c..11f8bdb2d26 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/Cart.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/Cart.php @@ -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'] );