Product Collection: Fix: ensure the global product object is always ready for compatibility layer (#49971)
* add: method for block to declare extra block setting for registration * update: register Product Template block with skip_inner_blocks * chore: remove unused import * chore: changelog * Revert "update: register Product Template block with skip_inner_blocks" This reverts commit88b076bde3
. * Revert "add: method for block to declare extra block setting for registration" This reverts commitd1545dbba5
. * fix: filter block setting for product template * chore: changelog * Revert "chore: remove unused import" This reverts commit0f8f66bad1
.
This commit is contained in:
parent
aaf3046eb6
commit
5047182efd
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Fix: ensure the global product object is always ready for compatibility layer by disabling default render routine of Product Templates inner blocks.
|
|
@ -17,6 +17,18 @@ class ProductTemplate extends AbstractBlock {
|
|||
*/
|
||||
protected $block_name = 'product-template';
|
||||
|
||||
/**
|
||||
* Initialize this block type.
|
||||
*
|
||||
* - Hook into WP lifecycle.
|
||||
* - Register the block with WordPress.
|
||||
* - Hook into pre_render_block to update the query.
|
||||
*/
|
||||
protected function initialize() {
|
||||
add_filter( 'block_type_metadata_settings', array( $this, 'add_block_type_metadata_settings' ), 10, 2 );
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the frontend script handle for this block type.
|
||||
*
|
||||
|
@ -134,4 +146,19 @@ class ProductTemplate extends AbstractBlock {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Product Template renders inner blocks manually so we need to skip default
|
||||
* rendering routine for its inner blocks
|
||||
*
|
||||
* @param array $settings Array of determined settings for registering a block type.
|
||||
* @param array $metadata Metadata provided for registering a block type.
|
||||
* @return array
|
||||
*/
|
||||
public function add_block_type_metadata_settings( $settings, $metadata ) {
|
||||
if ( ! empty( $metadata['name'] ) && 'woocommerce/product-template' === $metadata['name'] ) {
|
||||
$settings['skip_inner_blocks'] = true;
|
||||
}
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue