Fix: Make woocommerce/product-price available in the Single Product template (#49906)
* fix: register woocommerce/product-price using registerBlockSingleProductTemplate * fix: remove unnecessary blockMetadata * chore: changelog * Enable Product Price in post editor --------- Co-authored-by: Karol Manijak <20098064+kmanijak@users.noreply.github.com>
This commit is contained in:
parent
e39da623cf
commit
ac5b051fc2
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { registerBlockType } from '@wordpress/blocks';
|
import { registerBlockSingleProductTemplate } from '@woocommerce/atomic-utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
@ -28,4 +28,8 @@ const blockConfig = {
|
||||||
edit,
|
edit,
|
||||||
};
|
};
|
||||||
|
|
||||||
registerBlockType( 'woocommerce/product-price', blockConfig );
|
registerBlockSingleProductTemplate( {
|
||||||
|
blockName: 'woocommerce/product-price',
|
||||||
|
blockSettings: blockConfig,
|
||||||
|
isAvailableOnPostEditor: true,
|
||||||
|
} );
|
||||||
|
|
|
@ -32,7 +32,7 @@ export const registerBlockSingleProductTemplate = ( {
|
||||||
isAvailableOnPostEditor,
|
isAvailableOnPostEditor,
|
||||||
}: {
|
}: {
|
||||||
blockName: string;
|
blockName: string;
|
||||||
blockMetadata: Partial< BlockConfiguration >;
|
blockMetadata?: string | Partial< BlockConfiguration >;
|
||||||
blockSettings: Partial< BlockConfiguration >;
|
blockSettings: Partial< BlockConfiguration >;
|
||||||
isAvailableOnPostEditor: boolean;
|
isAvailableOnPostEditor: boolean;
|
||||||
isVariationBlock?: boolean;
|
isVariationBlock?: boolean;
|
||||||
|
@ -40,6 +40,10 @@ export const registerBlockSingleProductTemplate = ( {
|
||||||
} ) => {
|
} ) => {
|
||||||
let currentTemplateId: string | undefined = '';
|
let currentTemplateId: string | undefined = '';
|
||||||
|
|
||||||
|
if ( ! blockMetadata ) {
|
||||||
|
blockMetadata = blockName;
|
||||||
|
}
|
||||||
|
|
||||||
subscribe( () => {
|
subscribe( () => {
|
||||||
const previousTemplateId = currentTemplateId;
|
const previousTemplateId = currentTemplateId;
|
||||||
const store = select( 'core/edit-site' );
|
const store = select( 'core/edit-site' );
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Fix: Make woocommerce/product-price available in the Single Product template
|
Loading…
Reference in New Issue