Created
March 22, 2022 16:48
-
-
Save jmarreros/00220cf9bec36048a53a0b1434252cfb to your computer and use it in GitHub Desktop.
Move product price variation to top WooCommerce
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
<?php // No copiar este línea | |
add_action( 'wp_footer', 'dcms_add_script_footer' ); | |
function dcms_add_script_footer() { | |
if ( ! is_product() ) return; | |
?> | |
<script> | |
jQuery(function ($) { | |
$('.variations_form').on('woocommerce_variation_has_changed', function () { | |
const container_price_top = 'p.price'; | |
const container_price_bottom = '.woocommerce-variation-price'; | |
$(container_price_top).empty(); | |
setTimeout(function(){ | |
if ( $(container_price_bottom).is(":visible") ){ | |
const content = $(container_price_bottom).html(); | |
$(container_price_top).html(content); | |
$(container_price_bottom).hide(); | |
} | |
}, 500); | |
}); | |
}); | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment