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

Commit

Permalink
Hide Cross-Sells inner block behind experimental flag
Browse files Browse the repository at this point in the history
  • Loading branch information
nielslange committed Jun 30, 2022
1 parent 957fd57 commit 26527e7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* External dependencies
*/
import { Icon, column } from '@wordpress/icons';
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
import { registerExperimentalBlockType } from '@woocommerce/block-settings';

/**
* Internal dependencies
*/
import { Edit, Save } from './edit';
import metadata from './block.json';

registerFeaturePluginBlockType( metadata, {
registerExperimentalBlockType( metadata, {
icon: {
src: (
<Icon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* External dependencies
*/
import { Icon, column } from '@wordpress/icons';
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
import { registerExperimentalBlockType } from '@woocommerce/block-settings';

/**
* Internal dependencies
*/
import { Edit, Save } from './edit';
import metadata from './block.json';

registerFeaturePluginBlockType( metadata, {
registerExperimentalBlockType( metadata, {
icon: {
src: (
<Icon
Expand Down
5 changes: 4 additions & 1 deletion assets/js/blocks/cart/inner-blocks/cart-items-block/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { useBlockProps, InnerBlocks } from '@wordpress/block-editor';
import { Main } from '@woocommerce/base-components/sidebar-layout';
import { innerBlockAreas } from '@woocommerce/blocks-checkout';
import { isExperimentalBuild } from '@woocommerce/block-settings';
import type { TemplateArray } from '@wordpress/blocks';
/**
* Internal dependencies
Expand All @@ -22,7 +23,9 @@ export const Edit = ( { clientId }: Props ): JSX.Element => {
const allowedBlocks = getAllowedBlocks( innerBlockAreas.CART_ITEMS );
const defaultTemplate = [
[ 'woocommerce/cart-line-items-block', {}, [] ],
[ 'woocommerce/cart-cross-sells-block', {}, [] ],
...( isExperimentalBuild()
? [ 'woocommerce/cart-cross-sells-block', {}, [] ]
: [] ),
] as TemplateArray;

useForcedLayout( {
Expand Down
17 changes: 16 additions & 1 deletion assets/js/blocks/cart/inner-blocks/register-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
* External dependencies
*/
import { lazy } from '@wordpress/element';
import { WC_BLOCKS_BUILD_URL } from '@woocommerce/block-settings';
import {
WC_BLOCKS_BUILD_URL,
isExperimentalBuild,
} from '@woocommerce/block-settings';
import { registerCheckoutBlock } from '@woocommerce/blocks-checkout';

/**
Expand Down Expand Up @@ -58,6 +61,18 @@ registerCheckoutBlock( {
),
} );

if ( isExperimentalBuild() ) {
registerCheckoutBlock( {
metadata: metadata.CART_CROSS_SELLS,
component: lazy(
() =>
import(
/* webpackChunkName: "cart-blocks/cart-cross-sells" */
'./cart-cross-sells-block/frontend'
)
),
} );
}
registerCheckoutBlock( {
metadata: metadata.CART_TOTALS,
component: lazy(
Expand Down

0 comments on commit 26527e7

Please sign in to comment.