Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Frisoni/c8f9f4fbd08d68efd72f5dcccfb62836 to your computer and use it in GitHub Desktop.
Save Frisoni/c8f9f4fbd08d68efd72f5dcccfb62836 to your computer and use it in GitHub Desktop.
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('variable') ):
?><style> .woocommerce-variation-price {display:none;} </style>
<script>
jQuery(function($) {
var p = '.product-info .price-wrapper'
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment