Skip to content

Instantly share code, notes, and snippets.

@debonx
Created November 19, 2019 09:38
Show Gist options
  • Save debonx/cec5a17fb1992c7179d2167eb9e6920c to your computer and use it in GitHub Desktop.
Save debonx/cec5a17fb1992c7179d2167eb9e6920c to your computer and use it in GitHub Desktop.
How to filter Gutenberg WooCommerce blocks in WordPress.
add_filter( 'woocommerce_blocks_product_grid_item_html', 'filter_product_block', 10, 3);
function filter_product_block( $html, $data, $product )
{
$html = '<li class="wc-block-grid__product">
<div class="image-wrap">
<a href="' . $data->permalink . '" class="wc-block-grid__product-link">' . $data->image . '</a>
' . $data->button . '
</div>
<h3><a href="' . $data->permalink . '">' . $data->title . '</a></h3>
' . $data->badge . '
' . $data->price . '
' . $data->rating . '
</li>';
/**
* You can use also wc_get_template_html() to include WooCommerce Templates
**/
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment