Skip to content

Instantly share code, notes, and snippets.

@jmarreros
Created March 22, 2022 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmarreros/00220cf9bec36048a53a0b1434252cfb to your computer and use it in GitHub Desktop.
Save jmarreros/00220cf9bec36048a53a0b1434252cfb to your computer and use it in GitHub Desktop.
Move product price variation to top WooCommerce
<?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