Gavrila Opris
Gavrila Opris

Reputation: 11

Display the correct price range on woocommerce product bundles with variations

I would like to display bundle price in top of page under product title.

Here is a screenshot of what I mean.

I use woocommerce and woocommerce product bundles and I found this code which replace variation price but I need to replace bundle price.

add_action('woocommerce_before_add_to_cart_form', 'selected_variation_price_replace_variable_price_range');

function selected_variation_price_replace_variable_price_range(){ global $product;

if( $product->is_type('bundle') ):
?><style> .woocommerce-variation-price {display:none;} </style>
<script>
jQuery(function($) {
    var p = 'p.price'
        q = $(p).html();

    $('form.cart').on('show_variation', function( event, data ) {
        if ( data.price_html ) {
            $(p).html(data.price_html);
        }
    }).on('hide_variation', function( event ) {
        $(p).html(q);
    });
});
</script>
<?php
endif;

}

Could someone please help with this issue.

Upvotes: 1

Views: 260

Answers (0)

Related Questions