Created
October 20, 2021 13:46
-
-
Save Frisoni/c8f9f4fbd08d68efd72f5dcccfb62836 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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