Created
November 19, 2019 09:38
-
-
Save debonx/cec5a17fb1992c7179d2167eb9e6920c to your computer and use it in GitHub Desktop.
How to filter Gutenberg WooCommerce blocks in WordPress.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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