Commit 81188774556 for woocommerce
commit 8118877455697652d20b71441dd24f292ccab355
Author: Albert Juhé Lluveras <contact@albertjuhe.com>
Date: Tue Jun 2 13:04:44 2026 +0200
Remove no longer needed render_block_with_context() util (#65411)
* Remove no longer needed render_block_with_context() util
* Add changelog
* Remove unused imports
* Add back 'render_block_with_context' deprecated function
* Revert "Add back 'render_block_with_context' deprecated function"
This reverts commit 3e104e8a5801c6d0ab795ea73594ebc2546910aa.
diff --git a/plugins/woocommerce/changelog/remove-render_block_with_context_util b/plugins/woocommerce/changelog/remove-render_block_with_context_util
new file mode 100644
index 00000000000..5b2b568b8dd
--- /dev/null
+++ b/plugins/woocommerce/changelog/remove-render_block_with_context_util
@@ -0,0 +1,5 @@
+Significance: patch
+Type: tweak
+Comment: Remove no longer needed render_block_with_context() util
+
+
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartWithOptions/GroupedProductItem.php b/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartWithOptions/GroupedProductItem.php
index bed63e5daf3..eed91c13526 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartWithOptions/GroupedProductItem.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartWithOptions/GroupedProductItem.php
@@ -5,7 +5,6 @@ namespace Automattic\WooCommerce\Blocks\BlockTypes\AddToCartWithOptions;
use Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock;
use Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait;
-use Automattic\WooCommerce\Blocks\BlockTypes\AddToCartWithOptions\Utils as AddToCartWithOptionsUtils;
use WP_Block;
/**
@@ -61,16 +60,18 @@ class GroupedProductItem extends AbstractBlock {
add_filter( 'render_block_context', array( $this, 'set_is_descendant_of_grouped_product_selector_context' ), 10, 2 );
- // Render the inner blocks of the Post Template block with `dynamic` set to `false` to prevent calling
- // `render_callback` and ensure that no wrapper markup is included.
- $block_content = AddToCartWithOptionsUtils::render_block_with_context(
- $block,
+ // Create new block with custom context.
+ $new_block = new WP_Block(
+ $block->parsed_block,
array(
'postType' => 'product',
'postId' => $post->ID,
- ),
+ )
);
+ // Render with dynamic set to false to prevent calling render_callback.
+ $block_content = $new_block->render( array( 'dynamic' => false ) );
+
remove_filter( 'render_block_context', array( $this, 'set_is_descendant_of_grouped_product_selector_context' ) );
$post = $previous_post; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartWithOptions/Utils.php b/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartWithOptions/Utils.php
index 54efc13832e..38c3b0f5f3b 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartWithOptions/Utils.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartWithOptions/Utils.php
@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Automattic\WooCommerce\Blocks\BlockTypes\AddToCartWithOptions;
use Automattic\WooCommerce\Enums\ProductType;
-use WP_Block;
/**
* Utility methods used for the Add to Cart + Options block.
@@ -226,27 +225,6 @@ class Utils {
return false;
}
- /**
- * Renders a new block with custom context
- *
- * @param WP_Block $block The block instance.
- * @param array $context The context for the new block.
- * @return string Rendered block content
- */
- public static function render_block_with_context( $block, $context ) {
- // Get an instance of the current block.
- $block_instance = $block->parsed_block;
-
- // Create new block with custom context.
- $new_block = new WP_Block(
- $block_instance,
- $context
- );
-
- // Render with dynamic set to false to prevent calling render_callback.
- return $new_block->render( array( 'dynamic' => false ) );
- }
-
/**
* Check if min and max purchase quantity are the same for a product.
*