Sales badges for the WooCommerce page blocks
If you’ve created the page using standard WooCommerce page blocks and haven’t seen the sales badges, follow these steps:
1) Update Advanced Dynamic Pricing for WooCommerce to the latest version;
2) Insert this hook into the functions.php of your theme:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
add_filter( 'woocommerce_blocks_product_grid_item_html', function ($html, $data, $productC) { global $product; $product = $productC; ob_start(); woocommerce_show_product_loop_sale_flash(); $data->badge = ob_get_contents(); ob_end_clean(); return "<li class=\"wc-block-grid__product\"> <a href=\"{$data->permalink}\" class=\"wc-block-grid__product-link\"> {$data->image} {$data->title} </a> {$data->badge} {$data->price} {$data->rating} {$data->button} </li>"; }, 10, 3 ); |