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

Commit acc62a7

Browse files
authored
Prevent hydration in the editor (#8413)
1 parent 0d68203 commit acc62a7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/BlockTypes/AllProducts.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@ protected function enqueue_data( array $attributes = [] ) {
3030
$this->asset_data_registry->add( 'min_rows', wc_get_theme_support( 'product_blocks::min_rows', 1 ), true );
3131
$this->asset_data_registry->add( 'max_rows', wc_get_theme_support( 'product_blocks::max_rows', 6 ), true );
3232
$this->asset_data_registry->add( 'default_rows', wc_get_theme_support( 'product_blocks::default_rows', 3 ), true );
33-
$this->hydrate_from_api();
33+
34+
// Hydrate the following data depending on admin or frontend context.
35+
if ( ! is_admin() && ! WC()->is_rest_api_request() ) {
36+
$this->hydrate_from_api();
37+
}
3438
}
3539

3640
/**
37-
* Hydrate the All Product block with data from the API.
41+
* Hydrate the All Product block with data from the API. This is for the add to cart buttons which show current
42+
* quantity in cart, and events.
3843
*/
3944
protected function hydrate_from_api() {
4045
$this->asset_data_registry->hydrate_api_request( '/wc/store/v1/cart' );

0 commit comments

Comments
 (0)