Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 3105070

Browse files
authored
Mini-Cart: prevent 'Mini-Cart in cart and checkout pages' toggle from showing up in the post/page editor (#9442)
1 parent f9f6258 commit 3105070

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

assets/js/blocks/mini-cart/edit.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { getSetting } from '@woocommerce/settings';
1515
import { __ } from '@wordpress/i18n';
1616
import Noninteractive from '@woocommerce/base-components/noninteractive';
1717
import type { ReactElement } from 'react';
18-
import { useSelect } from '@wordpress/data';
1918

2019
/**
2120
* Internal dependencies
@@ -34,14 +33,18 @@ interface Props {
3433
setAttributes: ( attributes: Record< string, unknown > ) => void;
3534
}
3635

37-
const Edit = ( { attributes, setAttributes }: Props ): ReactElement => {
36+
const Edit = ( {
37+
attributes,
38+
setAttributes,
39+
context: { postType, postId },
40+
}: Props ): ReactElement => {
3841
const { addToCartBehaviour, hasHiddenPrice, cartAndCheckoutRenderStyle } =
3942
attributes;
4043
const blockProps = useBlockProps( {
4144
className: `wc-block-mini-cart`,
4245
} );
4346

44-
const isSiteEditor = useSelect( 'core/edit-site' ) !== undefined;
47+
const isSiteEditor = postType === undefined || postId === undefined;
4548

4649
const templatePartEditUri = getSetting(
4750
'templatePartEditUri',

assets/js/blocks/mini-cart/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const settings: BlockConfiguration = {
4848
className: 'wc-block-mini-cart--preview',
4949
},
5050
},
51+
usesContext: [ 'postId', 'postType' ],
5152
attributes: {
5253
isPreview: {
5354
type: 'boolean',

0 commit comments

Comments
 (0)