diff --git a/assets/js/blocks/mini-cart/edit.tsx b/assets/js/blocks/mini-cart/edit.tsx index 2d27388dc0d..38a0c3efe51 100644 --- a/assets/js/blocks/mini-cart/edit.tsx +++ b/assets/js/blocks/mini-cart/edit.tsx @@ -14,6 +14,7 @@ import { getSetting } from '@woocommerce/settings'; import { __ } from '@wordpress/i18n'; import Noninteractive from '@woocommerce/base-components/noninteractive'; import type { ReactElement } from 'react'; +import { useSelect } from '@wordpress/data'; /** * Internal dependencies @@ -23,6 +24,7 @@ import QuantityBadge from './quantity-badge'; interface Attributes { addToCartBehaviour: string; hasHiddenPrice: boolean; + cartAndCheckoutRenderStyle: boolean; } interface Props { @@ -31,11 +33,14 @@ interface Props { } const Edit = ( { attributes, setAttributes }: Props ): ReactElement => { - const { addToCartBehaviour, hasHiddenPrice } = attributes; + const { addToCartBehaviour, hasHiddenPrice, cartAndCheckoutRenderStyle } = + attributes; const blockProps = useBlockProps( { className: `wc-block-mini-cart`, } ); + const isSiteEditor = useSelect( 'core/edit-site' ) !== undefined; + const templatePartEditUri = getSetting( 'templatePartEditUri', '' @@ -54,6 +59,7 @@ const Edit = ( { attributes, setAttributes }: Props ): ReactElement => { ) } > { } ) } /> + { isSiteEditor && ( + { + setAttributes( { + cartAndCheckoutRenderStyle: value, + } ); + } } + help={ __( + 'Select how the Mini Cart behaves in the Cart and Checkout pages. This might affect the header layout.', + 'woo-gutenberg-products-block' + ) } + > + + + + ) } { templatePartEditUri && ( '; if ( is_cart() || is_checkout() ) { + if ( $this->should_not_render_mini_cart( $attributes ) ) { + return ''; + } + // It is not necessary to load the Mini Cart Block on Cart and Checkout page. return '