WordPress filter hook
woocommerce_blocks_product_grid_item_html
Defined by WooCommerce and fired by 3 plugins in total, running on 7M+ sites between them.
“Filters the HTML for products in the grid.”
How to use woocommerce_blocks_product_grid_item_html
It's a filter: your callback receives the value and 2 more arguments, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'woocommerce_blocks_product_grid_item_html', function( $value, $data, $product ) {
// Change $value here.
return $value;
}, 10, 3 );Argument names come from WooCommerce's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
3 plugins that fire woocommerce_blocks_product_grid_item_html
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
WooCommerce7+ million installs
apply_filters( 'woocommerce_blocks_product_grid_item_html', "<li class=\"wc-block-grid__product\"> <a href=\"{$data->permalink}\" class=\"wc-block-grid__product-link\"> {$data->badge} {$data->image} {$data->title} </a> {$data->price} {$data->rating} {$data->button} </li>", $data, $product )src/Blocks/BlockTypes/AbstractProductGrid.php:516 -
Boostify BlocksFewer than 10 installs
apply_filters( 'woocommerce_blocks_product_grid_item_html', "<div class=\"scroll-snap-slide {$escaped_classes}\" data-index=\"{$escaped_index}\"> <div class=\"wcb-products__product-featured \"> <a href=\"{$escaped_permalink}\" class=\"{$escaped_feat_classes}\"> {$data->image} {$isSwapHover} </a> {$topRightIconsHtml} {$bottomRightIconHtml} {$btnQuickViewBottomImageHtml} {$countdownHtml} {$saleBadge1} {$saleOutOfStock} </div> {$data->categories} {$data->t... )includes/wcb-render-callback-for-block-products.php:557 -
DresooFewer than 10 installs
apply_filters( 'woocommerce_blocks_product_grid_item_html', "<li class=\"col wc-block-grid__product\"> <a href=\"{$data->permalink}\" class=\"wc-block-grid__product-link\" target='_blank' data-pid=\"{$id}\"> {$data->image} {$data->title} </a> {$data->badge} {$data->price} {$data->rating} {$data->button} {$data->color} </li>", $this->block_name, $data, $product )blocks/AbstractProductGrid.php:405
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.