Add wc-blocks-registry as a dependency to product collection tester script

This commit is contained in:
“Joshua 2024-09-19 14:33:34 -04:00
parent e83eb82f92
commit d69dc0feef
2 changed files with 15 additions and 1 deletions

View File

@ -27,6 +27,20 @@ The `__experimentalRegisterProductCollection` function is part of the `@woocomme
});
```
Be sure to add `wc-blocks-registry` as a dependency to your script if you opt to use the `wc` global.
```php
function enqueue_my_custom_product_collection_script() {
wp_enqueue_script(
'my-custom-product-collection',
plugins_url( '/dist/my-custom-product-collection.js', __FILE__ ),
array( 'wc-blocks-registry' ),
10
);
}
add_action( 'enqueue_block_editor_assets', 'enqueue_my_custom_product_collection_script' );
```
> [!TIP]
> The first method is recommended if you are using Webpack.

View File

@ -21,7 +21,7 @@ function register_product_collections_script()
wp_enqueue_script(
'rpc_register_product_collections',
plugins_url('register-product-collection-tester/index.js', __FILE__),
array('wp-element', 'wp-blocks', 'wp-i18n', 'wp-components', 'wp-editor', 'wc-blocks'),
array('wp-element', 'wp-blocks', 'wp-i18n', 'wp-components', 'wp-editor', 'wc-blocks', 'wc-blocks-registry'),
filemtime(plugin_dir_path(__FILE__) . 'register-product-collection-tester/index.js'),
true
);