WP SITES

3095 Coded Tutorials & 297 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 :

Cart page displaying a custom HTML cart item block with a single product demo, quantity selector, and total price.

= Related =

Was this helpful?

Yes
No
Thanks for your feedback!

Leave a Reply