This commit is contained in:
Mike Jolley 2021-08-18 11:41:18 +01:00 committed by GitHub
parent 3f55ed5566
commit a9e403c0be
1 changed files with 10 additions and 0 deletions

View File

@ -175,18 +175,28 @@ export const registerCheckoutBlock = (
assertOption( options, 'areas', 'array' );
assertBlockComponent( options, 'component' );
/**
* If provided with a configuration object, this registers the block with WordPress.
*/
if ( options?.configuration ) {
assertOption( options, 'configuration', 'object' );
registerExperimentalBlockType( blockName, {
...options.configuration,
category: 'woocommerce',
parent: [],
} );
}
/**
* This enables the inner block within specific areas. See RegisteredBlocks.
*/
options.areas.forEach( ( area ) =>
registerBlockForArea( area, blockName )
);
/**
* This ensures the frontend component for the checkout block is available.
*/
registerBlockComponent( {
blockName,
component: options.component,