WP SITES

3082 Coded Tutorials & 285 Plugins

How To Add Custom HTML to Cart Page Blocks WooCommerce

You can use this code in your child theme functions file or custom code snippets plugin to add custom HTML or execute a function on your cart page.

add_filter( 'render_block', 'wpsites_cart_items_block', 10, 2 );
function wpsites_cart_items_block( $block_content, $block ) {

        if ( isset( $block['blockName'] ) && $block['blockName'] === 'woocommerce/cart-items-block' ) {
     
        $content = '<div class="checkout-block-html">Custom HTML Cart Item Block</div>';
        
        return $content;
        
        }
        
        return $block_content;
        
}

The output is in this position :

= Related =

Leave a Reply

New Plugins