Skip to content

Instantly share code, notes, and snippets.

@ValentinGenev
Last active October 4, 2019 13:39
Show Gist options
  • Save ValentinGenev/bce05f1121aa9c851be1682a59dcec10 to your computer and use it in GitHub Desktop.
Save ValentinGenev/bce05f1121aa9c851be1682a59dcec10 to your computer and use it in GitHub Desktop.
Changes the output markup of the product blocks.
<?php
if (!function_exists('woo_custom_product_block_markup')) {
function woo_custom_product_block_markup($data) {
$product_markup = new DOMDocument();
$product_markup->loadHTML($data);
$product_anchor = $product_markup->getElementsByTagName('a');
$product_id = '';
foreach ($product_anchor as $anchor) {
if ($anchor !== '') {
$product_id = $anchor->getAttribute('data-product_id');
}
}
$product = wc_get_product($product_id);
// more product data...
return '
<li class="' . implode(' ', wc_get_product_class('', $product)) . '">
<h3 class="title">' . get_the_title($product_id) . '</h3>
<!-- more html -->
</li>
';
}
}
add_filter('woocommerce_blocks_product_grid_item_html', 'woo_custom_product_block_markup');
@ValentinGenev
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment