Changing Rendering Behavior Bundle Item on Cart – WC Product Bundles

As you aware that WC Product Bundles ( wcpb ) is a wordpress plugin for woocommerce, using which you can create combo products. In this article we are going to see how to customize bundles meta on cart item.

By default wcpb renders bundles meta on cart line like this

<dl class="wcpb-cart-item-container">
    <dt>Bundle Includes</dt>
        <div>1 x <a href="#">Item Title 1</a></div>
        <div>1 x <a href="#">Item Title 2</a></div>

If you want to change the bundle meta skeleton, here is how you will do

function wcpb_render_bundle_item( $bundles ) {    
    $html .= '<div>';
    $html .= '<h4>Bundle Includes<h4>';
    $html .= '<ul>';
    foreach ( $bundles as $key => $bundle ) {
        if ( get_post_type( $key ) == 'product_variation' ) {							
            $html .= '<li>'. $bundle['quantity'] .' x <a href="'. get_permalink( wp_get_post_parent_id( $key ) ) .'">'. $bundle['title'] .'</a></li>';
        } else {
            $html .= '<li>'. $bundle['quantity'] .' x <a href="'. get_permalink( $key ) .'">'. $bundle['title'] .'</a></li>';
    $html .= '</ul>';
    $html .= '</div>';                
    return $html;
add_filter( 'wcpb/bundle/item/rendering', 'wcpb_render_bundle_item' );

Happy Coding.!

Leave a Reply

Your email address will not be published. Required fields are marked *