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:
parent
c410610c62
commit
5e5378e444
|
@ -3,11 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { formatShippingAddress } from '@woocommerce/base-utils';
|
import { formatShippingAddress } from '@woocommerce/base-utils';
|
||||||
import { useEditorContext } from '@woocommerce/base-context';
|
import { ShippingAddress as ShippingAddressType } from '@woocommerce/settings';
|
||||||
import {
|
|
||||||
ShippingAddress as ShippingAddressType,
|
|
||||||
getSetting,
|
|
||||||
} from '@woocommerce/settings';
|
|
||||||
import PickupLocation from '@woocommerce/base-components/cart-checkout/pickup-location';
|
import PickupLocation from '@woocommerce/base-components/cart-checkout/pickup-location';
|
||||||
import { CHECKOUT_STORE_KEY } from '@woocommerce/block-data';
|
import { CHECKOUT_STORE_KEY } from '@woocommerce/block-data';
|
||||||
import { useSelect } from '@wordpress/data';
|
import { useSelect } from '@wordpress/data';
|
||||||
|
@ -25,41 +21,18 @@ export interface ShippingAddressProps {
|
||||||
shippingAddress: ShippingAddressType;
|
shippingAddress: ShippingAddressType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ActiveShippingZones = {
|
|
||||||
description: string;
|
|
||||||
}[];
|
|
||||||
|
|
||||||
export const ShippingAddress = ( {
|
export const ShippingAddress = ( {
|
||||||
showCalculator,
|
showCalculator,
|
||||||
isShippingCalculatorOpen,
|
isShippingCalculatorOpen,
|
||||||
setIsShippingCalculatorOpen,
|
setIsShippingCalculatorOpen,
|
||||||
shippingAddress,
|
shippingAddress,
|
||||||
}: ShippingAddressProps ): JSX.Element | null => {
|
}: ShippingAddressProps ): JSX.Element | null => {
|
||||||
const { isEditor } = useEditorContext();
|
|
||||||
const prefersCollection = useSelect( ( select ) =>
|
const prefersCollection = useSelect( ( select ) =>
|
||||||
select( CHECKOUT_STORE_KEY ).prefersCollection()
|
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 );
|
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
|
const label = hasFormattedAddress
|
||||||
? __( 'Change address', 'woocommerce' )
|
? __( 'Change address', 'woocommerce' )
|
||||||
: __( 'Calculate shipping for your location', 'woocommerce' );
|
: __( 'Calculate shipping for your location', 'woocommerce' );
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Remove Active Shipping Zones check for displaying shipping calculator on the Cart Page.
|
|
@ -245,7 +245,6 @@ class Cart extends AbstractBlock {
|
||||||
$this->asset_data_registry->add( 'hasDarkEditorStyleSupport', current_theme_supports( 'dark-editor-style' ) );
|
$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->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( '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();
|
$pickup_location_settings = LocalPickupUtils::get_local_pickup_settings();
|
||||||
$this->asset_data_registry->add( 'localPickupEnabled', $pickup_location_settings['enabled'] );
|
$this->asset_data_registry->add( 'localPickupEnabled', $pickup_location_settings['enabled'] );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue